Skip to content

Strip proxy headers from SigV4 signing clone#4670

Merged
jhrozek merged 1 commit intomainfrom
aws_debug
Apr 9, 2026
Merged

Strip proxy headers from SigV4 signing clone#4670
jhrozek merged 1 commit intomainfrom
aws_debug

Conversation

@jhrozek
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek commented Apr 8, 2026

When requests arrive through a gateway (e.g. ngrok), X-Forwarded-* headers get signed by SigV4. Then httputil.ReverseProxy.SetXForwarded() rewrites those values, causing AWS to reject with 401 due to signature mismatch. Strip X-Forwarded-For/Host/Proto, X-Real-Ip, and Forwarded (RFC 7239) from the signing clone before computing the signature.

This regressed in 0791876 ("Bump Go to 1.26.0", #4040) which refactored the transparent proxy from httputil.NewSingleHostReverseProxy (using Director) to &httputil.ReverseProxy{Rewrite: ...}. The new Rewrite callback calls pr.SetXForwarded(), which injects X-Forwarded-* headers on the outbound request — something the old Director-based approach did not do.

@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Apr 8, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.65%. Comparing base (045b34c) to head (490fb68).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4670      +/-   ##
==========================================
- Coverage   68.70%   68.65%   -0.05%     
==========================================
  Files         507      507              
  Lines       52837    52842       +5     
==========================================
- Hits        36300    36279      -21     
- Misses      13717    13742      +25     
- Partials     2820     2821       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jhrozek added a commit to stacklok/docs-website that referenced this pull request Apr 8, 2026
AWS MCP Server no longer uses aws-mcp:* IAM actions. Authorization
now happens at the AWS service level using two new condition keys:
aws:ViaAWSMCPService and aws:CalledViaAWSMCP.

- Replace aws-mcp:* permission model explanation with new single-layer
  model and document both condition keys
- Update default role policy to use sts:GetCallerIdentity scoped to
  aws:ViaAWSMCPService with a BoolIfExists deny guardrail
- Update S3 role policy to use service-level actions with
  aws:CalledViaAWSMCP condition
- Add security best practices section covering the deny guardrail
  pattern, BoolIfExists truth table, and condition key guidance
- Update troubleshooting section to reflect service-level errors
- Add missing service: aws-mcp field to MCPExternalAuthConfig example
- Add resourceUrl to MCPRemoteProxy oidcConfig example for OAuth
  protected resource discovery

Depends on stacklok/toolhive#4670 (SigV4 proxy header fix).

Fixes #587

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When requests arrive through a gateway (e.g. ngrok), `X-Forwarded-*`
headers get signed by SigV4. Then `httputil.ReverseProxy.SetXForwarded()`
rewrites those values, causing AWS to reject with 401 due to signature
mismatch. Strip `X-Forwarded-For`/`Host`/`Proto`, `X-Real-Ip`, and
`Forwarded` (RFC 7239) from the signing clone before computing the
signature.

This regressed in 0791876 ("Bump Go to 1.26.0", #4040) which
refactored the transparent proxy from `httputil.NewSingleHostReverseProxy`
(using `Director`) to `&httputil.ReverseProxy{Rewrite: ...}`. The new
`Rewrite` callback calls `pr.SetXForwarded()`, which injects
`X-Forwarded-*` headers on the outbound request — something the old
`Director`-based approach did not do.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Apr 8, 2026
@jhrozek jhrozek merged commit 37e5bde into main Apr 9, 2026
93 of 95 checks passed
@jhrozek jhrozek deleted the aws_debug branch April 9, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants