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

Add secure client IP propagation throughout teleport #21080

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

AntonAM
Copy link
Contributor

@AntonAM AntonAM commented Feb 1, 2023

This PR adds client IP information propagation through teleport infrastructure. It builds upon first stage where signed PROXYv2 headers were added for propagating client IP to the auth server through ALPN (#19008).

Main approach is that we transfer client IP information through reverse tunnel system when we can and then we send signed PROXY header if we have to connect to a server directly. This allows us to only need to send signed headers within single cluster, because we can always transfer IP information in the tunnel between clusters. To make it possible to send IP information through tunnel we add a few new fields to DialReq struct:

// TeleportVersion shows what teleport version is the node that we're trying to dial
TeleportVersion string `json:"teleport_version,omitempty"`

// ClientSrcAddr is the original observed client address, it is used to propagate
// correct client IP through indirect connections inside teleport
ClientSrcAddr string `json:"client_src_addr,omitempty"`

// ClientDstAddr is the original client's destination address, it is used to propagate
// correct client point of contact through indirect connections inside teleport
ClientDstAddr string `json:"client_dst_addr,omitempty"`

We need to know teleport version of the target server, since old versions don't support receiving PROXY headers and would fail.

@AntonAM AntonAM force-pushed the anton/ip-propagation-reverse-tunnel branch 8 times, most recently from ddbe4b9 to cdb93da Compare February 3, 2023 22:19
@AntonAM AntonAM changed the title Add secure client source IP propagation throughout teleport Add secure client IP propagation throughout teleport Feb 3, 2023
@AntonAM AntonAM marked this pull request as ready for review February 3, 2023 22:59
@github-actions github-actions bot requested a review from hatched February 3, 2023 22:59
@AntonAM AntonAM force-pushed the anton/ip-propagation-reverse-tunnel branch 2 times, most recently from 1482f80 to 6f8471d Compare February 6, 2023 14:27
Copy link
Contributor

@strideynet strideynet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work - I've raised a few nits I've picked up on an initial run through, and I'll do a deeper assessment of the actual networking tomorrow.

lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/multiplexer/proxyline.go Outdated Show resolved Hide resolved
lib/reversetunnel/api.go Outdated Show resolved Hide resolved
lib/reversetunnel/srv.go Outdated Show resolved Hide resolved
lib/reversetunnel/transport.go Outdated Show resolved Hide resolved
lib/srv/regular/proxy.go Show resolved Hide resolved
lib/utils/formatter.go Outdated Show resolved Hide resolved
@AntonAM AntonAM force-pushed the anton/ip-propagation-reverse-tunnel branch 5 times, most recently from da25f80 to ed0f9d2 Compare February 7, 2023 07:17
Copy link
Contributor

@espadolini espadolini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's come to my attention lately that we actually officially support mixing and matching minor/patch versions in the same cluster (as long as everything is at the same major version as the auth), so please doublecheck that an auth server that's not aware of the client IP propagation through the PROXY line will still allow connections in from clients or proxies that are aware.

api/utils/sshutils/conn.go Outdated Show resolved Hide resolved
api/utils/sshutils/conn.go Outdated Show resolved Hide resolved
api/client/contextdialer.go Outdated Show resolved Hide resolved
lib/proxy/router.go Outdated Show resolved Hide resolved
lib/reversetunnel/localsite.go Outdated Show resolved Hide resolved
lib/reversetunnel/transport.go Outdated Show resolved Hide resolved
lib/reversetunnel/transport.go Outdated Show resolved Hide resolved
lib/reversetunnel/transport.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rosstimothy rosstimothy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass. Only made it to lib/multiplexer.

api/utils/sshutils/conn.go Outdated Show resolved Hide resolved
api/utils/sshutils/conn.go Outdated Show resolved Hide resolved
lib/client/api.go Outdated Show resolved Hide resolved
integration/helpers/discard.go Outdated Show resolved Hide resolved
integration/integration_test.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Show resolved Hide resolved
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Show resolved Hide resolved
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/proxy/router.go Outdated Show resolved Hide resolved
lib/proxy/router.go Outdated Show resolved Hide resolved
lib/proxy/router.go Outdated Show resolved Hide resolved
lib/reversetunnel/api.go Outdated Show resolved Hide resolved
lib/reversetunnel/transport.go Outdated Show resolved Hide resolved
lib/srv/regular/proxy.go Outdated Show resolved Hide resolved
lib/reversetunnel/localsite.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Show resolved Hide resolved
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Show resolved Hide resolved
@AntonAM AntonAM force-pushed the anton/ip-propagation-reverse-tunnel branch from 626d184 to acc9583 Compare February 9, 2023 22:36
lib/multiplexer/multiplexer.go Outdated Show resolved Hide resolved
lib/client/api.go Show resolved Hide resolved
lib/reversetunnel/transport.go Outdated Show resolved Hide resolved
lib/utils/net.go Outdated Show resolved Hide resolved
@AntonAM AntonAM force-pushed the anton/ip-propagation-reverse-tunnel branch 5 times, most recently from c2b72e2 to 89c7e95 Compare February 28, 2023 19:29
@AntonAM AntonAM force-pushed the anton/ip-propagation-reverse-tunnel branch from 89c7e95 to 75497fa Compare February 28, 2023 20:12
@AntonAM AntonAM added this pull request to the merge queue Feb 28, 2023
Merged via the queue into master with commit 3633c61 Feb 28, 2023
AntonAM added a commit that referenced this pull request Apr 3, 2023
* Add secure client IP propagation throughout teleport (#21080)

* Allow node to handle old and new way of client IP propagation on same listener

With addition of signed PROXY headers, node was listening on multiplexer, but because
 of that it couldn't processing incoming connection from older proxies
 when ProxyHelloSignature was used, because
 both ends were waiting for the other side to send data first.
 Here we integrate ability to handle PROXY headers into connection itself,
 so we can start ssh server without waiting for multiplexer to detect connection

* Enabled IP pinning enforcement for Kube and DB (#22310)

* Don't allow different tcp version IP addresses in signed PROXY headers

* Send signed proxy header to the kube service

Because it was checking version, which was empty, signed headers were not sent,
 when we contacted leaf cluster's kube service

* Temporary disable ip propagation tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants