verify cluster name of TLS peer certificates#52128
Merged
Conversation
This was referenced Feb 13, 2025
c255aef to
f6be23e
Compare
r0mant
approved these changes
Feb 13, 2025
f6be23e to
702d1d0
Compare
zmb3
approved these changes
Feb 13, 2025
702d1d0 to
68e34ba
Compare
carloscastrojumo
pushed a commit
to carloscastrojumo/teleport
that referenced
this pull request
Feb 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OSS backport of https://github.com/gravitational/teleport-private/pull/1787.
This fixes https://github.com/gravitational/teleport-private/issues/1749 by verifying that the cluster name of a TLS peer cert matches the cluster name of the CA that issued it. Checks have been also added to ensure all locations in a CA where the cluster name is specified all match. These checks together ensure that CAs provided by trusted leaf clusters cannot sign a cert that will be accepted by the root as if it belongs to the root cluster.
You can't really get useful info of the certs in a *x509.CertPool, so I modified logic that builds client CA cert pools to return the information I need to do the additional checks alongside the cert pool itself. I lookup the CA cert that issued the client TLS cert by the cert's serial number, this means if CAs contain trusted certs that share serial numbers these checks could be bypassed. This shouldn't happen normally, I would think this would likely only happen if a malicious leaf cluster somehow knew the serial number of a root Host or User CA but didn't have the CA itself (or else better attacks could be done).
ClientCertPool was removed from middleware.go because it is an unused duplicate func likely left there by accident.
Tested by (on root and leaf clusters):
Connecting via tsh and the Web UI
Connecting to an App
Connecting to an SSH
Connecting to a database
changelog: verify that cluster name of TLS peer certs matches the cluster name of the CA that issued it to prevent Auth bypasses