Repository navigation
fix(csrf)!: require Origin to match Host without an allow-list and default to SameSite=Lax - #49
Merged
Merged
Conversation
…ault to SameSite=Lax Without allowed_origins, the cross-site check let a same-site request from a sibling subdomain through, and passed a request without fetch metadata whatever Origin it carried. Now, with no allow-list, a same-site request or one without Sec-Fetch-Site that carries an Origin needs that Origin's host[:port] to equal the request's Host header (or the HTTP/2 authority), a default port aside. A Sec-Fetch-Site value the check does not know is treated as cross-site. Refusals keep answering 403 cross_site_request_blocked. Cookies now default to SameSite=Lax instead of None. The reference app pins SameSite=None, which the conformance contract expects. Closes #42 BREAKING CHANGE: auth cookies default to SameSite=Lax (was None when Secure). A frontend on another site that calls the adapter with credentials must set same_site(SameSite::None). Without allowed_origins, an unsafe request whose Origin does not name the request's own Host is refused with 403 cross_site_request_blocked; behind a proxy that rewrites Host, or for a frontend on another origin, set allowed_origins.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42. Part of fells-code/seamless-auth-api#603 (v0.24, M12).
What changes
allowed_origins, an unsafe request withSec-Fetch-Site: same-site, or with noSec-Fetch-Siteand anOrigin, needs theOrigin'shost[:port]to equal the request'sHostheader (or the HTTP/2 URI authority). A default port (:443for https,:80for http) on either side does not count against a match. Before, both cases passed.Originis refused without an allow-list too, as it already was with one.Sec-Fetch-Sitevalue is treated as cross-site.403 { "error": "cross_site_request_blocked" }. No option names change. The allow-list path is unchanged.SameSite=Lax(wasNonewhen Secure,Laxwithinsecure_cookies).same_site(SameSite::None), whichverify/CONFORMANCE.mdexpects.Behaviour change
The commit carries a
BREAKING CHANGEfooter, so release-plz bumps the minor version (pre-1.0). A frontend on another site that calls the adapter with credentials must now setsame_site(SameSite::None)andallowed_origins. A deployment behind a proxy that rewritesHostshould setallowed_origins.Checks
cargo fmt --check: cleancargo clippy --all-targets -- -D warnings(default,--all-features,--no-default-features,--no-default-features --features native-tls): cleancargo test --all-features: 155 passedcargo +1.88 test: 155 passedscripts/check-manifest.sh: matches