You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Input validation in Security Defenses Headers #30292
#47774
I’d like to dig a bit deeper into this enhancement. Here’s my initial thinking—please review the approach and suggest any changes, especially if there are validation gaps or edge cases I may have missed.
Proposed validation approach
Below is the proposed validation strategy for configurable security headers.
| Header | Proposed Validation | Rationale |
|X-Frame-Options | Must be one of: DENY, SAMEORIGIN, ALLOW-FROM | [RFC 7034] (https://tools.ietf.org/html/rfc7034)|%7C)
|Content-Security-Policy | No newlines/null bytes, max length 1024 | Flexible directive syntax, can't enumerate all valid values|
|Content-Security-Policy-Report-Only | Same as CSP, allow empty | Same as above, optional field|
|X-Content-Type-Options | Must be nosniff | Only valid value per spec|
|X-Robots-Tag | Must be valid directives: none, noindex, nofollow, etc. | Google spec|
|Strict-Transport-Security | Must match max-age= with optional includeSubDomains and preload | RFC 6797|
|Referrer-Policy | Must be one of the spec-defined values | W3C Referrer Policy|
Notes
For Content-Security-Policy and Content-Security-Policy-Report-Only, any max-length check should be treated as an implementation limit, not a protocol requirement.
For X-Frame-Options, I would recommend not supporting ALLOW-FROM unless we have a specific backward-compatibility requirement.
In general, the validation should :
prevent header injection and malformed values,
strictly enforce known enums where the spec defines them,
avoid over-restricting flexible headers like CSP.
Open questions
Do we want to preserve any backward compatibility for legacy X-Frame-Options: ALLOW-FROM usage, even if we do not recommend it?
Should the CSP max-length limit be configurable, or is a fixed implementation safeguard sufficient?
For X-Robots-Tag, do we want strict validation against a curated allowlist, or a lighter validation that only rejects clearly malformed values?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I’d like to dig a bit deeper into this enhancement. Here’s my initial thinking—please review the approach and suggest any changes, especially if there are validation gaps or edge cases I may have missed.
Proposed validation approach
Below is the proposed validation strategy for configurable security headers.
| Header | Proposed Validation | Rationale |
|X-Frame-Options | Must be one of: DENY, SAMEORIGIN, ALLOW-FROM | [RFC 7034] (https://tools.ietf.org/html/rfc7034)|%7C)
|Content-Security-Policy | No newlines/null bytes, max length 1024 | Flexible directive syntax, can't enumerate all valid values|
|Content-Security-Policy-Report-Only | Same as CSP, allow empty | Same as above, optional field|
|X-Content-Type-Options | Must be nosniff | Only valid value per spec|
|X-Robots-Tag | Must be valid directives: none, noindex, nofollow, etc. | Google spec|
|Strict-Transport-Security | Must match max-age= with optional includeSubDomains and preload | RFC 6797|
|Referrer-Policy | Must be one of the spec-defined values | W3C Referrer Policy|
Notes
Open questions
All reactions