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-14 08:46:10 +01:00
2021-10-05 01:45:05 +02:00
2019-08-21 01:26:16 +02:00
2025-01-29 10:41:03 -06:00
2021-09-13 20:22:27 +02:00
2024-10-26 17:42:22 +02:00
2024-03-08 22:25:09 -06:00
2024-03-08 22:25:09 -06:00
2024-03-08 22:25:09 -06:00
2026-02-08 12:50:20 +01:00
2024-03-08 22:25:09 -06:00