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

SOCKS and/or HTTP CONNECT proxy #1151

Open
riastradh opened this issue Jun 5, 2023 · 12 comments · May be fixed by #1204
Open

SOCKS and/or HTTP CONNECT proxy #1151

riastradh opened this issue Jun 5, 2023 · 12 comments · May be fixed by #1204

Comments

@riastradh
Copy link

riastradh commented Jun 5, 2023

Is your feature request related to a problem? Please describe.
kinit, kgetcred, gss_init_sec_context, and applications that use these via libkrb5 or libgssapi or equivalent all do DNS lookups and talk in the clear directly to a KDC over the internet.

This leaks two things:

  1. the realm you're logging into and the principal you're logging in as, to anyone on the network between you and the KDC, such as eavesdroppers sitting across the coffee shop; and
  2. your location (IP address), to the KDC.

Describe the solution you'd like
krb5.conf should have an option for connecting to the KDC via TCP through a SOCKS proxy and/or an HTTP CONNECT proxy, leaving all name resolution to the proxy.

This way, all these connections can be done through Tor, for any application that is able to use Tor for connections to the service, or through an ssh -D forward. (Of course, it requires domain-to-realm and realm-to-KDC mapping to be hard-coded in the local krb5.conf, and DNS mapping to be disabled.)

Describe alternatives you've considered
Heimdal currently has an option http_proxy but it is only used for KDCs reached through HTTP anyway, which I believe is off by default.

Heimdal currently has an option dns_proxy but (a) it only covers the DNS queries (like the service name canonicalization which shouldn't be happening anyway, domain-to-realm mapping, and KDC SRV/A/AAAA records), not communication with the KDC itself, and (b) it is a bizarre protocol that came out of nowhere and probably isn't very useful.

Additional context
Portrait of Heimdall apparently wearing some kind of socks, with a chicken on his head

@lhoward
Copy link
Member

lhoward commented Jun 5, 2023 via email

@riastradh
Copy link
Author

IAKERB would be better, no?

If I understand correctly, IAKERB is a mechanism for forwarding the user<->KDC exchanges through a GSSAPI channel already being established between user<->service, rather than through a side channel opened by libkrb5, to acquire a service ticket given a tgt. (Please correct me if I misunderstood!)

  1. How does that help with kinit?

  2. Does Heimdal support IAKERB?

    Looks like no (should perhaps file a separate issue for that!) -- and I suspect the effort to implement SOCKS proxy support would be considerably less.

  3. How widely deployed is IAKERB in services?

@lhoward
Copy link
Member

lhoward commented Jun 5, 2023

MIT has shipped with IAKERB for a long time, macOS has its own implementation (which is open source, so could be integrated into Heimdal – they use Heimdal), and it's coming in a future version of Windows. But yes, more work than SOCKS support.

@nicowilliams
Copy link
Contributor

Heimdal does have KDC-over-HTTP support, but not KDC-over-HTTPS -- that would require using OpenSSL for TLS, or maybe s2n.

I've been wanting to import s2n into Heimdal so that we can make a GSS-API mechanism that speaks TLS when no application framing is added -- that's basically what SChannel is, but with SSPI instead of GSS. So I'd be inclined to use s2n to implement KDC-over-HTTPS.

If I understand correctly, IAKERB is a mechanism for forwarding the user<->KDC exchanges through a GSSAPI channel already being established between user<->service, rather than through a side channel opened by libkrb5, to acquire a service ticket given a tgt. (Please correct me if I misunderstood!)

Correct.

1. How does that help with kinit?

Well, it doesn't, unless you defer kinit till gss_init_sec_context() time or have a GSS mechanism you can use as a kinit of sorts.

2. Does Heimdal support IAKERB?
   Looks like no (should perhaps file a separate issue for that!) -- and I suspect the effort to implement SOCKS proxy support would be considerably less.

Heimdal does not support IAKERB, no.

3. How widely deployed is IAKERB in services?

Well, Microsoft has expressed interest in extending IAKERB so that it can be used to replace NTLM(!), but apart from that bit of vaporware: not at all.

I'd rather do something simpler:

  • kinit as an HTTPS service

so that FIDO/UDF/whatever can be something the service implements and then it vends a serialized Kerberos credential.

As it happens, something like that exists in-tree right now (kdc/bx509d.c) which implements an online CA, but also a /get-ticket end-point that uses... the CA internally to mint a PKINIT client certificate then uses that to get a ticket using PKINIT. Now, it's written in C, and I'd rather we stop writing at least new services in C and go to something more memory safe, and it doesn't support random authentication mechanisms either. But if you have a suitable HTTP server that can do TLS and FIDO/UDF, then it's a great starting point.

To some degree I'm asking: why even bother with Kerberos? Well, there's a few reasons, though not all exactly compelling:

  • post-quantum a Needham-Schröder protocol could be used to amortize the cost of slow/bulky PK
  • installed base

My own preference (see recent-ish posts on the IETF KITTEN WG list) would be to extend JWT so that it can provide all the functionality that GSS-API Kerberos apps typically expect:

  • Kerberos principal names
  • key exchange
  • 1, 2, and 3 message protocol options

but also to extend JWT so that it has a standard fetch-a-token protocol that browsers and other HTTP user-agents can follow.

@lhoward
Copy link
Member

lhoward commented Jun 6, 2023

Heimdal does not support IAKERB, no.

Well, to be pedantic, Heimdal does (in Apple's implementation). So it wouldn't be impossible to merge their code.

@nicowilliams
Copy link
Contributor

Heimdal does not support IAKERB, no.

Well, to be pedantic, Heimdal does (in Apple's implementation). So it wouldn't be impossible to merge their code.

Ah, I didn't know. I mean, I suppose we could, but MIT's experience with IAKERB wasn't great. OTOH, if @SteveSyfuhs is serious about building an NTLM replacement out of IAKERB then we might have to. Still, that wouldn't get us much closer to having what @riastradh is asking for.

@SteveSyfuhs
Copy link

SteveSyfuhs commented Jun 6, 2023 via email

@nicowilliams
Copy link
Contributor

Good news! Futurama.gif

:)

All of that said FAST with armoring is also an option, which shields a lot of information on the wire. Though admittedly still leaves some things in the clear.

The realm name and the client's IP remain in the clear. Now the client's IP will always be in the clear, and KDCs might want to see it. A VPN or a proxy will take care of the realm name. This is fairly hard work here.

But on the plus side, if we did a kinit-over-HTTPS sort of thing that might take care of OP's desire for FIDO/UDF and proxying.

@riastradh
Copy link
Author

To some degree I'm asking: why even bother with Kerberos?

For the purpose of this issue, the premise is that I, as a user of client-side SSO, want to be able to log into existing Kerberos realms that I have no control over, but I don't want to expose records of my location when I log in, or reveal to others on the network who I am or what I'm logging into.

(For the U2F/FIDO or IAKERB questions, which necessarily involve changes to a realm at the very least to upgrade the KDC software, let's discuss those in other issues -- U2F/FIDO, IAKERB.)

@SteveSyfuhs
Copy link

SteveSyfuhs commented Jun 6, 2023 via email

@nicowilliams
Copy link
Contributor

I don't have much skin in the heimdal game, so obviously my opinion is just that. HTTPS is the transport de rigueur for all things and any transport otherwise in the stack is going to be scrutinized by everyone, except perhaps for a direct TLS or QUIC thing with less framing. But also HTTPS is a known quantity and everyone's favorite OS already supports it natively.

Heh, well, I share your opinion. Honestly, I want to replace Kerberos with something like I've described (JWT + bits needed to replace Kerberos as a drop-in), and any protocols for talking to a KDC-like entity should run over HTTPS.

riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 2, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS5 might be OK but takes more work to
implement.)

XXX Need to audit Heimdal for other kinds of traffic too.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
@riastradh riastradh linked a pull request Jan 2, 2024 that will close this issue
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 3, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

XXX Need to audit Heimdal for other kinds of traffic too outside
libkrb5.  Subsequent changes on this branch will address other parts
of libkrb5.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 3, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

XXX Need to audit Heimdal for other kinds of traffic too outside
libkrb5.  Subsequent changes on this branch will address other parts
of libkrb5.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 4, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

XXX Need to audit Heimdal for other kinds of traffic too outside
libkrb5.  Subsequent changes on this branch will address other parts
of libkrb5.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 4, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

XXX Need to audit Heimdal for other kinds of traffic too outside
libkrb5.  Subsequent changes on this branch will address other parts
of libkrb5.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 5, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

XXX Need to audit Heimdal for other kinds of traffic too outside
libkrb5.  Subsequent changes on this branch will address other parts
of libkrb5.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 7, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

XXX Need to audit Heimdal for other kinds of traffic too outside
libkrb5.  Subsequent changes on this branch will address other parts
of libkrb5.

XXX Need to combine with heimdal#1155
to plug DNS leaks.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 10, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

This only affects krb5_sendto -- the other initiator of network
traffic in libkrb5, krb5_change_password, will be fixed to respect
socks4a_proxy in a subsequent commit.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
riastradh pushed a commit to riastradh/heimdal that referenced this issue Jan 10, 2024
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

This only affects krb5_sendto -- the other initiator of network
traffic in libkrb5, krb5_change_password, will be fixed to respect
socks4a_proxy in a subsequent commit.

XXX Need to figure out where the socks4a.c code should go.

fix heimdal#1151
@tiran
Copy link

tiran commented Mar 27, 2024

Heimdal does not support IAKERB, no.

Well, to be pedantic, Heimdal does (in Apple's implementation). So it wouldn't be impossible to merge their code.

A co-worker found this issue while we were investigating a bug report for kdcproxy related to Apple's copy of Heimdal. Apple's implementation of MS-KKDCP protocol violates the spec and is incompatible with MIT Kerberos, Active Directory, and FreeIPA's kdcproxy. You might want to wait until Apple has acknowledged and fixed the bug.

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 a pull request may close this issue.

5 participants