Skip to content

reverse tunnel: read handshake headers from the live extension#46382

Open
kanurag94 wants to merge 7 commits into
envoyproxy:mainfrom
kanurag94:fix-reverse-tunnel-handshake-live-headers
Open

reverse tunnel: read handshake headers from the live extension#46382
kanurag94 wants to merge 7 commits into
envoyproxy:mainfrom
kanurag94:fix-reverse-tunnel-handshake-live-headers

Conversation

@kanurag94

@kanurag94 kanurag94 commented Jul 25, 2026

Copy link
Copy Markdown
Member

Commit Message: reverse tunnel: read handshake headers from the live extension
Additional Description:

The reverse-connection listen socket grabs a snapshot of the handshake formatters when it's created. Problem is, that can happen before onServerInitialized() builds them — so the snapshot is null, and since the same socket config gets reused for every re-dial, the handshake keeps going out with the raw additional_headers template instead of the resolved value.

So a header like authorization: B**rer %FILE_CONTENT(/etc/tunnel-jwt/token.jwt)% gets sent literally, on every dial.

Fix: when we assemble the handshake, read the formatters straight from the live extension instead of trusting the snapshot. Fall back to the snapshot only if the extension has none built.

This is a follow-up to #46168 — that one fixed the same symptom in the extension constructor, but didn't cover the socket() => io_handle => wrapper snapshot path.

Risk Level: Low
Testing: Added a new test to exercise the actual path. It asserts the snapshot is null at socket creation, then that the dial after init sends the resolved value
Docs Changes:
Release Notes:
Platform Specific Features:

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #46382 was opened by kanurag94.

see: more, trace.

The reverse-connection listen socket snapshots the handshake formatters
when it's created, and that can happen before onServerInitialized() has
built them. The snapshot ends up null and gets reused for every re-dial,
so handshake additional_headers that use a formatter (%FILE_CONTENT%,
SDS-backed secrets, etc.) went out as the raw template string instead of
the resolved value.

Read the formatters straight from the extension when we assemble the
handshake instead of trusting that snapshot, falling back to the snapshot
only when the extension hasn't built any.

This is a follow-up to envoyproxy#46168, which fixed the same symptom in the
extension constructor but missed the socket() -> io_handle -> wrapper
snapshot path. Adds a regression test that goes through the real socket()
path so it can't regress.

Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
@kanurag94
kanurag94 force-pushed the fix-reverse-tunnel-handshake-live-headers branch from c82f559 to ec4d2ba Compare July 25, 2026 09:42
@kanurag94
kanurag94 marked this pull request as ready for review July 25, 2026 09:43
Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
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.

1 participant