Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DNS hostname canonicalization #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

steelman
Copy link

Optionally resolve hostname via CNAME recrord to its canonical form (A or AAAA record). Optionally use reverse DNS query.

Such code is necessary on Windows platforms where SSPI (unlike MIT Kerberos[1]) does not implement such operation and it is applications' responsibility[2] to take care of CNAME resolution. However, the code seems universal enough to put it into the library rather than in every single program using requests_gssapi.

[1] https://github.com/krb5/krb5/blob/ec71ac1cabbb3926f8ffaf71e1ad007e4e56e0e5/src/lib/krb5/os/sn2princ.c#L99
[2] https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-server-2010/gg502606(v=office.14)?redirectedfrom=MSDN#kerberos-authentication-and-dns-cnames

@steelman
Copy link
Author

steelman commented Apr 3, 2024

Ping?

@simo5
Copy link

simo5 commented Apr 3, 2024

The reason why SSPI does not implement it is that it is unsafe, and can lead to MITM scenarios, especially with protocols like NTLMSSP.

I am not entirely sure we should provide this functionality from request-gssapi, because it is bound to be used without understanding opening up users of the application to bad surprises later.

I think at the very least these should not be common options provided in the function signature, and instead accessors you need to explicitly find and set individually after the HTTPSPNEGOAuth object has been instantiated.

ie:

    >>> import requests
    >>> from requests_gssapi import HTTPSPNEGOAuth
    >>> gssapi_auth = HTTPSPNEGOAuth()
    >>> gssapi_auth.dns_canonicalize_hostname(True)
    >>> gssapi_auth.use_reverse_dns(True)
    >>> r = requests.get("http://example.org", auth=gssapi_auth)

This will discourage casual setting and each of the effects can be documented in a doc string for the accessor.

The doc string MUST contain warnings that describe why these options are BAD ideas, and point to the relvant security sections of the RFC for a full description.

Optionally resolve hostname via CNAME recrord to its canonical form
(A or AAAA record). Optionally use reverse DNS query.

Such code is necessary on Windows platforms where SSPI (unlike MIT
Kerberos[1]) does not implement such operation and it is applications'
responsibility[2] to take care of CNAME resolution. However, the code
seems universal enough to put it into the library rather than in every
single program using requests_gssapi.

Warning: Usage of insecure DNS queries is explicitly forbidden in
RFC 4120[3] and may result in the risk of man-in-the-middle attack.

[1] https://github.com/krb5/krb5/blob/ec71ac1cabbb3926f8ffaf71e1ad007e4e56e0e5/src/lib/krb5/os/sn2princ.c#L99
[2] https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-server-2010/gg502606(v=office.14)?redirectedfrom=MSDN#kerberos-authentication-and-dns-cnames
[3] https://datatracker.ietf.org/doc/html/rfc4120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants