Skip to content

fix(node): stamp verified X-Peer-Id on mesh service ingress - #338

Merged
aojea merged 2 commits into
google:mainfrom
aojea:fix-node-ingress-verified-peer-id
Aug 31, 2026
Merged

fix(node): stamp verified X-Peer-Id on mesh service ingress#338
aojea merged 2 commits into
google:mainfrom
aojea:fix-node-ingress-verified-peer-id

Conversation

@aojea

@aojea aojea commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Implements #323 — and it turned out to be a fix, not just a feature: the ingress handler forwarded a client-supplied X-Peer-Id header untouched to backend services, so any service trusting that header for caller attribution (as inference_service.go does for loopback requests) was spoofable by any authorized mesh caller.

Changes:

  • After AuthZ succeeds, the ingress handler stamps X-Peer-Id with the transport-verified caller peer id, using Set so an inbound value is always overwritten — same semantics the inference facade already uses.
  • New api.HeaderPeerID constant; adopted at the two existing string-literal call sites (no behavior change there).

Tests (both verified red against the old code):

  • Unit (TestDatapathHeadersAndRoutingTable): new case asserting an inbound spoofed X-Peer-Id is replaced with the verified caller id.
  • Integration (TestIntegrationHTTPDatapath): the cross-binary datapath test's backend now captures received headers and asserts the verified peer id arrives, a spoofed inbound value is overwritten, and X-Sam-Biscuit never leaks to the backend. Red run against the old code fails with got "spoofed-peer", want verified caller "12D3Koo…". Runs in ~4.3s, within the integration budget; no e2e addition per the push-down rule.

Fixes #323

After AuthZ succeeds, the ingress handler now sets X-Peer-Id to the
transport-verified caller peer id on requests forwarded to backend
services, overwriting any inbound value. Previously a client-supplied
X-Peer-Id was forwarded untouched across the mesh, so any backend
trusting that header (as the inference service does on loopback) was
spoofable.

Adds api.HeaderPeerID and adopts it at the existing literal call sites.

Fixes google#323

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request standardizes the propagation of the caller's verified libp2p peer ID to backend services using a new HeaderPeerID constant (X-Peer-Id), ensuring that any inbound spoofed values are overwritten at the ingress server. The changes are reflected across the inference service, OpenAI facade, and test suites. The reviewer recommends also explicitly deleting the X-Sam-No-Trailing-Slash header at the ingress handler to prevent potential spoofing of path semantics.

Comment thread internal/node/node.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@aojea
aojea merged commit 738e91d into google:main Aug 31, 2026
18 checks passed
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.

Stamp X-Peer-Id on the service reverse-proxy (parity with the inference facade)

1 participant