Files
mattgodbolt-moltyandClaude Fable 5.1 49b7e073ba Make the trusted proxy hop count configurable instead of trusting every hop
Express was configured with "trust proxy" set to true, so req.ip was the
leftmost X-Forwarded-For entry: whatever the client chose to send. Scanners
sending "X-Forwarded-For: 127.0.0.1" were logged as 127.0.0.0, and
storeItem in the S3 storage read the raw header directly, so short link
audit records had the same problem.

Add a trustProxy property that is passed straight through to Express. The
default is "loopback" (a proxy on the same host is trusted, which covers
make dev and the common local-nginx setup); the amazon and amazonwin
environments set 2 for their CloudFront then ALB chain. storeItem now
derives the recorded address from req.ip and req.ips, so only hops Express
trusted are used.

Behaviour is covered by tests that run a real Express app through
setupBaseServerConfig with a spoofed header.

Companion infra change: compiler-explorer/infra#2353.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 18:09:43 -05:00
..
2026-07-02 18:26:35 +01:00
2025-07-28 10:34:46 -05:00