Skip to content

fix(proxy): strip client IP headers (mppx#1369) - #760

Merged
brendanjryan merged 1 commit into
mainfrom
agricola/mppx-1369
Nov 29, 2026
Merged

brendanjryan merged 1 commit into
mainfrom
agricola/mppx-1369

Conversation

@brendanjryan

Copy link
Copy Markdown
Collaborator

Source: wevm/mppx#1369 (merge commit e3a3dad)

Motivation

mppx's proxy now strips client-supplied forwarding headers (Forwarded, X-Real-IP, True-Client-IP, CF-Connecting-IP and Via) from proxied requests, as it already strips X-Forwarded-*. A client could otherwise claim any address or path to the upstream through them. The Rust proxy should behave the same way.

Summary

  • Added FORWARDING_HEADERS to src/proxy/headers.rs and stripped them in is_request_header_stripped, compared case-insensitively like the other stripped headers.
  • Added tests mirroring mppx's: the five headers are removed by scrub_request_headers while other headers stay, and each is stripped regardless of case.
  • Added a patch changelog fragment.

Key design considerations

  • Only request headers change; response stripping is untouched, matching mppx, where the new set applies only to Headers.scrub.
  • The upstream PR's "share the upstream call" refactor (a shared forward helper and rewrite/send split in Proxy.ts) was not ported: it restructures TypeScript code and changes no behavior that this crate's proxy needs to mirror.

Propagated from wevm/mppx#1369 (e3a3dad4c983b3abbbca0cea1997c6c0ba2709fd) by Agricola.

@tempoxyz-bot

tempoxyz-bot commented Nov 26, 2026 •

Copy link
Copy Markdown

👁️ Cyclops Security Review

✅ Reviewed a2fd015 (latest) · Coverage: partial · no open findings · report
⚠️ Not checked: Parity with mppx#1369 (merge commit e3a3dad) was not verified. The mppx source is outside the assigned repository and not among the pinned inputs, so whether its strip set is exactly these five names, or includes others such as X-Client-IP
⚠️ Not checked: That no other code in the repository reads the five stripped headers rests on a case-insensitive text search (matches only in src/proxy/headers.rs, a Stripe service test using X-Forwarded-For and the changelog fragment), not on exact-read s
⚠️ Not checked: The SDK strips Via regardless of who added it. The assigned source does not establish whether a deployed gateway relies on a trusted Via chain for forwarding, diagnostics, or loop detection, or whether it adds trusted hop metadata after scr
⚠️ 8 more unchecked questions are listed in the report
ℹ️ Not verifiable from the source alone (needs running code or deployed state): The proxy module leaves HTTP forwarding to the consumer, and no forwarder source was read in this repository. Whether deployed proxies apply the scrub, and whether any sits behind a trusted hop whose (1 more in the report)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T15:09:23.768510Z a2fd015 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Changelog found on PR.

Edit changelog

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed this PR and found no bugs. The repo-wide CODEOWNERS entry covers these files and the change hardens the proxy's request-header scrubbing, so a human look is still worthwhile.

What was reviewed:

  • FORWARDING_HEADERS in is_request_header_stripped: it uses the same exact-length, case-insensitive eq_ascii_lower match as the other stripped headers, so Viaduct and similar names pass through.
  • Response scrubbing is unchanged, and the new tests check that only x-public survives through the existing names helper. The changelog fragment matches the AGENTS.md format and includes the "as mppx does" note.
  • Not done: no build, clippy, fmt or feature-matrix run. The change was checked only by reading it.
Extended reasoning...

The change touches src/proxy/headers.rs, adding a five-entry FORWARDING_HEADERS list that is checked in is_request_header_stripped, plus two unit tests and a patch changelog fragment. It is security-relevant: it stops clients from spoofing their IP or forwarding path to the upstream through proxied requests. The logic is small and follows the existing pattern exactly. I deferred instead of approving because .github/CODEOWNERS assigns every path (*) to named owners.

@brendanjryan
brendanjryan merged commit fd6aead into main Nov 29, 2026
19 checks passed
@brendanjryan
brendanjryan deleted the agricola/mppx-1369 branch November 29, 2026 16:22
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.

2 participants