Skip to content

feat: calibrate the CSP checks as BootUI 2.6.0 - #382

Draft
ffroliva wants to merge 128 commits into
mainfrom
feat/0.11.0-t2.2-csp
Draft

ffroliva wants to merge 128 commits into
mainfrom
feat/0.11.0-t2.2-csp

Conversation

@ffroliva

@ffroliva ffroliva commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Task 2.2 of the 0.11.0 plan (#367), row A10 of the BootUI 2.6.0 delta: the pentesting CSP checks are calibrated as
BootUI 2.6.0 WeakContentSecurityPolicyCheck, MissingCspHardeningDirectivesCheck and
PentestingResponsePolicies.unrestrictedFraming.

  • PT-A05-060 is LOW. Weaknesses are evaluated across every enforcing policy (a weakness counts only when every
    policy allows it). Missing object-src (or the default-src fallback) and base-uri are folded into its evidence.
    A response whose enforcing policies restrict no scripts (no script-src, script-src-elem or default-src, and no
    blocking sandbox) is reported. Directive presence decides, not truthiness.
  • The PT-A05-060 recommendation carries BootUI 2.6.0's guidance: avoid wildcards and plain data, HTTP or HTTPS
    script sources, and prefer nonces or hashes with strict-dynamic.
  • PT-A05-067 reports only when PT-A05-060 did not.
  • PT-A05-066 reports only a wildcard frame-ancestors source that every enforcing policy allows; scheme sources
    alone no longer report it. Its severity is MEDIUM, as BootUI's PermissiveFrameAncestorsCheck (it was LOW).
  • docs/reference/matrix-updates/0.11.0-rules.tsv (new): PT-A05-060 adapted (evidence and advice use sharpit's
    static wording without quoted CSP source tokens, pinned by test_csp_weakness_output_does_not_echo_policy_values),
    PT-A05-066 matched, PT-A05-067 adapted.

Review scope

The branch was cut from the 0.11.0 integration line, so against main the diff also shows the earlier 0.11.0 pull
requests. This pull request's changes are src/sharpit/engine/collectors/pentesting/checks.py,
tests/engine/collectors/pentesting/test_pentesting_report.py and the matrix fragment above.

Red evidence

Tests were committed before each change; each red is an assertion (scripts/dev/red_check.py).

Finding Test Red
PT-A05-060 severity, folding and 067 gating differed from BootUI 2.6.0 the ported tests in test_pentesting_report.py (# ported: PentestingScannerTests) assertion
The 060 recommendation lacked the scheme-source and nonce guidance (review) test_weak_csp_recommendation_covers_scheme_sources_nonces_and_strict_dynamic assert 'data' in recommendation
PT-A05-066 fired on https: alone and ignored other policies (review) test_unrestricted_frame_ancestors_requires_intersected_wildcard assert 'PT-A05-066' not in [...]
A ported test asserted less than BootUI's (review) test_weak_csp_is_low_folds_hardening_gaps_and_skips_067 tightened; passes on the fix
PT-A05-066 was LOW where BootUI reports MEDIUM (review) test_unrestricted_frame_ancestors_requires_intersected_wildcard assertion on the severity
The 060 advice lacked the script-src remedy for the "no policy restricts scripts" case (review) test_weak_csp_recommendation_covers_scheme_sources_nonces_and_strict_dynamic assertion
Case, sandbox allow-scripts, duplicate-directive and mixed-policy framing inputs were untested (review) the parsing edge-case tests in test_pentesting_report.py pin existing behaviour; pass on the fix

docs/reference/PARITY.md lists the 0.11.0 rule deviations from 0.11.0-rules.tsv.

Verification

uv run ruff check, uv run ruff format --check, uv run pyright (0 errors); targeted run over the pentesting,
FastAPI pentest, code-shape, import-boundary, root rule and docs tests. The full suite runs in CI.

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>
Record the two deviations of the inactivity log from BootUI 2.6.0 in a matrix fragment, update the MVP plan text that still described the old log line, extract the inactivity logging of install() into a helper to keep its complexity at the pinned count, and wrap one over-long test assertion.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
An invalid SHARPIT_ENABLED must log exactly one record, the fixed warning, as BootUI does. The count of the remaining configuration warnings stays.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
An invalid SHARPIT_ENABLED is already reported by the fixed inactive warning. Counting its settings warning as well produced a second WARNING record, where BootUI logs one.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…tests

Port BootUiInactiveStartupDiagnosticTests.deliberateDisablementIsSilentAtInfo, cite the BootUI tests the other inactivity tests port, and keep the expected log texts in one test module. A single Inactivity alias types the inactivity category. The matrix row for the warning count records that it leaves out the invalid SHARPIT_ENABLED warning.

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
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…rity

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
# Conflicts:
#	docs/reference/matrix-updates/0.11.0-github.tsv
#	src/sharpit/engine/collectors/github/client.py
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>
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>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant