Skip to content

Segmentation fault when destroying PySecBuffer #700

@ghost

Description

Environment
Windows 7
Visual Studio 2008
Python 2.7.8
kerberos_sspi 0.2
pywin32 219

When returning from the function "authGSSClientUnwrap" in the library "kerberos_sspi": https://pypi.python.org/pypi/kerberos-sspi/0.2, I encounter a segfault coming from ~PySecBuffer().

Reproduction

#!/usr/bin/python
import kerberos_sspi

# SERVICE = xxx
# HOST = xxx

def repro():
    result, ctx = kerberos.authGSSClientInit(
        SERVICE + '@' + HOST, gssflags=kerberos.GSS_C_MUTUAL_FLAG)
    kerberos.authGSSClientStep(ctx, '')
    payload = kerberos.authGSSClientResponse(ctx)
    # Create response to intiiate SASL conversation
    response = make_sasl_start_response(payload)
    # Enter loop to catch protocol/library issues
    for _ in range(10):
        result = kerberos.authGSSClientStep(ctx, str(response['payload']))
        payload = kerberos.authGSSClientResponse(ctx) or ''
        response = make_sasl_continue_response(payload)
        if kerberos.AUTH_GSS_COMPLETE == result:
            break
    else:
        raise Exception("auth failed")
    # This causes a segmentation fault:
    kerberos.authGSSClientUnwrap(ctx, str(response['payload']))

You can find the original code that's causing this segmentation fault here: https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/auth.py#L261-L326. Note that this code doesn't currently support using "kerberos_sspi" due to this and another problem. However, it's possible to reproduce this issue by doing a "import kerberos_sspi as kerberos" in lieu of the other kerberos imports in this file.

The source for the kerberos_sspi module is here: https://github.com/may-day/kerberos-sspi/blob/kerberos-sspi-0.2/kerberos_sspi.py

Thank you so much for looking into this. Please let me know if I can provide any more detail.

Reported by: llvtt

Original Ticket: pywin32/bugs/700

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions