Files
Matthew Phillips dafbb1ba29 Prevent cache poisoning in x-forwarded headers (#14743)
* Restrict X-Forwarded-Proto and X-Forwarded-Port

* Fix X-Forwarded header security vulnerabilities

- Sanitize hostnames to reject paths and prevent path injection
- Validate X-Forwarded-Proto, X-Forwarded-Host, X-Forwarded-Port headers
- Add strict rejection for invalid hostnames (those with path separators)
- Implement single sanitizeHost() function in App class, used by both validateForwardedHeaders() and node.ts
- Add comprehensive security tests for header validation

* Fix path injection and port matching bugs in header validation

- Reject both forward and backward slashes in hostnames using single regex
- Fix allowedDomains port matching by validating full hostname:port combo instead of just hostname
- Add test for X-Forwarded-Host with embedded port in allowedDomains pattern

* changeset and build

* fix: validate X-Forwarded headers with port pattern matching

Fixes protocol validation to accept http/https when allowedDomains exist but lack protocol patterns. Restructures port/host validation to validate port first, then include it when validating host against patterns. Properly extracts hostname without port to avoid duplication when combining with X-Forwarded-Port.

* Update .changeset/secure-headers.md

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

---------

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
2025-11-10 15:18:23 -05:00
..
2025-02-06 13:11:10 +00:00
2024-08-29 08:45:22 +02:00
2025-08-08 14:57:47 +00:00
2024-08-29 08:45:22 +02:00
2025-02-06 15:08:28 +00:00
2024-02-23 13:24:45 +00:00
2025-02-06 13:11:10 +00:00
2025-10-14 06:55:43 +00:00
2024-03-01 08:33:27 +00:00
2025-08-14 08:04:32 +00:00