Skip to content

atenet-egress: refuse an actor's own CONNECT with 403 - #2721

Merged
Lior Lieberman (LiorLieberman) merged 1 commit into
agent-substrate:mainfrom
bochengchu:e2e-connect-forward-proxy
Oct 17, 2026
Merged

Lior Lieberman (LiorLieberman) merged 1 commit into
agent-substrate:mainfrom
bochengchu:e2e-connect-forward-proxy

Conversation

@bochengchu

@bochengchu Bo-Cheng Chu (bochengchu) commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Fix the status code returned for CONNECT

  • Envoy (egress/request.go): refuse a CONNECT on both inner legs with 403 CONNECT egress is not supported, before identity and policy, like the WebSocket refusal. atunnel's outer CONNECT is handled elsewhere and is unaffected.

Tests for CONNECT

  • Unit: TestRequestLegDeniesConnect (both legs, with and without a policy).
  • E2E: TestActorEgressConnect (cleartext, proxy on 3128) and TestActorEgressSecureConnect (inside TLS on 443). Each sends the CONNECT to an origin that answers any CONNECT 200, so the 403 can't be the origin's, and to the gateway's own Service.
  • Support: egress demo POST /connect; testserver http --accept-connect.

@bochengchu
Bo-Cheng Chu (bochengchu) marked this pull request as ready for review October 15, 2026 21:05

@bowei Bowei Du (bowei) left a comment

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.

Minor comments, LG

Comment thread demos/egress/main.go Resolved
Comment thread demos/egress/main.go Resolved
Comment thread demos/egress/main.go Resolved
Comment thread demos/egress/main.go Resolved
Comment thread demos/egress/main.go Resolved
Comment thread demos/egress/main.go Resolved

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.

PR looks good, I would remove agentgateway changes and ping Eitan Yarmush (@EItanya) on it

The egress gateway tunnels one CONNECT: the one atunnel wraps the actor's
traffic in, on the outer chain. A CONNECT the actor sends itself -- what a
client configured with a forward proxy sends first, in the clear or inside
TLS -- arrives as a request inside that tunnel. docs/egress-traffic.md says
the actor gets 403 Forbidden for it, but nothing refused it.

The request filter evaluated it like any other request, on its authority's
host and the port the actor dialed, and an allowing policy let it through.
Only the route table stopped it: every inner route matches a path prefix and
a CONNECT has none, so Envoy answered 404. The answer depended on how the
routes happen to be written, and the policy filter had already said yes.
Honoring it would police the authority's host on the dialed port while
tunneling to the port the authority names.

The request filter now refuses a CONNECT on both inner legs with 403 and
"CONNECT egress is not supported", before identity and policy, as it does
WebSocket upgrades.

Two networking e2e tests cover it: the actor sends a CONNECT cleartext on a
conventional proxy port, and inside TLS on 443 through the gateway's
interception, each to an origin that answers any CONNECT 200 and to the
gateway's own Service. The 403 and body the actor sees cannot be the
origin's, so the gateway refused the CONNECT before it reached anything
that would have accepted it; a 2xx is reported as an opened tunnel.

To send it, the egress demo gains POST /connect, which dials a proxy,
optionally completes a TLS handshake with it, sends one CONNECT and reports
the answer without waiting on a body a 2xx never carries. testserver's http
subcommand gains --accept-connect, so an origin can stand in for a proxy.
@bochengchu

Copy link
Copy Markdown
Collaborator Author

Lior Lieberman (@LiorLieberman) could you approve again? I had to rebase and fix the package name change (#2181)

Merged via the queue into agent-substrate:main with commit 64bf90d Oct 17, 2026
15 checks passed
@bochengchu
Bo-Cheng Chu (bochengchu) deleted the e2e-connect-forward-proxy branch November 2, 2026 18:40
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