Skip to content

Passthrough dial address resolved by the gateway - #2045

Merged
Bowei Du (bowei) merged 2 commits into
agent-substrate:mainfrom
LiorLieberman:passthrough-dial-by-sni
Oct 1, 2026
Merged

Bowei Du (bowei) merged 2 commits into
agent-substrate:mainfrom
LiorLieberman:passthrough-dial-by-sni

Conversation

@LiorLieberman

@LiorLieberman Lior Lieberman (LiorLieberman) commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

The passthrough chain from #2019 dialed the ORIGINAL_DST filter state, which the CONNECT leg filled with the address the actor connected to. The SNI picked the chain, the actor's own resolution picked the destination, so a passthrough rule for one name let an actor reach any IP by claiming that name in the ClientHello.

We fix it by:

  • The passthrough chain is now sni_dynamic_forward_proxy then tcp_proxy to a new raw forward-proxy cluster, egress_forward_proxy_passthrough, on the shared egress_dns_cache. The gateway resolves the SNI itself and sends the bytes to it.

  • The CONNECT leg answers the dialed port under dev.ate.egress:dialed_port; the outer chain copies it into envoy.upstream.dynamic_port, shared with the inner listener, which both the SNI filter and the cluster read before their configured port.

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@LiorLieberman
Lior Lieberman (LiorLieberman) force-pushed the passthrough-dial-by-sni branch 2 times, most recently from a1c1dc7 to 74d27f3 Compare October 1, 2026 04:21
@LiorLieberman
Lior Lieberman (LiorLieberman) marked this pull request as ready for review October 1, 2026 04:24

// The rule for this name covers 8443 only, so the ClientHello on 443 is
// closed.
const wrongPortOrigin = "https://" + egressOriginPassthroughWrongPortHost + "/"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You need one more test to validate that SNI DFP works.

To test SNI DFP, the probe fetcher needs to dial TLS connection to a bogus IP address (240.0.0.1) but still use valid SNI "example.edu". Successful fetch means that SNI DFP did its job. I think you can do in the custom DialContext in transport,

Transport: &http.Transport{TLSClientConfig: tlsCfg},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call, added something

Comment on lines +280 to +281
// plainPassthroughDestinationFormat is what the plain gateway still copies
// into the ORIGINAL_DST filter state. Nothing sets it anymore.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

comments are bad, will remove in a followup as I have another open pr to remove the "plain gateway "

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 this pull request may close these issues.

3 participants