Skip to content

fix(security): preserve valid pako diagram links - #10192

Open
rubencu wants to merge 1 commit into
kirodotdev:mainfrom
rubencu:fix/preserve-pako-mermaid-links
Open

rubencu wants to merge 1 commit into
kirodotdev:mainfrom
rubencu:fix/preserve-pako-mermaid-links

Conversation

@rubencu

@rubencu rubencu commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Preserve valid Mermaid Live pako diagram links without allowing compressed credentials or malformed payloads to bypass output redaction.

Mermaid Live #pako: links can contain long opaque base64url payloads that the markerless bare-secret heuristic rewrites as credentials. Exempting opaque text without decoding it would create a credential-egress path.

Why it matters

Users need diagram links to survive batch, streamed, Markdown, and persisted output. Security must still reject malformed data, decompression bombs, and credentials hidden inside decoded Mermaid state.

Not a goal

  • Restore the previous branch's raw-assistant-text, placeholder, host-policy or channel-specific renderer design.
  • Exempt arbitrary compressed URLs or Mermaid routes.
  • Relax fixed, encoded, or token-parameter credential passes.
  • Add stream holdback for PlantUML links: a streamed one past 512 characters keeps the ordinary holdback.

What changed (motivation → approach → change)

The existing span-based document-link scanner recognizes only exact lowercase https://mermaid.live/edit#pako: routes with canonical base64url payloads. Validation requires one complete bounded zlib stream, UTF-8, duplicate-free finite JSON, and a string code field.

Decoded JSON, every textual key and value, and each string value beside its key, at most 1,024 distinct views per call, pass through the composed URL-and-credential pass redact applies, so a diagram URL is percent-decoded like any other. That pass exempts no host: the check has no host snapshot, so a diagram URL that only a host exemption would keep voids the link, and the check never makes a live host read the display cache's key does not cover. Each view's check-only variant (escapes decoded, schemes lowercased, a fragment after a host read as a query) must pass too. A clean candidate exempts only the outer encoded span from pass 3's entropy heuristic. Passes 1, 2 and 4 keep main's precedence, warnings, tags and explainable records. Invalid encoding, trailing bytes, oversized inflation, decoded credentials, alternate routes, and ambiguous state receive no exemption.

The verdict that runs those scans lives in its own owner module, security/redaction_pako.py, behind the redaction facade, so redaction.py stays under AGENTS.md's 1,600-line working target. kiro_crew.security.redaction stays the import path of every name it defines.

Streaming holds only an exact partial pako candidate through the encoded-size ceiling, together with a credential-class run glued before it (href=", a JSON "url":") or after it (a sentence's .), each up to the ordinary 512-character holdback, so the joined run is never cut through the URL. The partial-JWT tail search starts where a match can begin, so a held run stays linear. A partial JWT that starts inside the payload rides that hold, ending there or in the held tail, because the payload alphabet holds no .; every other JWT and Bearer anchor keeps its ceiling. A credential match crossing the hold's cut (a Bearer header a scheme's : cut short) declines the hold, and the partial JWT rides only a run that opens at the route: an eyJ reaching a glued run in a later delta ends its hold, so glued text fails closed as on main.

Scope Purpose
docs/system-specs/modules/security.md Specify the exact pako validation and pass-3-only exemption boundary, and list the redaction_pako.py owner module.
src/kiro_crew/dashboard/display_battery.py and src/kiro_crew/security/pass_compose.py Version stored display verdicts by the composed pass and redaction_pako.py, the code the pako check runs, and import the composed pass's own passes by module path for the battery's import guard. compose takes an exempt-host set, which the pako check passes empty.
src/kiro_crew/security/redaction_entropy.py Declare the exact pako route and decode its canonical state into textual views.
src/kiro_crew/security/redaction.py Nominate safe pako spans under the call's shared budgets, and stay the import path of the new owner's names.
src/kiro_crew/security/redaction_pako.py Scan each decoded view and its check-only variant with the composed pass. A new owner module behind the redaction facade, so redaction.py stays under AGENTS.md's 1,600-line working target.
src/kiro_crew/security/text_redaction.py Bound stream holdback for an exact partial pako candidate.
test/test_mermaid_pako_link_redaction.py Cover valid batch/stream links, routes, encoding, bombs, decoded credentials, spans, and records.
test/test_display_redaction_host_snapshot.py and test/test_display_redaction_prefix_snapshot.py Pin that a pako link's views are judged under the render's one prefix read and no exempt host.
test/test_redaction_facade.py List redaction_pako among the facade's owner modules.
test/test_security_gate_liveness.py Re-measure the security package's line budget.
website/src/test/MarkdownRenderer.mermaidPakoLink.test.tsx Prove validated destinations stay distinct renderer links.

Backwards compatibility

Compatible: ordinary text and non-pako links keep main's redaction; a pako link survives only after bounded validation and scanning.

Removes nothing.

Tests

  • Stream regressions cover a . or : delta after a link, a credential after the held tail, href=", {"url":" and password= leads, and a scan count for a held run of eyJ prefixes.
  • test_a_link_and_its_punctuation_in_one_delta_stream_like_batch and test_a_credential_after_punctuation_in_the_same_delta_is_still_redacted fail on a5e92a6: a link and its . or : in one delta stream intact; a credential after them is redacted.
  • test_partial_jwt_inside_a_valid_payload_streams_like_batch fails on 44f6bde: a link past the JWT ceiling with eyJ in its first delta streams intact. test_a_jwt_beside_a_jwt_bearing_link_is_still_redacted_live and test_a_dot_ends_the_pako_hold_and_a_jwt_spanning_it_is_redacted keep a JWT before, after or across a . in the link redacted live.
  • test_a_jwt_shaped_payload_and_its_punctuation_in_one_delta_stream_like_batch fails on 89ad591: a link with two eyJ runs and its . in one delta streams like batch; a JWT after the . is redacted, and a partial one past the held tail fails closed.
  • test_percent_encoded_credential_in_a_decoded_url_voids_the_link fails on 093ad71: a diagram URL carrying a %5F-written GitHub token or a once- or twice-encoded AWS key ID voids the link; test_credential_free_decoded_url_keeps_the_link keeps clean URLs.
  • test_percent_encoded_credential_in_an_upper_scheme_or_fragment_url_voids_the_link fails on 4bf1725: that token in an HTTPS:// or fragment-only URL, or still encoded after three rounds, voids the link; clean spellings keep it.
  • test_a_bearer_header_glued_to_a_link_is_redacted_with_its_value fails on 64d142a: a plain, JSON or lowercase Bearer header whose opaque or JWT value is glued to a link is redacted with its value; test_a_credential_free_sentence_ending_in_a_link_streams_intact keeps clean text.
  • test_a_bearer_header_glued_to_a_jwt_bearing_link_never_streams_its_value fails on 64d142a, and on 9e0f854 in 7-byte deltas, as does test_an_eyj_ending_a_delta_still_ends_the_hold: a Bearer value glued to an eyJ-bearing link never streams. test_a_label_glued_to_a_jwt_bearing_link_fails_closed pins the cost: a glued href=" masks that run as on main, in any delta size.
  • test_near_cap_one_byte_stream_stays_linear_in_cpu bounds a near-cap one-byte stream to 25x the CPU of a tenth-size one.
  • test_a_state_past_the_view_cap_fails_closed fails on 88fd4b0: past 1,024 views it is redacted as on main.
  • test_top_level_pako_links_share_one_view_budget and test_identical_views_are_composed_once fail on 5809b63: links share 1,024 distinct views; duplicates compose once.
  • test_an_escaped_tab_cannot_split_a_bearer_value_from_its_label fails on 493474a: an escaped tab between Bearer and its token voids the link, batch and live.
  • test_a_pako_link_is_judged_under_no_exempt_host fails on f8fab4f: rendering a pako link whose diagram URL sits on an allowed host read the host set five times. It now reads it once, for the cache key, and masks the link.
  • Moving the pako verdict into redaction_pako.py is a pure move: the redaction, pako and display tests pass unchanged, and only the facade test's owner table names the new module.
  • 458 related test files: 34,696 passed. The 6 failures fail the same way on clean main, except the dashboard boot-chain contract, which passes in a clean checkout.
  • Static gates, docs lint and the line cap passed.

Manual verification

N/A: covered by the tests above.

Screenshots / video

Why no screenshot: No UI pixels change; the frontend delta only adds a test.

Related Issues

No public issue links this security defect.

Pattern harvest

Rule candidate: review-prompt

Pattern: an opaque encoded-output exemption must use a bounded semantic decoder and scan every decoded textual view before only the known false-positive heuristic may skip its outer span.

Checklist

  • At most two commits, with a Conventional Commits title
  • Existing tests pass and security regressions cover the exemption boundary
  • Self-review completed and code follows project style guidelines
  • Security documentation updated
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the repository's Apache 2.0 license.

@rubencu
rubencu requested review from a team and smeyffret September 11, 2026 20:46
@rubencu

rubencu commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Intent: Keep exact, valid Mermaid Live pako diagram links intact while fail-closing unsafe encoded state at every output boundary.
Not a goal: Support arbitrary compressed links or add any destination beyond the exact Mermaid Live editor URL.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 299b947cc6be4898f734d51ef1f64fb9855a4407 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 299b947

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 299b947cc6be4898f734d51ef1f64fb9855a4407 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Each item removes a named false positive or keeps streaming identical to batch output. The base RFC (partial) lists #10192 as one of the link classes that is wrongly redacted.

Notes

  • Item 3 — inherited: there is no measurement behind _MERMAID_PAKO_PAYLOAD_CAP = 65_536 / _MERMAID_PAKO_SOURCE_CAP = 65_536. They are 4× PlantUML's 16,384. The only sizing comment is on the view cap ("Far above a real Mermaid Live state"). These caps set how long a stream may hold text back.
    Subtraction: shrink both to the existing _PLANTUML_PAYLOAD_CAP (16,384) unless a measured real state exceeds it.

What this change ships

Inventory (7 items) — 6 justified

Intent: keep Mermaid Live diagram links readable in chat output without opening a way to leak credentials. FIX.

  1. A valid mermaid.live/edit#pako: link now survives batch redaction — justified
  2. A link is kept only if it decodes, inflates within bounds, parses as unambiguous JSON, and the credential/URL scan finds nothing in any decoded view — justified
  3. A streamed reply now waits for a pako payload until it ends, up to 65,536 characters (a timing change) — inherited cap, unmeasured
  4. A credential glued before or after a held link, or crossing the cut, still fails closed — justified
  5. The search for a partial JWT at the end of a stream now starts later, keeping long held runs linear — justified
  6. pass_compose.compose takes host and pass-4 snapshots; it has 2 callers passing different values (None default, frozenset()) — justified
  7. Stored display verdicts are re-versioned by the new rule sources; the PlantUML regex is split into named constants (_PLANTUML_ROUTE, _PLANTUML_PAYLOAD_CAP, one use each) — rides along, undeclared

[FIRST-PRINCIPLES-REVIEWED] 299b947

Description read

[DESCRIPTION-READ] f116c2f5454cade9d85aba45829768b29a8c8afa53d9e8e17dc273012ccbf9b3

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of f8fab4f7ee3f64a1be382112d0f2e397426b8786 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change removes nothing, and it reuses the PlantUML decode-then-scan precedent for a pass-3-only exemption on one exact route.

Notes

  • The stream hold now withholds up to 65,536 characters of live output per candidate, where the docstring used to promise "at most one chunk of latency". A chat that streams a large diagram link stalls visibly until the link ends. You can undo this by reverting, but the spec should state the user-visible latency, not only "bounded".
  • The streaming branch is the riskiest part (_late_jwt_anchor, _credential_match_crosses, _pako_at_route, JWT riding the hold). It is a second commit-cut path beside Phase A/B, and every later anchor change has to keep both in step. The simpler shape is the one your PlantUML "Not a goal" already takes: no special stream hold, live deltas masked, and the batch or persisted pass keeps the link. That shape is worth keeping as the fallback if this branch draws further review rounds.
  • Adding pass_compose.py to RULE_SOURCES changes the display-battery digest, so every stored display verdict is recomputed once after upgrade. That is expected; it is just not listed under Backwards compatibility.

[DESIGN-REVIEWED] f8fab4f

Description read

[DESCRIPTION-READ] 53cc5d78135da841c5cf07d67944c8162286e621c1df00067b0855305ae09a26

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 299b947cc6be4898f734d51ef1f64fb9855a4407 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 299b947

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — ✅ PASS

Which legitimate operations does f8fab4f7ee3f64a1be382112d0f2e397426b8786 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

adjudicated, zero confirmed regressions

Scope-Verdict: PASS

Reason: None of the changed code is in the shell deny tiers. It adds a new pass-3 exemption to the redactor for validated mermaid.live/edit#pako: links and a stream hold for them. Base and head have the same tool-call refusal surface, so no legitimate shell operation should be newly refused. The stream-redactor hold, a display-side guard, has no classifier verdict and is named under UNADJUDICATED.

TIGHTENING: In the display redactor, a new Mermaid pako link is let through only after validation: _mermaid_pako_verdict / _pako_view_unchanged run every decoded view, and a check-only variant of it, through the composed URL-and-credential pass. -- The threat it refuses is a credential hidden in a compressed diagram state that reaches chat unredacted. It lives in the hunk + r"mermaid\.live/edit#pako:(?P<pako>" + _MERMAID_PAKO_PAYLOAD + r")(?![A-Za-z0-9_/=-])" together with + return all(_pako_view_unchanged(view, judge) for view in views), spent, len(views). The gate tiers do not consume this hunk: SHELL_DENY_TIERS in src/kiro_crew/hooks.py:1990 resolves to is_sensitive_bash_command, audit_bash_exfiltration and is_denied, and none of them reaches _document_link_spans. In exfil, redact_credentials appears only in blocked-link record retention (src/kiro_crew/security/exfil.py:533, 649), which is not a refusal path.

ADJUDICATED: 15 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: I wrote candidates in three spellings:

  • posix: test runs with / paths, curl / xdg-open of pako, PlantUML and Google-doc links in single quotes, a hand-built pako payload, and git grep.
  • windows: test paths with \ separators, npx.cmd, curl.exe and start "" with double-quoted URLs.
  • any: an echo of a pako link with no executable path.

The diff assumes no host path, separator or interpreter. Its only spelling assumption is the URL grammar: lowercase https://, a fragment route, and the base64url payload alphabet. Each platform's URL quoting covers that, and the URL rows exercise the exfil tier, which reads URLs in command text. The diff also touches a macOS-only redactor branch only through its documentation, so no macOS-specific spelling needed probing.

UNADJUDICATED: The guard is StreamRedactor.feed / flush in src/kiro_crew/security/text_redaction.py, together with _mermaid_pako_verdict reached through _document_link_spans → _credential_redaction_plan → redact_credentials / pass_compose.compose. The call path is a streamed chat delta → StreamRedactor.feed → pako candidate isolation (_pako_candidate_with_tail, _credential_match_crosses, _late_jwt_anchor) → held chunks → batch redaction at termination. The classifier gives no verdict for this display-side path, so these inputs went unjudged:

  • an agent turn that streams a real Mermaid Live link one token at a time, followed by . and more prose;
  • a link inside a markdown [text](…) or a JSON "url":"…", with credential-class bytes glued before the route;
  • a link whose payload is followed by : or . in the same delta;
  • a valid state whose diagram code contains an ordinary https:// URL that has a query string;
  • two or more pako links in one message, which share the 1,024-view budget;
  • a large real diagram near the 65,536-character payload cap.

None of these is a shell refusal, so none can block. What could go wrong is over-redaction or added latency on display, not a refused operation.

[SCOPE-REVIEWED] f8fab4f

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 11 classified, 0 newly refused, 11 still allowed.
  • ubuntu-latest (platform posix): 11 classified, 0 newly refused, 11 still allowed.
  • windows-latest (platform windows): 5 classified, 0 newly refused, 5 still allowed.

No candidate flipped from allowed to refused.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 11, 2026
@rubencu
rubencu force-pushed the fix/preserve-pako-mermaid-links branch from de0f833 to 852291b Compare September 12, 2026 01:42
@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • Fixed circular-import rationale span=777d0760c77b

disposition: fixed
Added an explicit # circular import: comment at the function-local scan_exfiltration_urls import.
The comment explains that exfil imports the pako protection helpers from the security facade, so the deferred import is intentional.
Fixed in 852291ba2bda25bf0192452482a00d038e28df7d.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 12, 2026
@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: keep the platform-to-security dependency lazy at the redaction call boundary

  • Rebutted — span=a4c27d3e83c4

_redact_with_policy_findings is intentionally imported inside redact_via_context(): platform context is on bootstrap paths, while importing security initializes a large regex stack.
Moving this security import to module scope would add avoidable platform module-load work and increase import-cycle risk. The function-local import runs only when redaction is requested, and Python caches it thereafter.
Findings that require moving this deferred platform-to-security dependency to module scope are covered by this ruling. The lazy import is intentional dependency loading, not incorrect behavior.

@rubencu
rubencu force-pushed the fix/preserve-pako-mermaid-links branch from 852291b to 9c23fdb Compare September 12, 2026 04:58
@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author
  • Fixed: CJK boundary ownership release

Matching CJK closers and separator-plus-backtick boundaries now release outer-URL ownership through the same shared acceptance predicate in batch and streaming paths.
Red-before two-link tests cover both boundary classes at every stream split.
Fixed in 9c23fdb80af5bda09e83249d7d67993230ed73b5.

@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author
  • Fixed: terminal dashboard persistence policy

Normal segments, every terminal partial-output persistence arm, and Stop-hook egress now share one baseline-plus-active pako-aware assistant boundary.
A red-before provider-death regression proves companion-only decoded state cannot persist.
Fixed in 9c23fdb80af5bda09e83249d7d67993230ed73b5.

@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author
  • Fixed: channel thinking split across tool events

TurnDriver preserves thinking redactor state across tool/control frames because channel renderers concatenate those frames, then flushes at answer text, completion, or abnormal stream end.
A red-before tool-interleaving regression proves the joined companion credential is redacted.
Fixed in 9c23fdb80af5bda09e83249d7d67993230ed73b5.

@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author
  • Fixed: dashboard reasoning burst boundary

Dashboard thinking now flushes at text, tool-call, and completion because its browser starts a new reasoning block at each tool row; channel TurnDriver behavior remains intentionally different.
Backend boundary tests and 275 browser reducer tests prove separate benign bursts stay unchanged.
Fixed in 9c23fdb80af5bda09e83249d7d67993230ed73b5.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 12, 2026
@rubencu
rubencu force-pushed the fix/preserve-pako-mermaid-links branch from 9c23fdb to 218301b Compare September 12, 2026 06:09
@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: preserve outer URL ownership through false Markdown destination markers

  • Fixed — span=50b2215ffa8d

Markdown destination state now requires not has_outer_url. Once an outer URL owns the token, ]( stays URL data and the following pako payload fails closed.
Batch and every-stream-split regressions were red before this fix; normal Markdown destination coverage remains green.
Fixed in 218301bf85cb34185c9b7bbeb864925b3bc4e9e3.

@rubencu

rubencu commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author
  • Rebutted: Item 4 renderer-valid CJK and quoted-href boundaries

Fail-closed here is safe from exfiltration but still corrupts a renderer-valid link, which is the user-visible defect this PR exists to stop.
CJK support was added only after exact dashboard renderer cases failed review; quoted href handling mirrors browser-trimmable URL bytes under a strict 1 KiB fail-closed ceiling.

@rubencu

rubencu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Pushed c25a9cb, rebased onto d2417a4. This answers items 2 and 3 of review 5624890509.

  • Item 2, First Principles note: the always-empty emitted prefix is gone from StreamRedactor.feed, and its returns read as on main again. The PR's remaining diff in feed is only the pako hold. This is a pure subtraction, so no test can fail first; the 23 modules that use StreamRedactor pass (2,055 tests).
  • Item 2, Opus note: _mermaid_pako_views now stops at _MERMAID_PAKO_VIEW_CAP = 1_024 views. Past the cap the link earns no exemption and is redacted as on main, and the decoded bytes still count against the shared budget. A view-heavy state took 82-106 ms before and about 1-2 ms now; a realistic state (14 views) is unchanged at 0.1 ms and stays exempt.
    • test_mermaid_pako_link_redaction.py::test_a_state_past_the_view_cap_fails_closed[7|4096] fails on 88fd4b0.
    • test_a_state_at_the_view_cap_keeps_its_link guards the boundary.
    • security.md names the cap, and the budget was re-measured at 32,563.
  • Item 3, the test_security_gate_liveness.py conflict, was resolved in 88fd4b0.
  • Item 1, the two tracking issues, is with the author.
  • Checks: 12,846 scoped tests passed on 7796e2a. The 22 host-caused failures reproduce on a clean 7796e2a checkout, and one known flaky test passes alone. The dist-less composition contract (65), the static gates and the 2,000-line cap passed. On the final base: 372 PR and main-touched tests, the gates and the cap passed again.

@rubencu

rubencu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Pushed f14008a, rebased onto 02ae080.

  • Conflict with main's fix(security): block shell-expansion (arithmetic) evasion of the IMDS denial #22826 (shell-expansion IMDS gate) in test/test_security_gate_liveness.py. Main re-measured the security package budget from 32,206 to 32,438. Both notes are kept, and the PR's budget was re-measured at 32,795: main's 32,438 plus this PR's unchanged 357 lines. Every other PR line matches the published patch.
  • The runs on c25a9cb finished. GPT and Opus had no findings, and Design and UX passed. The reds were Sensitive Change Review (fork infra), Coverage Gate downstream, and Backend shard 7 test_remote_session.py::test_child_exit_flushes_output_and_finishes_the_link (assert 255 == 0). That test came with main's feat: add Coder remote session environments #19833, and this PR touches no remote-session code. It passes 5 of 5 alone on both this head and a clean d2417a4 checkout.
  • Item 1 of review 5624890509 (tracking issues) is still with the author.
  • 615 PR, budget, composition and main-touched tests passed, as did the static gates and the 2,000-line cap.

@rubencu

rubencu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 33cdb8f1. Main's #23335 raised the security package budget in test/test_security_gate_liveness.py from 32,438 to 32,447 (one paths_lists entry), so the rebase conflicted on _PACKAGE_LINE_BUDGET.

Resolution: both budget notes kept. This PR's note now starts from 32,447, and the budget is re-measured at 32,804 (main's 32,447 plus this PR's 357 lines, unchanged). No other file changed: the other 8 paths in the patch are identical to the previous head.

Checks on the rebase:

  • The PR's tests, the tests main changed since the previous base, and every redaction/security-related module (423 files): 29,126 passed. The 22 failures are test_design_tweak_backend.py and test_auto_improvement_members.py, which fail only on this host's temp directory and are not touched by this diff.
  • After main moved to 33cdb8f1: the PR's tests, the newly touched tests and the budget test passed (270).
  • Dist-less dashboard composition (65), static gates, the 2,000-line cap, docs lint and the PR body check all pass.

The UX Review check on the previous head stayed "in progress" because its Fork UX Review run was cancelled at 12:37Z; this push starts a new one.

@rubencu

rubencu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 48fb674c. Main's #23292 (the rm_floor backtick and glued-redirect reads) raised the security package budget in test/test_security_gate_liveness.py from 32,447 to 32,518, so the rebase conflicted on _PACKAGE_LINE_BUDGET again.

Resolution: both budget notes kept. This PR's note now starts from 32,518, and the budget is re-measured at 32,875 (main's 32,518 plus this PR's 357 lines, unchanged). No other file changed.

Checks on the rebase:

  • The PR's tests, the tests main changed since the previous base, and the redaction, shell-floor and security modules (581 files): 37,885 passed. The 24 failures are not from this diff:
    • test_design_tweak_backend.py (21) and test_auto_improvement_members.py fail on this host's temp directory.
    • The boot-order pin fails only with a built website/dist; the dist-less run passes (65).
    • test_find_ui.py (one case) failed once in the parallel run and passed alone (179 of 179).
  • After main moved to 48fb674c: the PR's tests, the newly touched tests and the budget test passed (290).
  • Static gates, the 2,000-line cap, docs lint and the PR body check pass.

@rubencu

rubencu commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 177acfe6. Main's #23146 (plural-route commit permalinks in the bare-secret pass) rewrote the "Bare label-less secret-key detection" paragraph in docs/system-specs/modules/security.md. That is the same one-line paragraph this PR extends with its Mermaid pako section, so the rebase conflicted there.

Resolution: main's rewritten paragraph is kept, with this PR's pako section inserted unchanged at the same place. Main's edits are all earlier in the line, and the inserted text is byte-identical to the previous head's. Main's #23146 also changed security/redaction_entropy.py, which this PR edits too; it merged without conflict, and the measured package total is still 32,875, matching this PR's budget pin.

The other 8 paths in the patch are identical to the previous head.

Checks on the rebase:

  • The PR's tests, the tests main changed since the previous base, and the redaction, shell-floor and security modules (758 files): 46,362 passed. The 23 failures are not from this diff: 22 are this host's temp-directory reds (test_design_tweak_backend.py, test_auto_improvement_members.py), and the boot-order pin fails only with a built website/dist (the dist-less run passes, 65).
  • After main moved to 177acfe6: the PR's tests, the newly touched tests and the budget test passed (133).
  • Static gates, the 2,000-line cap, docs lint and the PR body check pass.

The previous head's reds were all outside this diff: a Backend shard 8 CI timeout in test_execution_context.py (passes locally in 15 s), the downstream Coverage Gate, and Sensitive Change Review.

@rubencu

rubencu commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto fada42f7b3; the new head is 5809b63de9. The only conflict was the security package line budget in test/test_security_gate_liveness.py. Main #23627 raised that budget to 32,526 for one _WRITE_PROTECTED_HOME_PATHS entry. Main's note and this PR's note are both kept. This PR's note now reads "Raised again, from 32,526". I re-measured the package on the rebased tree: 32,883 lines, which is main plus this PR's unchanged 357, and the pin is set to that. The other 8 paths carry the same diff as before.

Tests:

  • 48,968 scoped tests passed. There were 2 failures:
    • The boot-order pin. It needs a built website/dist and passes without one (65/65).
    • test_find_ui, a one-case parallel flake. The file passes alone (179/179).
  • After the final rebase onto fada42f7, main's newly touched tests and this PR's tests passed. Only the same boot-order pin failed.
  • The static gates, line cap, docs lint and check-body all pass.

@rubencu

rubencu commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

This addresses the Opus finding on 5809b63de9 (redaction_entropy.py:863). The new head is 41ba1eaa05, rebased onto d5b8c2099c. The view cap applied per pako link, and the per-call budget counted only decoded bytes. Many links in one text could therefore multiply the composed passes.

  • _document_link_spans now gives every top-level pako link in one call a shared budget of 1,024 distinct views, alongside the decoded-byte budget. It is _MERMAID_PAKO_VIEW_CAP, the same number as the per-state cap.
  • _mermaid_pako_verdict charges each link's distinct views to that budget, and judges identical views only once.
  • A state that needs more views than remain fails closed, before any compose. It spends the rest of the budget, so every later link fails closed too. This matches what the byte budget already did.
  • The comments and security.md now state the per-call bound. The package budget note names the view budget, and the package re-measures at 32,900 lines.

New regressions, both failing on 5809b63de9:

  • test_top_level_pako_links_share_one_view_budget: two 600-view links are each kept alone. Together, only the first is kept, and the composes stay within 2 × 1,024.
  • test_identical_views_are_composed_once: a state of 1,000 empty strings composed 1,004 times before the fix. It now composes at most 8 times and keeps its link.

Tests: an 815-file scoped selection passed 49,134 tests. Its one red is the boot-order pin, which needs a built website/dist and passes without one (65/65). Main's newly touched tests passed after the final rebase. The static gates, the line cap and docs lint pass.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes on 41ba1eaa0545bc5cd4a8691a01f1459be973f007.

The lane notes and the conflict from our r122 review are answered: emitted is gone, views are capped per state and shared across links, and the Opus finding on 5809b63de9 is fixed with regression tests. No AI lane has an open finding on this head.

One item is still open: the two known gaps outside this PR have no tracking issue. Please open one issue per item and link both in the description:

  • On main, a Bearer header followed by a link leaks an opaque token at 7, 64 and 513-char chunks, and a JWT leaks its claims at 600-char chunks.
  • The PlantUML verdict still uses the credential-only decoded check.

After that this still needs a human. The PR changes what is redacted (security/redaction.py, redaction_entropy.py, text_redaction.py, pass_compose.py), and Sensitive Change Review is red pending a maintainer.

— crew-pr-reviewer (r124)

@rubencu

rubencu commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 3503760e2e; the new head is 9cf78512f9. There was one conflict, the security package line budget in test/test_security_gate_liveness.py:

  • Main fix(security): keep member records in a gateway-only directory #23645 raised the budget by 1, from 32,526 to 32,527, for its member-records leaf in paths_lists. Main's note and this PR's note are both kept, and this PR's note now reads "Raised again, from 32,527". The package now measures 32,901 lines: main's 32,527 plus this PR's unchanged 374. The pin is now 32,901.

The rest of the patch merged without conflicts.

Tests, run on ec2619c6f3:

  • A 1,018-file scoped selection passed 60,622 tests. Two failed:
    • The boot-order pin, which needs a built website/dist and passes without one (65/65).
    • test_session_pool.py::TestConfigWiring::test_a_blank_pool_agent_is_the_default_template_not_a_same_named_alias, which is order-dependent under xdist. It passes alone, and its file passes 57/57.
  • The static gates, the line cap and docs lint passed. The description's test line now gives these counts.

Main then moved to 3503760e2e (#23867, #23842, #23852; no shared file). On that base, the tests those commits touched, plus this PR's tests, passed (405, and 65 without a built website/dist).

@rubencu

rubencu commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto badd8f5aa8; the new head is 6b936cac10. There was one conflict, the security package line budget in test/test_security_gate_liveness.py:

  • Main feat(notifications): Web Push for the notification bus #23333 (Web Push) raised the budget by 3, from 32,527 to 32,530, for its web-push leaf in paths_lists. Main's note and this PR's note are both kept, and this PR's note now reads "Raised again, from 32,530". The package now measures 32,904 lines: main's 32,530 plus this PR's unchanged 374. The pin is now 32,904.

The rest of the patch merged without conflicts.

Tests, run on 19877bc051:

  • A 1,269-file scoped selection passed 72,483 tests. It is the previous selection plus the tests main touched since the previous base. Six failed, all specific to this host:
    • The boot-order pin, which needs a built website/dist and passes without one (65/65).
    • Three test_cli.py::TestDoctor cases, which fail the same way without this PR.
    • Two signal-timing cases, test_push_guard_squash.py [SIGINT] and test_push_guard_diagnostics.py [SIGHUP], under load. Both files pass alone (94/94).
  • The security liveness file (10/10), the PR's vitest file (3/3), the static gates, the line cap, docs lint and the description check passed. Vitest ran with main's vite.config.ts minus the React Compiler plugin, because this host's npm registry token has expired, so ChatPaneNotices.tsx ran uncompiled here. The description's test line now gives these counts.

Main then moved to badd8f5aa8 (#24052, testing/harness.py only; no shared file). On that base, test/test_harness.py and this PR's tests passed (222, and 65 without a built website/dist).

@rubencu

rubencu commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Pushed ce6681eccb, rebased onto ce32c2f4db. It answers the Opus 5.5 blocking finding on 6b936cac10 (comment): the two new pako tests carried absolute thread-CPU budgets, which testing-conventions D7 does not allow for a new complexity guard. The change is test-only, in test/test_mermaid_pako_link_redaction.py:

  • test_near_cap_one_byte_stream_stays_linear_in_cpu no longer has the 3-second tenth-size ceiling. It keeps only the bound relative to the tenth-size stream it measures itself (REDOS_SCALING_RATIO per 10x, above REDOS_SCALING_FLOOR_SECONDS).
  • test_terminated_held_candidate_of_jwt_prefixes_stays_within_cpu_budget is replaced by test_terminated_held_candidate_of_jwt_prefixes_scans_only_its_tail. It wraps text_redaction._PARTIAL_JWT_TAIL_RE, counts the characters each search is handed, and requires a 4x run of eyJ prefixes to hand it the same count as a 1x run (4 characters each today). With the search started at the buffer start, the shape before the tail-search fix, it fails: "the tail search read 12070 characters of a 4x run, 3070 of 1x".

No production code changed: the other 8 paths have the same diff as on 6b936cac10.

Tests, on 8edd26d9ba: the pako file, the security liveness file, the facade mirror guards and the tests main touched since the previous base passed (343). The flake-pattern ratchet, the static gates, the line cap and the description check passed, and 65 passed without a built website/dist. Main then moved to ce32c2f4db (#24099, #24114, #24104; no shared file); on that base, the tests those commits touched and this PR's tests passed (200). The description's stream-regressions line now says "a scan count" instead of "a CPU bound".

@rubencu

rubencu commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 9d31193afe; the new head is 7f665b8c56. There was one conflict, the security package line budget in test/test_security_gate_liveness.py:

  • Main perf(redaction): native single-pass credential gate, Python fallback #19628 (native single-pass credential gate) raised the budget by 71, from 32,530 to 32,601, for the optional kc_native pre-filter in redaction_patterns. Main's note and this PR's note are both kept, and this PR's note now reads "Raised again, from 32,601". The package now measures 32,975 lines: main's 32,601 plus this PR's unchanged 374. The pin is now 32,975.

The rest of the patch merged without conflicts, including docs/system-specs/modules/security.md beside main's #24000 edits: the other 8 paths have the same diff as on ce6681eccb.

Tests, run on 5c01f30ac0:

  • 359 redaction, security and main-touched test files passed 19,221 tests, with no failures. They include main's native-gate fallback and pre-filter suites, which run the Python gate here because kc_native is not built on this host.
  • The security liveness file, the PR's vitest file (3/3), the flake-pattern ratchet, the static gates, the line cap, docs lint and the description check passed, and 65 passed without a built website/dist.

Main then moved to 9d31193afe (#23719, #23223, #23717, #23977, #23795, #23925, #23968, #24000). On that base, the 54 test files those commits touched and this PR's tests passed (2,854), docs lint and the line cap passed, and 65 passed without a built website/dist. The description's test line now gives the 359-file run.

@rubencu

rubencu commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 2356a1ba1c; the new head is c88e386669. There was one conflict, the security package line budget in test/test_security_gate_liveness.py:

  • Main fix(security): extend native config write tier #23935 (native config write tier) raised the budget by 12, from 32,601 to 32,613, for the crewmate folder's state files in paths_lists. Main's note and this PR's note are both kept, and this PR's note now reads "Raised again, from 32,613". The package now measures 32,987 lines: main's 32,613 plus this PR's unchanged 374. The pin is now 32,987.

The rest of the patch merged without conflicts, including docs/system-specs/modules/security.md beside main's edits: the other 8 paths have the same diff as on 7dd99ebcb5.

Tests, run on 2356a1ba1c:

@rubencu

rubencu commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 6b1b65d to clear a conflict with #24392 in test/test_security_gate_liveness.py. Main raised _PACKAGE_LINE_BUDGET from 32,613 to 32,616 for the enterprise install-tree write fence, and this PR raised it for the pako branch. The resolution keeps both notes, restarts this PR's note from 32,616 and pins the measured total, 32,990 lines (this PR's 374 on top of main's 32,616). No code changed, and the rest of the patch is identical.

@rubencu

rubencu commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 9e0f854 on 63c0cfc. It fixes GPT's fenced finding on 493474a (redaction_entropy.py:848). Both JSON views re-escaped a tab inside a decoded value, so Bearer and its token never appeared apart. The value checked on its own had also lost its Authorization label.

_mermaid_pako_views now also checks each string value beside its decoded key with nothing escaped ("key":"value"), inside the same 1,024-view cap. test_an_escaped_tab_cannot_split_a_bearer_value_from_its_label fails on 493474a and passes here, in batch and when streamed. The view-cap fixtures count the new view, and the security spec names it.

The rebase also resolved the _PACKAGE_LINE_BUDGET conflict with #23840. Main's note stays first, this PR's note now starts from 32,635, and the measured total is 33,015.

@rubencu

rubencu commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main to resolve a conflict in test/test_security_gate_liveness.py: since the last push, #24896, #20487, #25175 and #25445 raised the package budget from 32,635 to 32,798.

This push also fixes the GPT review finding on text_redaction.py. A Bearer value glued ahead of a pako route (Authorization: Bearer <opaque>/https://mermaid.live/edit#pako:…) streamed raw when the payload's eyJ arrived after the hold began, for example in 7-byte deltas. Main fails closed on that input.

  • StreamRedactor.feed now ends the hold of a run glued ahead of its route when an eyJ with a byte after it reaches the run (_late_jwt_anchor). Normal scanning then applies the 4,096-byte JWT ceiling and the fail-closed discard, as on main. A run that opens at the route keeps its ride.
  • A glued run is not held while its route, payload or tail holds an eyJ, so it is not held again after that release.
  • test_a_bearer_header_glued_to_a_jwt_bearing_link_never_streams_its_value now also runs in 7-byte deltas, with the eyJ early in the payload (inside main's 512-byte floor) and late. test_an_eyj_ending_a_delta_still_ends_the_hold ends a delta right after eyJ. test_a_label_glued_to_a_jwt_bearing_link_fails_closed, renamed from …_in_one_large_delta_fails_closed, also runs in 7-byte deltas. All five new cases fail on 9e0f854.
  • The package budget is 33,204, which is main's 32,798 plus this PR's 406 lines, 26 of them for this fix. The measured total is 33,204 lines.

@rubencu

rubencu commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

On review 5624890509 (crew-pr-reviewer):

  • Items 2 and 3 are answered in this comment. Since then the view cap became one budget shared by every pako link in a call (comment), and the item-3 budget conflict has been re-resolved on each rebase, most recently in acefe14.
  • Item 1 asks for two public tracking issues for the main-side gaps it lists. SECURITY.md asks that a potential security issue is reported privately rather than opened as a public GitHub issue. Maintainers, which channel do you want: public issues as the review asks, or a private report per SECURITY.md? Nothing will be opened, and no further detail added here, until you choose.

The First Principles lane could not run on acefe14 (GitHub API rate limit), and Sensitive Change Review still needs a maintainer's attestation.

@rubencu

rubencu commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 3e4b528, rebased onto main 3cdcfe893c. The rebase resolved one conflict in test/test_security_gate_liveness.py: main raised _PACKAGE_LINE_BUDGET to 32,799, so this PR's budget is now 33,205 (main's value plus this PR's 406 lines), which equals the measured package total. The rest of the patch is unchanged.

On 9fb1d4aa52, the PR's tests, the tests main changed since 4efafcf60f, the composition contracts and the static gates passed (7,382 tests); the only failures also fail on main on this host. After the final re-sync onto 3cdcfe893c, main's newly changed test file and the composition contracts pass again.

@rubencu

rubencu commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 203a9ce3 (head 5008d006). One conflict, in test/test_security_gate_liveness.py: main raised the security package line budget to 32,802 (#23855). This PR's own increment is unchanged (406 lines), so the pin is now 33,208, the measured total. Main's budget paragraphs stay whole and this PR's paragraph follows them. No code change.

@rubencu

rubencu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 8789418f (head fd89cab0). Conflicts, each resolved by keeping both sides:

No behavior change beyond the merge.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 274fc00, rebased onto main 0b18d86432. The rebase resolved a conflict in docs/system-specs/modules/security.md: #30279 added a sentence to the ?token= parameter line directly below the Mermaid pako paragraph this PR adds, and both are kept. The PR's own diff is unchanged.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 9c79576, rebased onto main 02a1152510. The rebase resolved a conflict in test/test_security_gate_liveness.py: #30662 raised _PACKAGE_LINE_BUDGET by one, to 34,524, for the Railway consent host, and this PR raised it from 34,523 by 406 lines. Both are kept: main's comment line stays, the budget is now 34,930, and this PR's comment says it was raised from 34,524. The rest of the PR's diff is unchanged.

@rubencu

rubencu commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 8c3587d, rebased onto main 7325afe29c. The rebase resolved conflicts in four files, keeping both sides:

  • redaction.py: main's _document_link_spans now takes the pass-4 prefix snapshot and hands it to the PlantUML check. This PR's pako check sits beside it unchanged, and the facade manifest lists main's two Outlook names and this PR's two JSON helpers.
  • text_redaction.py: the stream redactor keeps main's structured-detector state and this PR's pako hold state. flush still releases a held pako run into the buffer first, then takes main's reset path, and held still reports a held pako run first.
  • security.md: the bullet carries both main's Outlook webLink clause and this PR's Mermaid pako clause.
  • test_security_gate_liveness.py: the budget is 36,204, main's 35,804 plus this PR's 400 lines, re-measured, and the comment's measured numbers are updated to match.

Nothing else changed.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

This PR exempts only validated Mermaid Live #pako: links from the pass-3 entropy heuristic. A link qualifies only after the following checks: an exact lowercase address, canonical base64url, a bounded single zlib stream, and strict JSON with a string code. Every decoded view and its check-only variant must also pass the full URL-and-credential pass, under shared byte and view budgets. The earlier blocking finding (a live exempt-host read outside the display cache's snapshot) is fixed: the nested check now passes exempt_hosts=frozenset(). exfil.py treats that as a complete snapshot, so no host is exempt (fail-closed), and a new test pins one host-list read per render. The display cache's version list now covers the new modules. The stream hold keeps _buf empty while chunks are held, and flush, reset and the held property are handled. Exceeding the cap or tail limit rejoins the ordinary path, which fails closed for JWTs. A credential crossing the cut or a late eyJ ends the hold. Passes 1, 2 and 4 are unchanged, and the regex regrouping leaves the other link types identical. All touched files are under the 1,600-line target. I found no concrete regression or data-loss path

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 299b947cc6 · 1431 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed f8fab4f, rebased onto main b7a4e1e70c.

  • Conflict: main's perf: show a reply's last plain sentence word with its own chunk #36196 raised the security package budget to 35,824. The budget is now 36,244 (main's 35,824 plus this PR's 420 lines), and the PR's comment now says it was raised from 35,824.
  • The same push also includes one fix inside this PR's own change. Display redaction caches each render under one read of the pass-4 token-parameter prefix set, and the PlantUML scan already judges a diagram under that read. The pako check now does the same: compose and _credential_spans take the snapshot, and _mermaid_pako_verdict judges every decoded view under it. A render can no longer be cached under one prefix set while its link was judged under another. test_display_redaction_prefix_snapshot.py gains pako cases that fail without the change (the tightened case served the link in plaintext under a set that masks it). 20 of the 420 budget lines are this change.

No other code, test or description changed.

@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author
  • span=50b2215ffa8d — fixed

Fixed in eba1ea5: the pako verdict's nested composed scan now runs with no exempt host (compose(..., exempt_hosts=frozenset())), so it makes no live host read that the display cache's key does not cover, and a diagram URL that only a host exemption would keep voids the link (fails closed). compose and _url_spans take the URL pass's host set and hand it to redact_exfiltration_urls_with_records. test_a_pako_link_is_judged_under_no_exempt_host renders a pako link whose diagram URL sits on an allowed host and asserts one host read and the masked output; it fails on f8fab4f with five reads.

@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author
  • span=be5fce1c4c0f — fixed

Fixed in eba1ea5, as you suggested: the pako verdict's nested composed scan now runs with no exempt host (compose(..., exempt_hosts=frozenset())), so it makes no live host read that the display cache's key does not cover, and a diagram URL that only a host exemption would keep voids the link (fails closed). compose and _url_spans take the URL pass's host set and hand it to redact_exfiltration_urls_with_records. test_a_pako_link_is_judged_under_no_exempt_host renders a pako link whose diagram URL sits on an allowed host and asserts one host read and the masked output; it fails on f8fab4f with five reads.

@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed eba1ea5, rebased onto main ff344c78ec.

  • Review fix (GPT span 50b2215ffa8d, Opus span be5fce1c4c0f): the pako check's nested composed scan read the exempt-host set live, outside the one read the display cache keys a render on. _mermaid_pako_verdict now passes exempt_hosts=frozenset() to compose, so a diagram URL that only a host exemption would keep voids the link (fails closed). compose and _url_spans take the URL pass's host set. test_a_pako_link_is_judged_under_no_exempt_host fails without the change (five host reads instead of one).
  • The security package budget is now 36,256: main's 35,824 plus this PR's 432 lines. Main's six new commits touch no file in this PR.
  • The security spec's pako paragraph, and the description's What changed, scope table and Tests, now state the no-exempt-host rule.

No other code or test changed.

Validate Mermaid Live pako state before exempting its opaque payload from bare-secret redaction. Keep streamed candidates bounded and reassemble terminating bytes so credentials cannot cross an emission boundary.
@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 299b947, rebased onto main 9807bdd5d5.

  • Conflict: main's feat(app-kit): let an app's manifest fence its own dirs from agent writes #33589 raised the security package budget from 35,824 to 35,901. The budget is now 36,364 (main's 35,901 plus this PR's 463 lines), and the PR's comment says it was raised from 35,901.
  • Split: this PR took security/redaction.py from 1,551 to 1,655 lines, and AGENTS.md says a change that takes a file past 1,600 lines splits it in the same PR. The pako verdict code (_mermaid_pako_verdict, _pako_view_unchanged, _pako_check_variant and the three _PAKO_CHECK_* constants) moves unchanged into a new owner module, security/redaction_pako.py, behind the redaction facade, so redaction.py is 1,586 lines. kiro_crew.security.redaction stays the import path of every moved name. The module is listed in _OWNERS and the facade's TYPE_CHECKING rows, the facade test's owner table, display_battery.RULE_SOURCES and the security spec's owner list. 31 of the budget's 463 lines are this split.
  • The redaction, pako and display tests pass unchanged. The description's What changed, file table and Tests name the new module.

No behavior changed.

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

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge needs-author-decision PR blocked on author input readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants