Skip to content

Treat a literal "null" Origin like a missing Origin#208

Closed
c-tonneslan wants to merge 1 commit into
gorilla:mainfrom
c-tonneslan:accept-null-origin-fallback-referer
Closed

Treat a literal "null" Origin like a missing Origin#208
c-tonneslan wants to merge 1 commit into
gorilla:mainfrom
c-tonneslan:accept-null-origin-fallback-referer

Conversation

@c-tonneslan

Copy link
Copy Markdown

Closes #205. Per RFC 6454 §7.3, user agents must send Origin: null from privacy-sensitive contexts (sandboxed iframes, file://, redirects from data: URLs, etc.). The opaque value can't be checked against an allowlist, so the current code returns ErrBadOrigin even when the regular Referer-based check would otherwise accept the request.

This treats Origin: null like a missing Origin header: skip the origin allowlist check and let the existing Referer logic decide. For TLS requests that still demands a valid Referer (since the origin == "" && !isPlaintext block runs), so the security posture is unchanged.

Added a regression test covering both the cleartext-passes and TLS-no-referer-rejects paths.

Closes #205

Per RFC 6454 §7.3 user agents must send Origin: null from
privacy-sensitive contexts (sandboxed iframes, file://, etc.). The
opaque value can't be checked against an allowlist, so trying to
compare it short-circuits the request with ErrBadOrigin even when
the regular Referer-based check would otherwise accept it.

Fall through to the existing Referer logic when Origin is "null".
For TLS requests that still demands a valid Referer, so the
security posture is unchanged.

Closes gorilla#205

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
@c-tonneslan

Copy link
Copy Markdown
Author

Closing in favor of #207 which I already had open for the same issue. Sorry for the duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Support "null" value for Origin header

1 participant