Repository navigation
fix(chat): key the display-redaction cache on the host set the battery judged under - #16544
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the key and the battery now judge under a single read of the host set, so a cached entry always matches the set its key names. Notes
[DESIGN-REVIEWED] 51adf3b Description read[DESCRIPTION-READ] 9cb89829787978e541ac9eef49c69a081235926bf2297d1f6525301d9ce392f9 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 Nothing blocks. The fix reads the host set once and passes that one copy to both the cache key and the battery. That removes the gap between two reads, which is what let the cache store output under the wrong key. Inventory (6 items) — 6 justifiedIntent: stop chat renders from showing an exempt link as
[FIRST-PRINCIPLES-REVIEWED] 51adf3b Description read[DESCRIPTION-READ] b93ead29a71776bf4ba93e38131bc5dce9a3f194cb0ec2e83b1d4761f0fb9bb9 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: |
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: Nothing in this change makes a refusal stricter. It is a consistency fix in the dashboard's display-redaction cache: the exempt-host set is now read once, and that one copy is used both for the cache key and by the redaction pass that produces the cached output. The live-read default path in TIGHTENING: the display redaction pass's exempt-host input ( ADJUDICATED: 10 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The diff assumes nothing new about paths, separators, interpreters, executable names or environment variables. It only adds a keyword argument and a lowercasing step to a set of hostnames. I still wrote rows in three spellings to cover the exfil tier near the edited function:
No platform assumption in the diff is left without a candidate. UNADJUDICATED: The guard is the display redaction pass's exempt-host decision, not the shell deny composite. The call path: dashboard render →
Reading the code, I found no path where a legitimate link is newly redacted. The values that previously came from two separate reads now come from one. But this is reasoning, not a verdict. [SCOPE-REVIEWED] 51adf3b |
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: |
Review dispositions (updated in place)Security Scope Review — CONCERNS (advisory, exit 0) on
Also covered from the previous head's list: default-path callers passing no snapshot ( No redaction rule moved; the diff changes which READ feeds the battery, not what the battery does with it. |
53a5478 to
c1a8564
Compare
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
c1a8564 to
e997be3
Compare
Sensitive change review
|
Review dispositions for e997be3
|
|
HOLD on e997be3. Two things stand: this touches the redaction path, which is reserved for human review, and one check is red. The fix looks correct. To clear the hold:
— crew-pr-reviewer (r114) |
dodgeblaster
left a comment
There was a problem hiding this comment.
Steward review for #13482 (T1/T2 sweep). Verified the fix against current origin/main and read every changed file.
The bug is still live on main. _display_redaction_cache_key reads _exempt_exact_hosts() | current_scoped_exempt_hosts() for the key, and redact_exfiltration_urls_with_records re-reads _exfil_exempt_hosts() | _SCOPED_EXEMPT_HOSTS.get() independently — two reads of a set that can move (or degrade a failure to frozenset()) between them, so output computed under one set can be stored under another set's key.
The fix is correct and does not widen what is exempted.
_redact_for_displaynow takes ONE snapshothosts = _exempt_exact_hosts() | current_scoped_exempt_hosts()and hands the SAME object to both_display_redaction_cache_key(text, base, hosts)anddisplay_battery(text, exempt_hosts=hosts). Key and battery provably judge under the same set.- The new
exempt_hostskeyword onredact_exfiltration_urls/_with_recordsreplaces the live read rather than adding to it, and lowercases the snapshot (frozenset(h.lower() ...)) exactly as_exfil_exempt_hosts()does — so the snapshot path reproduces the live path's set element-for-element.extra_exempt_hostsstill joins on top either way. - The default (
exempt_hosts=None) branch is byte-identical tomain: every other caller is untouched. Confirmed no redaction rule, threshold, or host carve-out is relaxed; the only change is that the two reads become one. test/test_display_redaction_host_snapshot.pypins the contract both directions (a transient failure after the key read never serves[REDACTED]for an exempt host under the stable set; a tightened set after the key read never serves plaintext), asserts one read per call, and asserts a supplied snapshot suppresses the battery's live read.
CI: every required check is green on head e997be3c except Sensitive Change Review, which is red only because the sensitive-path reasoning template has not been posted for this head — not a code defect.
To merge, two things remain, both outside what a steward can do:
- @NicholasRBowers (author): post the filled
## Sensitive change reviewtemplate as a PR comment naming heade997be3c59b58b3e92a3214451016eb0a2c02994(or a reviewer folds it into an Approve review on this head). That clears the gate within ~a minute, no push needed. - A human approving review (
reviewDecisionisREVIEW_REQUIRED).
I'm not approving or merging: the final approval and the security-gate template are the author's/maintainer's to supply, and this is a same-repo PR I did not author. Once (1) and (2) land with all checks green and no admin bypass, it's ready to squash-merge.
e997be3 to
81b721a
Compare
|
@NicholasRBowers I rebased this onto latest Sensitive Change Review counts only the author's comment or a reviewer's Approve review. Could you repost the filled form below as your own comment? Or a maintainer can paste it into an Approve review on this head. I am not posting it as an approval myself. |
…y judged under `_redact_for_display` read the exempt-host set twice: once in `_display_redaction_cache_key` and again inside the battery (`display_battery` -> `redact_exfiltration_urls` -> `_exfil_exempt_hosts`). The platform read can move between the two (a companion loads, a policy tightens) and degrades every failure to the empty set, so a transient failure on the battery's read alone stored maximally-redacted output under the full set's key, and every later hit served `[REDACTED]` for an exempt host. The reverse order served a plaintext link after the set emptied. One snapshot now feeds both: `_redact_for_display` reads `_exempt_exact_hosts() | current_scoped_exempt_hosts()` once (the same expression the key digested before, so every key is byte-identical), hands it to `_display_redaction_cache_key(text, base, hosts)` and to `display_battery(text, exempt_hosts=hosts)`. `redact_exfiltration_urls` and `redact_exfiltration_urls_with_records` gain an optional `exempt_hosts` keyword that replaces the live platform read and the scoped override; `None`, the default for every other caller, is the live read. Tests: regressions in both directions (red on main, green here), one read per call, scoped-override composition, key and battery taking no live read when handed a snapshot, lowercase matching, the additive set, and the default path. Security package line budget re-pinned 32,097 -> 32,111. Closes #13482 Co-authored-by: iamwhatever <iamwhatever@users.noreply.github.com>
81b721a to
51adf3b
Compare
|
@NicholasRBowers I rebased this onto latest Sensitive Change Review counts only the author's comment or a reviewer's Approve review. Could you repost the filled form below as your own comment? Or a maintainer can paste it into an Approve review on this head. I am not posting it as an approval myself. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Review lanes PASS; the hold was advisory (a downgraded GPT 6.1 finding, a security-checklist item, or a missing reasoning template). The watch holder read the hold and approved explicitly.
Problem / Motivation
Goal: A chat render never shows a link as
[REDACTED], or in plaintext, because the display cache stored output judged under a different exempt-host set than the one its key names._redact_for_display(src/kiro_crew/dashboard/chat_utils_display.py) memoizes the display battery keyed on the text and the exempt-host set, but it reads that set twice: once in_display_redaction_cache_key(_exempt_exact_hosts() | current_scoped_exempt_hosts()) and again inside the battery (display_battery->redact_exfiltration_urls->_exfil_exempt_hosts()). The platform read can move between the two (a companion loads, a policy tightens) and degrades every failure to the empty set. A transient failure on the battery read alone stores maximally-redacted output under the full set key, and every later hit, including the persistent verdict store, serves[REDACTED]for an exempt host. The reverse order serves a plaintext link after the set empties.Confirmed on
main17404da26: both regression tests below fail there.Why it matters
The display cache fronts every chat render and now also feeds the persistent verdict store. One transient failure on one read poisons a hot entry, and the symptom (an exempted tenant link shown as
[REDACTED]) reads as a policy bug. It is a cache-correctness race on a security-area path.Not a goal
_token_param_exempt_prefixes) is also read by the key and again insideredact_credentials. Same class, different input; left for a follow-up so this diff stays on the host set named in chat: display-redaction cache reads the exempt-host set twice #13482._redacted_previewkeeps its own key reads; it already re-checks the digest before filing an entry.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_exempt_exact_hosts() | current_scoped_exempt_hosts()once (the exact expression the key digested before, so every key and stored verdict tag is byte-identical tomain) and hands it to_display_redaction_cache_key(text, base, hosts)and todisplay_battery(text, exempt_hosts=hosts)._display_redaction_cache_keygains an optional third positionalexempt_hosts;Nonereads the set as before (used bywire_render._context_digestand_redacted_preview).display_battery,redact_exfiltration_urlsandredact_exfiltration_urls_with_recordsgain an optional keywordexempt_hosts. When supplied it replaces the live platform read and the scoped override; hosts are lowercased either way (RFC 4343);extra_exempt_hostsjoins either way.None, the default for every other caller, is the live read.No redaction rule is widened or narrowed: the set the battery judges under is the same set it would read itself, read once instead of twice.
display_battery.pyandexfil.pyare rule sources, so the rules version moves once and stored verdicts are recomputed once.This is a port of the original change onto the
chat_utils_display/display_batteryowner modules that landed after this PR was opened.Backwards compatibility
Compatible: only optional parameters with defaults that keep the live read. Nothing is removed or renamed. Keys are byte-identical to
mainfor the same host set.Tests
New
test/test_display_redaction_host_snapshot.py(9 tests):test_an_entry_is_keyed_on_the_set_the_battery_judged_under: first readALLOWED, later reads empty, then settles atALLOWED; the warm render must equal the battery output underALLOWED. RED onmain, green here.test_a_tightened_set_mid_call_never_serves_plaintext: the reverse order; RED onmain(served plaintext), green here.test_the_host_set_is_read_exactly_once_per_call: 1 read cold, 1 read warm (red on main).test_the_key_digests_the_snapshot_it_is_handed: key takes no live read when handed a snapshot, and equals the default-read key for the same set.test_the_snapshot_carries_the_scoped_override,test_the_battery_takes_the_snapshot_and_performs_no_live_read,test_the_snapshot_is_lowercased_like_the_live_set,test_extra_exempt_hosts_still_joins_a_snapshot,test_the_default_path_still_reads_live.Adjusted: wrappers in
test_chat_utils.py,test_display_verdicts.pyandtest/perf/slot_render_bench.pyforward the new argument.test_display_redaction_source_guard.pycounts reads through both bindings and pins exactly one per call.test_security_gate_liveness.pyre-pins_PACKAGE_LINE_BUDGET31,509 -> 31,523 with the reason beside it.Determinism: the new file passed 5 repeats, a shuffled order (seed 7) and
-n 4.Runs: the 10 directly related files 171 passed.
scripts/run_scoped_tests.py --surface backend: 8585 passed, 12 failed; the same 12 (test_cli.py::TestDoctor*, onetest_auto_improvement_members, onetest_sel_chain_hardening) fail identically onmainin this sandbox (environment: scratch path under~/.kiro/crew, no gateway).black,isort,flake8,mypy(3 source files),check_comment_history.py,check_file_line_cap.pyclean.Manual verification
N/A — unit coverage sufficient: backend-only change with no user-visible dashboard state; the race is pinned by the unit tests above.
Screenshots / video
N/A — no user-visible frontend surface is touched.
Related Issues
Closes #13482
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 snapshot into the function.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
N/A — placeholder pending OSPO wording.