-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Preserve roles from user cert when forwarding k8s requests #3624
Conversation
cd3521e
to
a34965e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Please wait for others before merging though.
674ae8a
to
6bae48e
Compare
@awly I don't suppose |
@russjones interesting idea! If we used SNI, it wouldn't work with:
which could be fine, but it's an awkward caveat to document |
A lot of people's Teleport PoCs/trials don't use domains set up with proper TLS at all, they're using IP addresses and |
Since this fix relies on updated proxy behavior, version compatibility is a concern. The auth server should fallback to the old strategy if it doesn't receive any roles from the proxy. You can add a
If a certificate was constructed in part based on access requests, the request IDs are preserved under the |
6bae48e
to
4242478
Compare
@webvictim would or wouldn't make it harder? I imagine we want to make trying the product easy but ensure that prod setups use good security practices.
@fspmarshall ahh, good catch. I'll add some heuristic in auth server to detect a CSR from older proxy and fall back to manually producing the Subject. Stand by. |
4242478
to
d11728a
Compare
I suppose it wouldn't really make it harder. I agree with your overall assessment - an easyish trial but great production setup is exactly we want to do. Trialling the product without using DNS and valid TLS certs is already a tricky experience so it's unlikely to make a lot of difference. |
d4c9fc7
to
302184c
Compare
@klizhentas @russjones added |
96c5c4a
to
c196219
Compare
When a proxy forwards a k8s request to another proxy in a trusted leaf cluster, it dynamically generates a new client key/cert to impersonate the user. This key/cert is presented to the leaf proxy as if a user was directly making a request to it. Auth server, when processing the CSR, would load user identity from the backend. If this user had temporary role grants via workflow API, they would not be loaded from the backend. This means that if a user accesses k8s through: ``` kubectl -> root proxy -> leaf proxy -> k8s ``` the second hop would drop their temporary role grants. To fix this, preserve full user identity from the original client cert presented to root proxy, as encoded in CSR Subject. The auth server implicitly trusts the CSR Subject that the proxy presents. This also requires fixing the Subject encoding on the proxy side, which was inconsistent with how auth server does it. One downside here is: a compromised proxy can mint k8s client certs for known users with arbitrary roles.
Auth server has to trust the proxy with all k8s CSR fields. Usage is the only field it can enforce, to somewhat limit the blast radius of compromising this cert flow.
c5981bb
to
70442a1
Compare
There seem to be some test stubs in `lib/auth` that can generate TLS key/cert but without supporting k8s users/groups. Rewrite cert generation in `kube_integration_test.go` to use the same logic as `auth.Server.ProcessKubeCSR`.
70442a1
to
f41714f
Compare
When a proxy forwards a k8s request to another proxy in a trusted leaf
cluster, it dynamically generates a new client key/cert to impersonate
the user. This key/cert is presented to the leaf proxy as if a user was
directly making a request to it.
Auth server, when processing the CSR, would load user identity from the
backend. If this user had temporary role grants via workflow API, they
would not be loaded from the backend.
This means that if a user accesses k8s through:
the 2nd hop would drop their temporary role grants.
To fix this, preserve full user identity from the original client cert
presented to root proxy, as encoded in CSR Subject. The auth server
implicitly trusts the CSR Subject that the proxy presents.
This also requires fixing the Subject encoding on the proxy side, which
was inconsistent with how auth server does it.
One possible downside here is: a compromised proxy can mint k8s client certs for
arbitrary users with arbitrary (but existing) roles.
Fixes #3593