Skip to content

feat: cookie and session-cookie pentesting checks from BootUI 2.5.0 - #277

Merged
ffroliva merged 26 commits into
release/0.8.0from
feat/0.8.0-a12
Nov 22, 2026
Merged

ffroliva merged 26 commits into
release/0.8.0from
feat/0.8.0-a12

Conversation

@ffroliva

Copy link
Copy Markdown
Owner

Summary

Ports BootUI 2.5.0's cookie-flag and session-cookie pentesting checks (lane A12 of the 0.8.0 plan) onto the bounded
probe runner. No new request is sent: the checks read the Set-Cookie and Cache-Control headers of the scan's GET
probe and the application's own session middleware configuration.

  • Nine checks in BootUI's registry order with its texts, severities and gap strings: the HttpOnly, SameSite and Secure
    flags, the __Host- and __Secure- prefix requirements, the session cookie configuration, and cacheable
    Set-Cookie responses (PT-A02-007 and PT-A02-008 included, both active in BootUI 2.5.0).
  • Cookie values are never kept: a parsed cookie holds its name, flags, a closed SameSite value and whether its path is
    the root, nothing else. A name is checked for secret shapes on its full length before it is shortened; a nameless
    cookie is labelled (unnamed), never with its first segment.
  • Cache-Control evidence is rebuilt from the recognised directives; the raw header is never echoed.
  • The shared evidence helpers (the echo that masks host fragments and the evidence sanitiser) move to
    pentesting/echo.py, re-exported where the CORS checks used them. Every finding passes the sanitiser.
  • The session check reads the security facts once per scan, after the probe releases its single-flight; when the facts
    are unavailable or incomplete the scan records BootUI's configuration gap and is PARTIAL.
  • Deviation rows are in docs/reference/matrix-updates/0.8.0-a12.tsv.

Tests

Every test commit was red at its named assertions before the change (scripts/dev/red_check.py), and the absence
tests are backed by recorded mutations, each killed by its named test. A planted cookie value, attribute values and a
Cache-Control secret appear on no output surface (POST scan, cached GET report, MCP, CLI) under MASKED and
METADATA_ONLY; under FULL only a long cookie name that no secret shape matches is shown, shortened, as recorded in
the deviation rows. The worst-case limitation list is measured on the real report and every promised statement
survives the 20-entry cut. Ruff, format, pyright and the code-shape, import-boundary and citation checks pass.

…ing checks

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

Reuse the A11 completeness and header helpers, keep observations free of
attribute values, redact secret-shaped names before shortening, rebuild the
PT-A02-008 evidence from parsed directives, use BootUI's gap wording, split the
check and surface tasks, and record the Flask and session-clear deviations.

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

The shared evidence module is created by A12, every finding passes the evidence
sanitiser, the stub names are consistent, read_security_facts has its own tests,
Cache-Control is covered at host level, the FULL capture exception is stated and
boundedLabel uses an ASCII class.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Route the session configuration findings through the shared evidence sanitiser and test all nine rules. Limit capture-record assertions to the cookie value and record that Cache-Control values are captured as sent. Use public with private in the Cache-Control case. Move the PT-A02-008 presence assertion to its own file so the earlier tasks turn green. Record the actual names of the CORS helpers and keep their imports working.

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

The scan reads the security facts once, after run_probe returns and the single-flight is released; a busy scan reads nothing. The worst-case limitation test measures the real pre-cut list (15 entries) instead of summing constants.

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

The echo factory and the evidence sanitiser leave cors.py for echo.py so the cookie checks reuse them. Behaviour is unchanged; cors.make_echo stays importable.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
The parser stub is BootUI's literal cookieName (the whole first segment as the name, attribute presence by substring, no deletion, no SameSite or Path classification), so every test fails on its assertion. red_check: 19 of 19 RED.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
parse_set_cookie keeps a bounded name label, flag presence, a closed SameSite class, Path=/ and the deletion decision, and no text of any value. A first segment with no = after its first character is (unnamed); a secret-shaped name is (redacted) before the 80 character cut. All 19 observation tests pass.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Stubs: split_cookies returns the headers unchanged, and observed is BootUI's literal port (the whole first segment as the name, the echo ignored), so the raw Set-Cookie value reaches every surface. red_check: 128 of 128 RED (5 probe, 27 cookie surfaces, 96 Cache-Control surfaces). The Cache-Control surface file stays red for the PT-A02-008 cases until the cacheable check lands. tests/fastapi/pentesting_surfaces.py is the shared host and surface collector of the two surface files.
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
split_cookies parses every Set-Cookie value in arrival order and returns the headers without that key; the probe sets SyntheticResponse.cookies from it, so no cookie text outlives the call. The observed stub now reads the observations. The cookie probe and surface files pass (77 tests) with the Cache-Control surface file still red.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Against the Task 4 stub (one INFO finding per cookie, no deletion filter, no gaps, no sanitiser) all 10 tests are RED at their assertions (red_check: 10 of 10). The failed or rejected GET and the incomplete Set-Cookie inventory tests are placed here rather than with the Cache-Control tests: Task 6 implements that gating, so they cannot be red later.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
PT-A02-001, PT-A05-005, PT-A02-002 and PT-A02-003 follow BootUI's texts, severities and order over the non-deletion observations. The name goes through echo, the severity is decided on the unmasked label, and the whole sentence passes through the shared sanitiser. An incomplete Set-Cookie inventory is BootUI's gap, and the retained cookies are still checked. All 10 flag tests pass (249 in the lane gate).

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
red_check against the stub (no prefix rules, no session findings) over the new nodes: 11 RED (the prefix requirement, session prefix and 240 character cut tests, and the nine-rule sanitiser cases for PT-A02-004, -006, -007, -008, PT-A05-064, plus the two mount path cut cases). Four nine-rule cases (PT-A02-001, -002, -003, PT-A05-005) pass already because the flag helper of the previous commit uses the shared sanitiser; they are characterization and make a skipped sanitiser in that helper fail its own case. The PT-A02-004, -006 and -008 cases stay red until their tasks.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
PT-A02-007 reads every observation (deletion cookies included, as BootUI does) and PT-A05-064 the non-deletion ones, both through the shared finding helper. Seven of the nine-rule sanitiser cases and all prefix tests pass; the PT-A02-004, -006 and -008 cases stay red until their tasks.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Stubs: parse_cache_control sets every signal, directive_summary returns the raw joined text with a marker, and the PT-A02-008 branch fires HIGH for every cookie whenever a Cache-Control header exists. red_check: 35 of 35 RED in test_cache_control.py and the 4 new check tests RED (cacheable distinction, rebuilt evidence, incomplete header gaps, deduplicated gaps). The plan's all-false parse stub and bare raw-text summary stub were made wrong in both directions so the silent and trivial cases are red too.
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…eport text

PT-A02-008 follows CacheableSetCookieCheck: the header requirement is evaluated before the empty-cookie check, both BootUI gap strings are recorded for an incomplete Cache-Control, and the evidence is rebuilt from recognised directives (numeric arguments of at most ten digits, other directives counted), never from the raw header text. The cookie words leave the pending limitation; the A04 scope sentence is BootUI's. The Cache-Control surface file (96 cases) and all cookie tests pass; only the four PT-A02-004 and -006 sanitiser cases stay red until the session checks land.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Stubs: read_security_facts returns an empty SecurityFacts for any input, session_evidence one config with both flags set, configured one INFO PT-A02-004 finding with the text stub and no gap, and scanned_report and PentestingService.scan accept and ignore the new session keyword. red_check: 22 of 22 RED (5 configuration checks, 14 reader cases, the scan over a SessionMiddleware host, the https_only keyword flag, the report keyword).
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
PT-A02-004 and PT-A02-006 read the SessionMiddleware keywords from the static security facts: only https_only passed as False is an explicit false (new https_only_false flag), and the mount path goes through echo and the shared sanitiser. Absent facts or any limitation record BootUI's configuration gap, make the scan PARTIAL and copy no limitation text. read_security_facts is called once per completed scan, after run_probe released the single-flight, catches Exception without logging, and returns None for an absent, raising or wrongly typed reader. All 22 previously red tests pass (497 in the lane gate with the Security panel and parity suites).

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
The cases are absence-only, so their red evidence is a control-deletion run: each
wrong-value mutation was applied to the working tree, red_check was run on the named
tests, and the file was restored with git checkout.

M1 the parser returns the raw first segment as the name
   test_segment_without_equals_is_unnamed, test_empty_name_is_unnamed,
   test_synthetic_response_repr_holds_no_header_text (3 of 3 RED)
M2 split_cookies returns the headers unchanged
   test_set_cookie_values_never_reach_the_synthetic_response and the FULL post_scan
   surface case (2 of 2 RED)
M3 the echo is skipped on a cookie name
   test_flag_findings_name_the_echoed_label_and_classify_the_unmasked_one (RED)
M4 directive_summary returns the raw text
   test_cache_control_evidence_is_rebuilt_from_directives and the public-with-extension
   surface case (2 of 2 RED)
M5 the security facts are read in a read path
   test_reads_never_call_the_host_or_read_security_facts (RED)
M5b the security facts are read before run_probe
   test_a_busy_scan_answers_409_without_a_host_call_or_a_facts_read (RED)
M6 the per-name incompleteness is dropped
   test_overlong_cookie_value_marks_set_cookie_incomplete_only (RED)
M7 session_evidence copies the limitation text
   test_unreadable_session_options_leave_metadata_checks_indeterminate (RED)
M8 the finding helper of cookie_checks skips sanitize_evidence
   test_cookie_finding_evidence_goes_through_the_shared_sanitiser for PT-A02-001, -002,
   -003, -007, -008, PT-A05-005, PT-A05-064 and the 240 character cut test (8 of 8 RED)
M8b session_cookie.configured skips sanitize_evidence
   test_session_findings_cut_a_long_mount_path_at_240_characters for PT-A02-004 and -006
   (2 of 2 RED)
M9 read_security_facts lets the exception escape, or logs its message
   test_read_security_facts_returns_none_and_logs_nothing_when_the_reader_raises
   [RuntimeError] and [ValueError] (RED both)
M10 boundedLabel uses Python \s
   test_label_keeps_unicode_whitespace_that_java_does_not_match (RED)

The worst-case limitation test measures the real pre-cut list: 18 unique entries at this
merge point (A10 7, A11 7, A12 1, 3 standing), not the 16 the plan estimated, and names
every one of them; all survive the 20-entry cut.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
The rule-contract projection gains the nine BootUI cookie rules in registry order, and a hand-derived golden (cookie-captured.json) pins BootUI's text for a cookie-setting response with fake values. The deviation rows are in 0.8.0-a12.tsv and spec section 14, the pentesting:cookie-pending row leaves 0.8.0-a10.tsv, and the user skill states what the checks observe. Lane gate: 1142 passed (pentesting engine and FastAPI tests, Security panel transport rules, import boundary, parity and docs); ruff check, ruff format --check and pyright clean.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…tion rows read neutrally

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…s from BootUI

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
@ffroliva
ffroliva marked this pull request as ready for review November 22, 2026 03:52
@ffroliva
ffroliva merged commit 690a1a2 into release/0.8.0 Nov 22, 2026
45 checks passed
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