Repository navigation
fix(chat): key the display-redaction cache on the prefix set pass 4 judged under - #22455
cruisercohen wants to merge 2 commits into
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: one prefix-set snapshot now feeds both the cache key and pass 4, which fixes the root cause, the double read. Nothing is taken away, and every Notes
[DESIGN-REVIEWED] 29258e0 Description read[DESCRIPTION-READ] 545a3662c64350449df7f911010c18818a92cb9a045e945644e75f06ccd593f6 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix is at the cause: both the cache key and pass 4 now use one read of the prefix set. It follows the snapshot the same function already takes for the exempt hosts. Two red-on-base tests back it, and issue #22388 is linked. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: a chat render never caches an approval-link verdict that was judged under a different token-prefix set than its key names. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 29258e0 Description read[DESCRIPTION-READ] 761658c96e953395f0257c5bfa75f4e428f0b300d967da0eedd615bb92dc58a4 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Sensitive change review
|
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: No regression is confirmed. The only thing that got stricter is a display-redaction cache, and the shell classifier can't check that. Every shell-tier caller of TIGHTENING: Pass 4 of display redaction (the token-parameter exemption) now runs under the same prefix-set snapshot as the cache key -- it refuses a cache entry computed under one prefix set and stored under another set's key, which would let a token stay in plain text after the set is emptied: " ADJUDICATED: 11 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: Candidates cover posix and windows. The diff assumes nothing about paths, separators, interpreters or executable names; its only new input is the prefix tuple, which passes the platform-neutral
No platform the diff assumes is left without a candidate. UNADJUDICATED: The guard is pass 4 of
I can argue that (a)–(c) keep working: with the prefix set unchanged, one read gives the same tuple the old two reads gave. That is reasoning, not a confirmed result. [SCOPE-REVIEWED] 29258e0 |
723963a to
5480f6f
Compare
Review dispositions for 5480f6f
|
Sensitive change review
|
Sensitive change review
|
|
Hold at This PR changes which token-parameter prefix set decides whether a I found no defect. The cache key and the battery now take one read of the set (chat_utils_display.py#L488-L518). A snapshot goes through the same shape gate as the live read, stream suspension still wins, and every other caller keeps the live read. Checks on this head are green. Also open: the Security Scope Review on this head is CONCERNS, with five display-path inputs it could not adjudicate, and there is no — crew-pr-reviewer (r115) |
|
8159db7 to
07bed9e
Compare
11c85d2 to
483c838
Compare
|
@iamwhatever two short questions on your r116 hold (human review of the redaction behaviour):
Since r116 on 07bed9e the head moved once, to 483c838 (10-22), a rebase onto main's exempt-host snapshot. |
…udged under _redact_for_display read the pass-4 token-parameter prefix set once for the cache key and again inside redact_credentials, including the nested credential scan of a PlantUML diagram's source. When the platform read moved between the reads, output computed under one set was cached under the other set's key. Read the set once and hand the same snapshot to the key, to pass 4 and to the diagram scan. Fixes #22388
483c838 to
29258e0
Compare
|
Hold at 29258e0 for human review of redaction behaviour, as in r115 and r116.
KiroCrew/src/kiro_crew/security/redaction.py Line 1319 in 29258e0 I found no defect. KiroCrew/src/kiro_crew/dashboard/chat_utils_display.py Lines 514 to 518 in 29258e0 On @cruisercohen's two questions: a repository maintainer with write access needs to review it, and I cannot pick one. Nothing else blocks. The branch is mergeable, and auto-merge is armed, so the human approval is the only remaining gate. — crew-pr-reviewer (r143) |
|
[operator: bolichen97] Continuing this in #32252; thanks for the start. |
A chat message shown again from the display cache could carry a different redaction than a fresh render under the settings in force at that moment. The cached and the fresh result now always agree. Builds on #22455. Closes #22388 (cherry picked from commit bab2387) Original author: Bolin Chen (#32252). Hand-resolved, tests only: test/test_security_gate_liveness.py raises release's own package line budget by this commit's 39 lines (34,548 -> 34,587) with its comment; main's separate +10 re-measure is not carried.
Pull request was closed
Problem / Motivation
Goal: A chat render never shows a companion approval link's
?token=value in plaintext, or as[REDACTED], because the display cache stored output judged under a different token-parameter prefix set than the one its key names._redact_for_display(dashboard/chat_utils_display.py) memoizes the display battery, keyed on the text, the exempt-host set and the pass-4 token-parameter prefix set (CredentialPolicy.token_param_exempt_url_prefixes). It reads the prefix set twice: once in_display_redaction_cache_keyand again insideredact_credentials(pass 4,security/redaction.py). The platform read can move between the two (a companion loads, a policy tightens) and degrades every failure to the empty set. When the key read sees the empty set and the pass-4 read sees the prefix, the approval link is kept and filed as a clean verdict under the empty-set key, so every later render under the empty set shows the token value. The reverse order serves[REDACTED]for an exempt link.Confirmed on
main754421e3b5: both regression tests below fail there.Why it matters
The display cache fronts every chat render and feeds the persistent verdict store, so one read that moves mid-call poisons a hot entry. In one direction a
?token=value the settled policy redacts is shown; in the other an exempt approval link the user has to click is hidden.Not a goal
_redact_for_display, so whichever merges second takes a small rebase._redacted_previewandwire_render._context_digestkeep their own key reads (theNonedefault).redact_credentials_with_recordsand the streaming path are unchanged.What changed (motivation → approach → change)
Root cause: two independent reads of a set that can move between them, feeding a key and a battery that must agree. Change: ONE snapshot feeds both.
_redact_for_displayreads_token_param_exempt_prefixes()once and hands that value to_display_redaction_cache_key(..., token_param_prefixes=...)and todisplay_battery(..., token_param_prefixes=...). It is the value the key digested before, so every key and stored verdict tag is byte-identical tomainfor the same set._display_redaction_cache_keygains a keyword-onlytoken_param_prefixes;Nonereads the set as before.display_batteryandredact_credentialsgain an optional keywordtoken_param_prefixes. When supplied it replaces pass 4's lazy live read, and the credential pass hands it on to the nested scan of a PlantUML diagram's source (_document_link_spans->_plantuml_verdict->redact_credentials(source, ...)), so a diagram that carries an approval link is judged under the same set as the text around it. A snapshot goes through the same shape gate as the live read (_well_formed_token_param_prefixes, now shared by both), so it cannot exempt a URL the live read could not, and the streaming-window suspension still pins the set empty over a snapshot.None, the default for every other caller, is the live read.No redaction rule is widened or narrowed: pass 4 judges under the set it would read itself, read once instead of twice.
display_battery.pyandredaction.pyare rule sources, so the rules version moves once and stored verdicts are recomputed once.Backwards compatibility
Compatible: only optional keywords whose
Nonedefault keeps the live read; nothing is renamed or removed.Removes nothing: the diff adds optional parameters and one private helper, and every existing call keeps its behaviour.
Tests
New
test/test_display_redaction_prefix_snapshot.py(11 tests):test_an_entry_is_keyed_on_the_prefix_set_the_battery_judged_under: first readALLOWED, later reads empty, then settles atALLOWED; the warm render must equal the battery output underALLOWED. RED onmain(served[REDACTED: credential]), green here.test_a_tightened_set_mid_call_never_serves_plaintext: the reverse order; RED onmain(served the token value), green here.test_the_prefix_set_is_read_exactly_once_per_call: 1 read cold, 1 read warm (2 cold onmain).test_a_diagram_entry_is_keyed_on_the_set_its_scan_judged_underandtest_a_diagram_scan_takes_the_snapshot_and_performs_no_live_read: the same race through a PlantUML link whose source holds the approval link; red without the diagram-scan threading (served the diagram in plaintext after the set emptied), green here.test_the_key_digests_the_snapshot_it_is_handed,test_the_battery_takes_the_snapshot_and_performs_no_live_read,test_a_snapshot_passes_the_live_reads_shape_gate(with an ungated control showing it is the gate that drops the member),test_the_stream_suspension_still_wins_over_a_snapshot,test_the_default_path_still_reads_live,test_the_fixture_turns_on_the_prefix_set.Adjusted: the
redact_credentialswrappers intest_chat_utils.pyandtest_display_verdicts.py, and the_display_redaction_cache_keywrapper intest_slot_render_context_key.py, forward keyword arguments.test_security_gate_liveness.pyre-pins_PACKAGE_LINE_BUDGET31,509 -> 31,548 with the reason beside it.Runs: the new file 11 passed. 71 related files (redaction, exfil, PlantUML links, display, chat_utils, facade mirrors, security gate liveness, token-param deferral, slot render memo): 3488 passed, 1 skipped; 19 more files that call the display path (slot render key, slot detail, chat history and pagination, decisions gate): 1218 passed.
black,isort,flake8,mypy(3 source files),check_comment_history.py(baseorigin/main) andcheck_file_line_cap.pyclean.The race tests on main 754421e (no fix)
Manual verification
N/A — unit coverage sufficient: backend-only change with no user-visible dashboard state of its own; the race is pinned by the unit tests above.
Screenshots / video
N/A — no user-visible frontend surface is touched.
Related Issues
Fixes #22388
Pattern harvest
Rule candidate: review-prompt
Pattern: a memo keyed on mutable state read by the key function AND re-read by the memoized function; the two reads can disagree, so pass the key's snapshot into the function.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.