Repository navigation
Conversation
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
… file Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…e protocol Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
The Origin header is parsed as scheme://host[:port] with an http or https scheme, as BootUI 2.6.0 does: a path (a trailing slash included), query, fragment, userinfo, control character, trailing colon, unsupported scheme or a port above 65535 makes the origin unreadable, and an unreadable origin is cross-site. The value is no longer trimmed.\n\nA port of more than five digits is refused before int() converts it, in the origin and in the request's own Host, so a very long port is a cross-site refusal and no longer an unhandled ValueError. Adds a property test of the origin parser. Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…UI 2.6.0) A write that carries Sec-Fetch-Site must send same-origin or none (ASCII, case-insensitive); same-site, cross-site, an empty value and any unknown value are refused. A present but empty Origin header is an unreadable origin and is cross-site, no longer read as absent. A same-site navigation GET still loads the shell, and an API path still requires the request's own scheme, host and port. A request whose own origin cannot be formed stays cross-site where that comparison applies.\n\nDocuments the rule in SECURITY.md and the BootUI contract note, and records the deviations in the 0.11.0 guard matrix fragment. Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com> # Conflicts: # tests/fuzz/test_trust_boundary_fuzz.py
This branch has not been deployed
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.
Summary
Tasks 1.1 and 1.2 of the 0.11.0 plan (#367), row S1 of the BootUI 2.6.0 delta: the cross-site check accepts only a
serialized origin and refuses same-site or malformed browser metadata on a write.
src/sharpit/engine/guard.py_parse_originaccepts onlyscheme://host[:port]withhttporhttps, as BootUI 2.6.0'sLocalhostGuard.extractOriginHostdoes: no path (a trailing slash included), query, fragment, userinfo, controlcharacter, trailing colon, port above 65535 or other scheme; the value is not trimmed;
nullstays opaque.OriginorHostport longer than five digits is refused beforeint(). Before this change such a port raisedValueError(Python limitsint()to 4300 digits) and the request ended in HTTP 500.Originis cross-site; only an absent header counts as absent.Sec-Fetch-Sitemust besame-originornone(ASCII only, so a Unicode look-alike never passes).Originis parsed once per request.OriginandSec-Fetch-Site: cross-siteon every method, and on API paths a presentOriginmust equal the request's own origin, port included, whatever
Sec-Fetch-Sitesays. Both are recorded deviations(
docs/reference/matrix-updates/0.11.0-guard.tsv, spec §14 rows 8 and 35).SECURITY.mdanddocs/reference/BOOTUI-CONTRACT-MVP.mddescribe the new rule.Behaviour change: a trailing-slash
Originand an emptyOriginon a GET are now refused. Browsers send neither.Red evidence
Every new test below was run against the base source (
b5283506,src/unchanged, the new tests in place):23 failures, each an assertion under
tests/except the two FastAPI oversized-port tests, which fail with the HTTP 500they name.
tests/engine/test_guard.py::test_serialized_origin_rejects_what_2_6_0_rejectstests/engine/test_guard.py::test_rejects_non_serialized_origin_with_trailing_slashtests/engine/test_guard.py::test_a_blank_origin_is_present_and_cross_sitetests/engine/test_guard.py::test_same_site_and_unknown_fetch_metadata_refuse_a_writesame-originacceptedtests/engine/test_guard.py::test_fetch_metadata_allow_list_is_ascii_onlytests/engine/test_guard.py::test_origin_only_write_must_match_scheme_and_effective_porttests/engine/test_guard.py::test_browser_metadata_never_makes_malformed_or_foreign_origins_acceptabletests/fastapi/test_cross_site_origin.py::test_oversized_origin_port_is_cross_site_without_errortests/fastapi/test_cross_site_origin.py::test_oversized_host_port_is_cross_site_without_errortests/fastapi/test_cross_site_origin.py::test_empty_origin_header_is_refused_by_the_fastapi_adaptertests/engine/test_console_contract.py::test_empty_origin_header_is_refused_by_the_consoletests/fuzz/test_trust_boundary_fuzz.py::test_parse_origin_never_raisesOther new tests pin behaviour that already held and must keep holding (the API-path full-origin rule, safe-method
scope, IPv6 and mixed-case origins).
Review findings
Three independent reviews found no fail-open path and no request that ends in an error. Their findings were test and
wording quality, addressed in the last commit:
Originwas parsed twice on API paths# derived:commentsVerification
uv run ruff check,uv run ruff format --check,uv run pyright(0 errors);uv run pytest -q -n 4 tests/engine tests/fastapi/test_cross_site_origin.py tests/fuzz tests/test_code_shape.py tests/docs(7161 passed, 16 skipped). The three overhead-budget tests pass when run alone (
-n 0).