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>