Skip to content

Egress proxy: the ClientHello must name the CONNECT host (#1595) - #1618

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1595-egress-proxy-sni
Nov 14, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1595-egress-proxy-sni

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1595

What

The egress proxy checked only the CONNECT authority against the allowlist and then tunnelled opaque bytes. awscli.amazonaws.com and efa-installer.amazonaws.com are CloudFront-fronted, and an edge serves whichever distribution the ClientHello's server_name names. So CONNECT awscli.amazonaws.com:443 followed by a ClientHello for <anything>.cloudfront.net reached an arbitrary distribution from a subnet with no internet route.

tunnel() now reads the client's first flight before forwarding any of it (new sni.go):

  • Parsing. crypto/tls parses the ClientHello as a server whose GetConfigForClient captures ServerName and Extensions, then aborts. The proxy answers nothing, decrypts nothing, and still never terminates TLS. Every byte read, which is at most 64 KiB, is forwarded unchanged ahead of the rest of the stream.
  • Refused:
    • an SNI that is not the CONNECT host (compared after the allowlist's normalizeHost)
    • no SNI
    • encrypted_client_hello (0xfe0d), whose outer name is only a cover
    • a tunnel that does not start with TLS
  • Timeout. The read uses HeaderTimeout, so a tunnel that sends no hello holds its slot no longer than a client that sends no request.
  • Stats. Accepted is now counted only after the check passes, and the refusal is logged with its reason.

Plain-HTTP forwards were already consistent: forward() overwrites Host with the vetted target.

Tests

  • TestConnectRefusesAClientHelloForAnotherHost covers a fronted name, no SNI, ECH, not-TLS, and another allowlisted host. In each case zero bytes come back and the request counts as refused. I watched all five fail with the check disabled.
  • TestConnectWithNoClientHelloTimesOut, TestReadClientHello, TestHelloRefusal.
  • The existing tunnel tests now send a real Go ClientHello and check that it arrives upstream byte-for-byte.

There is no IAM or user-data change. This is a spored change, because spored egress-proxy runs it. There is no sporedPolicySchema change.

Live checks needed before merge (owner)

Run in 435415984226. Build spored from this branch and put it on a proxy, either with spawn egress-proxy upgrade once released, or a dev spored on a test proxy.

  1. Bring up a proxy: spawn launch --no-public-ip --bootstrap-egress proxy --ttl 30m on stock Ubuntu (it installs the AWS CLI through the proxy). The member's bootstrap should finish, which shows the AWS CLI zip (awscli.amazonaws.com) and, with --efa, the EFA tarball still come through.
  2. From the member, run curl -sS -x http://<proxy>:<port> https://awscli.amazonaws.com/ -o /dev/null -w '%{http_code}\n'. Expect an HTTP status.
  3. From the member, run openssl s_client -proxy <proxy>:<port> -connect awscli.amazonaws.com:443 -servername d111111abcdef8.cloudfront.net </dev/null. Expect the handshake to fail. The proxy log should show verdict=refused with "names d111111abcdef8.cloudfront.net, not the CONNECT host". This is the issue's deployed-state check.
  4. Terminate the member and the proxy, and leak-check.

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.00000% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/egressproxy/sni.go 75.67% 9 Missing ⚠️
pkg/egressproxy/proxy.go 84.61% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live check (dev, 2026-11-13). The proxy was brought up by this branch's CLI, then this branch's spored was swapped onto it. The probe sat in the proxy's client group.

request through the proxy result
curl https://awscli.amazonaws.com/ (allowlisted) 301
openssl s_client CONNECT awscli.amazonaws.com with SNI d111111abcdef8.cloudfront.net refused, handshake EOF. Proxy log: verdict=refused reason="the ClientHello names d111111abcdef8.cloudfront.net, not the CONNECT host awscli.amazonaws.com"
the same with matching SNI TLS 1.3, verify OK
curl https://example.com/ refused (not on the allowlist)

Not exercised: a full stock-Ubuntu --no-public-ip bootstrap through the proxy. The dev VPC has no S3 or SSM endpoints, so the member's spored couldn't start. That's the environment, not this change.

Teardown: egress-proxy delete removed the proxy and both groups. Leak check clean.

scttfrdmn and others added 2 commits November 13, 2026 15:51
The allowlisted HTTPS hosts are CloudFront-fronted, and an edge serves
whatever distribution the ClientHello's server_name asks for, so a
client could CONNECT to awscli.amazonaws.com and reach any distribution.
The tunnel now parses the client's ClientHello (crypto/tls, stopped at
GetConfigForClient, nothing answered or decrypted) and refuses it unless
its SNI is the CONNECT host; no SNI, encrypted_client_hello, or no TLS
at all are refused. The hello is forwarded unchanged; a tunnel that
sends none is closed at the header timeout.
@scttfrdmn
scttfrdmn marked this pull request as ready for review November 13, 2026 23:53
@scttfrdmn
scttfrdmn force-pushed the fix/1595-egress-proxy-sni branch from c58ff04 to 0c0639f Compare November 13, 2026 23:53
@scttfrdmn
scttfrdmn merged commit d0da56d into main Nov 14, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1595-egress-proxy-sni branch November 14, 2026 00:17
@scttfrdmn scttfrdmn mentioned this pull request Nov 14, 2026
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.

security: Egress proxy allowlists CloudFront-fronted hosts but tunnels CONNECT without checking the TLS SNI

1 participant