Fix App public_addr allows setting a conflicting hostname with the proxy when using capital letters#61123
Fix App public_addr allows setting a conflicting hostname with the proxy when using capital letters#61123
Conversation
…roxy when using capital letters Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Signed-off-by: Chris Thach <chris.thach@goteleport.com>
7efc819 to
eb1f8e3
Compare
| return nil | ||
| } | ||
|
|
||
| // It is assumed that the app's public address has already been validated to be a valid address format during app |
There was a problem hiding this comment.
// It is assumed that the app's public address has already been validated to be a valid address format during app resource validation
Can you clarify where and when this happens? Would it hurt to be redundant and validate here again?
There was a problem hiding this comment.
Can you clarify where and when this happens?
It happens in the NewAppV3 constructor. It calls the CheckAndSetDefaults.
Would it hurt to be redundant and validate here again?
Hmm yes, that is a good idea to be on the defensive side. We just have to be careful that the implementation now and going forward doesn't mutate existing struct fields that are already set.
I can also see that this is an already an established patten i.e., calling CheckAndSetDefaults outside of the method receiver's constructor. Thanks for the suggestion!
There was a problem hiding this comment.
Let's not call CheckAndSetDefaults explicitly here to avoid side effects. That is the biggest pain we have today with that pattern. Well that and the fact that it's called during custom marshal/unmarshal code.
|
|
||
| // Convert the application's public address hostname to its ASCII representation for comparison. Strip any trailing | ||
| // dot to ensure consistent comparison. | ||
| asciiAppHostname, err := idna.ToASCII(strings.TrimSuffix(appAddr.Host(), ".")) |
There was a problem hiding this comment.
Could I just set my host to teleport.example.com..? Do we need to strip all . characters at the end?
…-app Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Signed-off-by: Chris Thach <chris.thach@goteleport.com>
…test. Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Signed-off-by: Chris Thach <chris.thach@goteleport.com>
…oxy when using capital letters (#61123) * fix: App public_addr allows setting a conflicting hostname with the proxy when using capital letters Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Only normalize once. Remove app public_addr validate. Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Fix grpc tests Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Polish and optimize ValidateApp Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Apply suggestions from code review Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com> * Strip all trailing dots Signed-off-by: Chris Thach <chris.thach@goteleport.com> * NewAppV3 should never panic during fuzzing. Improve comments in fuzz test. Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Clarify app spec validated in CheckAndSetDefaults Signed-off-by: Chris Thach <chris.thach@goteleport.com> --------- Signed-off-by: Chris Thach <chris.thach@goteleport.com> Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
…oxy when using capital letters (#61123) * fix: App public_addr allows setting a conflicting hostname with the proxy when using capital letters Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Only normalize once. Remove app public_addr validate. Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Fix grpc tests Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Polish and optimize ValidateApp Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Apply suggestions from code review Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com> * Strip all trailing dots Signed-off-by: Chris Thach <chris.thach@goteleport.com> * NewAppV3 should never panic during fuzzing. Improve comments in fuzz test. Signed-off-by: Chris Thach <chris.thach@goteleport.com> * Clarify app spec validated in CheckAndSetDefaults Signed-off-by: Chris Thach <chris.thach@goteleport.com> --------- Signed-off-by: Chris Thach <chris.thach@goteleport.com> Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
…oxy when using capital letters (#61123) (#61292) * fix: App public_addr allows setting a conflicting hostname with the proxy when using capital letters * Only normalize once. Remove app public_addr validate. * Fix grpc tests * Polish and optimize ValidateApp * Apply suggestions from code review * Strip all trailing dots * NewAppV3 should never panic during fuzzing. Improve comments in fuzz test. * Clarify app spec validated in CheckAndSetDefaults --------- Signed-off-by: Chris Thach <chris.thach@goteleport.com> Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
…oxy when using capital letters (#61123) (#61290) * fix: App public_addr allows setting a conflicting hostname with the proxy when using capital letters * Only normalize once. Remove app public_addr validate. * Fix grpc tests * Polish and optimize ValidateApp * Apply suggestions from code review * Strip all trailing dots * NewAppV3 should never panic during fuzzing. Improve comments in fuzz test. * Clarify app spec validated in CheckAndSetDefaults --------- Signed-off-by: Chris Thach <chris.thach@goteleport.com> Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
What
Adds extra validation on top of #58475 to ensure that if a user attempts to configure an App with a
public_addrthat conflicts with one of Proxy's public addresses, Teleport will fatally error. Includes extra unit test cases and fuzz tests.Changelog: Improve conflict detection of application public address and Teleport cluster addresses.
Required Approvers 👀
🔴 Do not merge unless all of these approvers have approved 🔴
Why
The key difference from PR #58475 is that we'll now trim any trailing dots of the hostnames, then normalize by converting to ASCII and finally doing a case insensitive comparison to detect conflicts. This would catch conflicting Internationalized Domain Names (IDN), mixed casing, and a trailing dot in the name that we previously did not catch.
Scope
This PR focuses only on preventing applications from using a
public_addrvalue that matches the public address of any proxy.It does not aim to improve field validation for the
public_addrfield beyond preventing proxy address conflicts e.g., ensuring only a hostname is set, ensuring a scheme or port is not provided, etc.Those will be handled in issues #58751 and #4838 in future PRs.
Manual Tests
My Teleport's public cluster address is
teleport.dev:443.The following tests were performed:
public_addrapp.teleport.devshould succeedpublic_addrteleport.devshould errorpublic_addrTELEPORT.devshould errorChange the public cluster address to
münchen.dev:443to test IDNA/unicode domains:public_addrapp.münchen.devshould succeedpublic_addrMüncheN.devshould errorpublic_addrMüncheN.dev.(trailing dot) should error