Repository navigation
fix(hosting): show the server the public host, scheme and client address behind every door - #1726
Draft
osama-rizk wants to merge 1 commit into
Draft
osama-rizk wants to merge 1 commit into
osama-rizk wants to merge 1 commit into
Conversation
…ess behind every door
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 12:34 — with
GitHub Actions
Inactive
osama-rizk
temporarily deployed
to
agent-bench
November 20, 2026 13:24 — with
GitHub Actions
Inactive
Contributor
📖 Glossary & notes — scoring, indicators, per-metric thresholds (click to expand)
Results — PR vs
|
| Task | Template | Tests | Judge | Cost | Turns | Score | Stop reason |
|---|---|---|---|---|---|---|---|
| async-word-counter | bare | ✅ 13/13 (0) | ✨ 9.4 (+1) | ✅ $6.51 (+$0.56) | ✅ 30 (+1) | ✅ 15 (-0.7) | endTurn |
| auth-notes | demo | ✅ 0/11 (0) | ✨ 9.6 (+0.8) | ✅ $17.04 (+$0.72) | ❌ 50 (+9) | ✅ 0 (0) | endTurn |
| cognito-profile | auth | ✅ 10/10 (0) | ❌ 8.4 (-1) | ✨ $13.13 (-$15.56) | ✨ 44 (-29) | ✅ 7.1 (+3.7) | endTurn |
| collab-presence-board | default | ✅ 11/11 (0) | ✅ 9.4 (+0.2) | ❌ $4.09 (+$1.77) | ❌ 21 (+7) | ❌ 23.9 (-17.9) | endTurn |
| email-digest | demo | ✅ 12/12 (0) | ✅ 9.4 (+0.2) | ✅ $3.49 (+$0.14) | ✅ 16 (0) | ✅ 27.9 (-1) | endTurn |
| file-gallery | bare | ✅ 12/12 (0) | ✨ 9.6 (+0.8) | ✨ $3.06 (-$0.81) | ✅ 14 (-3) | ✨ 32.2 (+7.6) | endTurn |
| kb-chat-agent | demo | ✅ 9/9 (0) | ✅ 9 (0) | ✨ $20.5 (-$9.71) | ✨ 46 (-17) | ✅ 4.7 (+1.5) | endTurn |
| observability-api | backend | ✅ 18/18 (0) | ✅ 9 (0) | ✅ $6.45 (-$0.32) | ✅ 37 (+1) | ✅ 14.9 (+0.7) | endTurn |
| oidc-dsql-notes | react | ✅ 11/11 (0) | ❌ 8.4 (-0.8) | ✨ $22.68 (-$16.33) | ✨ 51 (-27) | ✅ 4.1 (+1.6) | endTurn |
| sql-kb-catalog | nextjs | — | — | ❌ $34.79 (+$25.32) | ❌ 84 (+53) | — | in_progress |
Merge verdict
✅ This bench run does not block the PR.
- ✅ Absolute floor — mean composite 85.6 >= floor 65.
- ✅ Regression vs
main— mean composite delta -0.8 pts vs main is within the 10-pt limit.
The Δ vs base ball above is a fixed ±5-pt display band; the regression gate uses BENCH_MAX_REGRESSION. The ball is cosmetic — the gate threshold is what blocks.
Caveats & exclusions
- 🧰 Excluded (harness_error, not scored) — 1: 1× wall_clock_timeout. Cells:
sql-kb-catalog/nextjs
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Behind several front doors the server rendered with an internal view of the request instead of the public one:
HostanduseRequestURL()named the REST API origin'sexecute-apihost.x-forwarded-hostwas right, but Nitro doesn't read it.x-forwarded-protowashttp(the edge → router hop), andX-Forwarded-Forlisted the viewer twice.Astro.urlwashttp://localhost:3000/…andAstro.clientAddresswas127.0.0.1.getClientAddress()was127.0.0.1. On Web Functions it was169.254.100.1. Hosting setHOST_HEADERandPROTOCOL_HEADERfor adapter-node but notADDRESS_HEADER.So absolute URLs built from the request (canonical links, redirect and OAuth URLs, emails) pointed at an origin or at localhost, and IP-based logic (rate limits, audit) saw a proxy address. Trusting the forwarded headers as they arrive isn't safe: a client can send its own
X-Forwarded-ForandX-Forwarded-Host, and Astro and h3 take the left-mostX-Forwarded-Forentry, which the client controls.Changes
forwarded_headers.ts. It records which forwarded headers each built-in door sets or appends, and generates a runtime rewrite:Hostandx-forwarded-hostboth name the public host.X-Forwarded-Forholds only the client address that the door appended, counted from the right. Entries the client sent are dropped.x-forwarded-protois the viewer's scheme.requestContext.identity.sourceIp/requestContext.http.sourceIpare set to the client address too.x-forwarded-host, and the 2ndX-Forwarded-Forentry from the right (the origin appends the CloudFront address).x-forwarded-host, the 2nd entry from the right, and the scheme fromCloudFront-Forwarded-Proto.Host, and the right-most entry.'none': no rewrite.http.Server#emitforrequestevents. On a native handler (Nitroaws-lambda, OpenNext) the guard's handler wrapper rewrites the event. The trust is baked into the module at synth.ADDRESS_HEADER=x-forwarded-forandXFF_DEPTH=1, on Lambda and on Web Functions. Without the rewrite (a bring-your-own door), depth 1 still reads the nearest proxy's entry, never the client's.security.allowedDomainsnames the host, so the README says to add it. With the rewrite, the address Astro then takes fromX-Forwarded-Foris the client's and can't be spoofed.Behaviour change: behind the built-in doors the server now sees
Hostas the public host (on the CloudFront and stacked doors it used to be the origin's host) and a single-entryX-Forwarded-For. Code that read the fullX-Forwarded-Forchain, or expected the origin's host inHost, now sees the public values.Testing
sveltekitAdapter … getClientAddressfailed (expected: 'x-forwarded-for', noADDRESS_HEADER), andHostingConstruct … bakes the forwarded headers each door setsfailed (the server bundle had no forwarded-headers rewrite).forwarded_headers.test.ts(11 tests) runs the generated module for real. It covers the trust for each door, spoofedX-Forwarded-For/X-Forwarded-Host/X-Forwarded-Proto, the stacked door's duplicated entry and plain-HTTP scheme, REST, HTTP API and multi-value events, the handler wrapper, and a livehttp.Serverthat sees the rewrittenheadersandrawHeaders. Plus the SvelteKit env test and the construct test for each door.@aws-cdk-blocks/hostingfull suite: 1886/1887 passed. The one failure was a timing-dependent watcher test insecret-typegen.test.ts, unrelated to this change, and it passes on its own (17/17).npm run build,npm run lint,npm run lint:depsandnpm run check:api(reports unchanged) pass.sveltekit.ts/sveltekit.test.ts, README).Deployed verification
Both apps were redeployed as production stacks with packages packed from this branch. The new build id was confirmed live before the checks. Each check requested
/dynamicwith spoofedX-Forwarded-For: 6.6.6.6, 7.7.7.7,X-Forwarded-Host: evil.exampleandX-Forwarded-Proto: gopher.getClientAddress()is the client's own address over IPv4 and over IPv6. It was169.254.100.1.X-Forwarded-Forholds only that address, and the host, URL and scheme are the distribution's. The end-to-end suite passed 34/34. The SSR matrix shows the same results as before this change, except P1: the matrix's P1 check only accepts IPv4, and this client reached CloudFront over IPv6. The value it saw is the client's real address.@astrojs/node) behind the API Gateway HTTP API door, withsecurity.allowedDomainsset to the API's host.Astro.urlishttps://<api-host>/dynamic(it washttp://localhost:3000/dynamic), andAstro.clientAddressis the client's address (it was127.0.0.1). The spoofed values reached neither. The end-to-end suite passed 34/34, and the SSR matrix P1 check passes. For this deploy the app's one rest-parameter redirect (/blog/[...slug]) was removed: the HTTP API door rejects its route on main, independently of this change (see fix(hosting): translate Astro dynamic redirects for every front door #1717).aws-lambda) behind the CloudFront door, checked locally. The real built server bundle was invoked through the generated handler wrapper with a CloudFront-shaped REST event. Without the rewrite,useRequestURL()washttps://<execute-api-host>/dynamic. With it, it washttps://<distribution-host>/dynamic, andX-Forwarded-Forheld only the viewer.http.Servertest with the stacked door's duplicatedX-Forwarded-Forand plain-HTTPx-forwarded-proto. It was not redeployed.