Skip to content

fix(security): redact a two-segment link token that follows a '.' - #23293

Merged
bolichen97 merged 1 commit into
mainfrom
fix/redact-link-token-after-dot-21550
Oct 24, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/redact-link-token-after-dot-21550

Conversation

@JLargent42

@JLargent42 JLargent42 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The credential redactor removes a two-segment link token the same way whether it starts the text, follows a space, or follows a ., while a dotted member chain of the same lengths stays intact.

The two-segment link-token alternative in the credential pattern had a left boundary that included .. A token right after a . (prefix.<token>, see .<token>) was kept in full, while the same token at the start of a text or after a space was removed. A streamed reply hit the same split: a per-delta pass removed the token when a delta started with it, but the whole-text pass kept it.

Why it matters

Any reply that holds such a token right after a . is saved, copied and posted with the token in it. The dashboard chat save works around it today by withholding the reply.

Not a goal

What changed (motivation → approach → change)

The . was in the boundary to keep dotted code intact. The lengths alone cannot do that: a chain such as config.eyJ<long member>.<43-char member>(x) has the token's exact shape. So in security/redaction_patterns.py the lookbehind now covers letters, digits and -/_, and a start guard decides what follows a .. There the token starts a match only when it carries what an identifier chain never does:

  • a - in either segment, or
  • a payload shaped as base64url of ASCII JSON: every fourth character from the fifth on is A-Z or a-f, because it encodes the top six bits of an ASCII byte. Every generate_token payload is ASCII JSON, since json.dumps escapes non-ASCII.

Each guard arm reads one segment once, so the scan stays linear. The stdlib copy of the pattern in the prepare-pr skill's _review_contract.py and the owning spec, docs/system-specs/modules/security.md, are updated to match; in _review_contract.py the alternative is wrapped in (?-i:…), because that file's regex runs under (?i) and the payload-shape class must stay case-sensitive as it is in the backend. test/test_redaction_mirror_parity.py now tells the two JWT alternatives apart by the {2,4} repetition and splits the two-segment one at its payload floor, so the frontend mirror is still pinned on the body and exempt only on the boundary.

Backwards compatibility

Compatible: against main the redactor removes more, never less. At every position not right after a . the alternative is unchanged; after a . it now also removes a token that passes the guard. Dotted member chains are kept, as on main.

Removes nothing: no path, record, key or function is removed.

Tests

test/test_link_token_dot_boundary.py, with neutral fixtures:

  • the filler token is removed at the start, after a space, after prefix., after a lone ., and after a sentence's . with no space;
  • 200 minted tokens are each removed after obj., and a fixed ASCII-JSON payload with a fixed --free signature is removed after obj., so the payload-shape arm is covered without depending on a random nonce;
  • a full-length dotted chain (eyJ plus a 102-character member, then a 43-character member) is kept after config., self.cache. and a lone ., followed by (x), nothing, .close() or = None;
  • shorter dotted identifiers after a . are kept;
  • the prepare-pr script's redact() keeps the same dotted chain (member lengths covering every remainder mod 4) and still removes a fixed token after obj.; 9 of those cases fail against the previous _review_contract.py;
  • 400,000-character runs after .eyJ are scanned under a 60 s timeout.

The 12 dotted-chain cases fail on the previous head and pass now. Disabling the ASCII-JSON arm fails both of those tests; disabling the - arms fails the three filler after-. cases and the chat-save test below.

test/test_chat_runner_coverage.py: two save-guard tests used a token after . as their example of a value only a per-delta pass removes, and the fix stops that example producing one. test_each_removed_value_is_checked_on_its_own now uses two glued tokens (#21595) and still fails closed, through the saved-text check. test_a_record_holding_a_value_only_a_per_delta_pass_removed_fails_closed now uses a token glued to a word (q=prefix<token>), still asserts the flush fails closed, and fails when the flush's _records_hold_removed_credential call is disabled. test_a_link_token_in_a_blocked_link_query_is_saved_in_neither_text_nor_record is added for the after-. case: the token is in neither the saved text nor the link record. No credential-redaction test changes.

220 redaction, credential, security, URL-check, stream, prepare-pr and chat-runner test files plus test_redaction_mirror_parity.py: 13551 pass, including the security package line budget. isort, flake8, mypy, docs-lint and comment-history are clean.

Manual verification

N/A — unit coverage sufficient: the change is the start guard of one regex alternative, exercised directly, with minted tokens, and through the streamed-save path.

Related Issues

Closes #21550

Sibling sweep

Swept: git grep -n "eyJ[A-Za-z0-9_-]{96,}" -- src/ website/src/
Sibling: src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-prepare-pr/scripts/_review_contract.py -- changed here
Sibling: website/src/utils/sanitize.ts -- not affected -- it carries no start boundary at all, so it already removes these tokens; the parity test pins its body.

Pattern harvest

Not generalizable: the guard reads properties of this one generator's output (base64url of ASCII JSON), and the parity test already pins the mirror.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners October 23, 2026 02:49
@JLargent42
JLargent42 requested a review from mbriones98 October 23, 2026 02:49
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: f86d12d
  • What rule changed: the left boundary of the two-segment link-token alternative in security/redaction_patterns.py changes from (?<![A-Za-z0-9_.-]) to (?<![A-Za-z0-9_-]); the stdlib mirror in the prepare-pr skill's _review_contract.py and docs/system-specs/modules/security.md match.
  • Before -> after (what was allowed/blocked, now): before, a token of this shape right after a . was kept in full, while the same token at the start of a text or after a space was redacted. After, it is redacted in all three positions. A letter, digit, - or _ right before eyJ still keeps it from matching inside a longer word.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): over-redaction of text that has a . before an eyJ run of at least 96 base64url characters, a ., and exactly 43 more. Dotted identifiers and file names are kept by those lengths, and test/test_link_token_dot_boundary.py pins that. Nothing is redacted less than before.
  • Evidence checked (which sandbox result proves it): N/A, no sandbox rule or command floor is touched. Redaction behaviour is checked by test/test_link_token_dot_boundary.py (the three after-. cases fail against main's pattern and pass here) and by the security suites below.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed; the streamed chat-save path is covered by test_chat_runner_coverage.py (all pass), including the save guard's record check, which fails when that call is disabled.
    • Backward compatible (old config / old data / old callers still work, how checked): yes; the pattern removes a superset of what it removed before, and no config, stored data or call signature changes.
    • Existing tests (which suites passed on this head): test_security.py, test_security_stream_redaction.py, test_chat_runner_coverage.py, test_link_token_dot_boundary.py, test_redaction_mirror_parity.py, test_security_gate_liveness.py (815 passed); flake8, black, isort, comment-history, docs-lint clean.
  • How to undo: revert the PR; the boundary, its mirror, the spec text and the tests come out together.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/redaction_patterns.py

  • @JLargent42 posted a complete reasoning template for 89354d2.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns. The redactor now removes more than before, the change takes nothing away, and nothing in it is platform-specific.

Notes

  • The JWS branch already accepts a match only when its first segment decodes to a JSON object, and every pass-1 consumer runs that check. Sending this alternative's after-. matches through the same check would be an exact test instead of a regex that guesses the payload shape.

[DESIGN-REVIEWED] 89354d2

Description read

[DESCRIPTION-READ] bf573361413e7269f5eb9b8ad1df3d190472dca9acf4b08ffc715d87101279e0

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 Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2 — 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: this fixes a linked defect (#21550) where the redactor already decides what gets removed. All three copies of the pattern are accounted for.

What this change ships

Inventory (6 items) — 6 justified

Intent: stop a dashboard link token from surviving redaction when it comes right after a ., so replies holding one are no longer saved, copied or posted with the token in them. FIX.

  1. A link token right after a . is now removed the same way as one at the start of a text or after a space — justified
  2. Dotted member chains of the same lengths are still kept, through a guard on what follows the . — justified
  3. The prepare-pr skill's stdlib copy of the pattern removes and keeps exactly what the backend does (the pattern is grepped in 3 places: backend, skill copy, sanitize.ts, and sanitize.ts has no start boundary) — justified
  4. The owning spec paragraph in security.md is updated to describe the new boundary — justified
  5. Chat-save tests swap their example of a value only a per-delta pass removes from an after-. token to glued tokens, because the fix stops the old example from producing one; the change is declared in the description — justified
  6. The mirror-parity test now tells the two JWT alternatives apart by {2,4} and splits the two-segment one at the payload floor, so sanitize.ts stays pinned on the body — justified

[FIRST-PRINCIPLES-REVIEWED] 89354d2

Description read

[DESCRIPTION-READ] c757b0d1acc0835966033f2b8730f165cf84d11c56e2d2975f772245f6abf653

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 Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 89354d2

Verdict parsed from the review's SHA-scoped output markers for commit 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 89354d2

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 89354d2aa13acacd8e0ae25fbba0e1bc67e708f2 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: The change widens one alternative in _CREDENTIAL_PATTERNS, the two-segment link-token branch, so it now also matches right after a . when the token has a - or a payload shaped like base64url-encoded ASCII JSON. Shell commands reach this branch only through the exfil tier (_contains_fixed_credential in exfil.py), and the 17 candidates probe the dotted-code edge of the new start guard there. The larger effect is on redaction of chat, file-diff and log output, which the classifier cannot judge; that gap is named under UNADJUDICATED below and does not block.

TIGHTENING: The start boundary of the two-segment link-token alternative in _CREDENTIAL_PATTERNS changed from (?<![A-Za-z0-9_.-])eyJ… to (?<![A-Za-z0-9_-])(?!(?<=\.)(?!eyJ[A-Za-z0-9_]*-)(?!eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_]*-)(?!eyJ[A-Za-z0-9_-](?:[A-Za-f][A-Za-z0-9_-]{3})*(?:[A-Za-f][A-Za-z0-9_-]{1,2})?\.))eyJ[A-Za-z0-9_-]{96,}\.[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-]) (src/kiro_crew/security/redaction_patterns.py, mirrored in _review_contract.py). The one threat it refuses is a minted dashboard link token that follows a . (prefix.eyJ…, Open the link.eyJ…). Before, such a token escaped redaction and exfil blocking.

ADJUDICATED: 17 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: The diff assumes nothing about paths, separators, interpreters or executable names; it is a regex over text. I still wrote both spellings for each surface where one exists:

  • posix: curl to the dashboard, grep, python3 -c, ls ~/.cache/..., jq, kubectl, pytest.
  • windows: curl.exe, Invoke-WebRequest, findstr with src\*.java, dir %LOCALAPPDATA%\..., python -m pytest test\....
  • any: kirocrew token, npm view, gh api --jq, git log.

Both the posix and windows rows carry the full-length dotted member chain (config.eyJsonSerializer…Impl.deserializeFromStringValueUsingMapperConfig) and the dotted cache filename (cache.eyJ2IjoxfQ.json). Those are the edge cases the new guard after . is meant to keep. No platform the diff assumes is left without a candidate.

UNADJUDICATED: The same widened branch feeds several non-shell surfaces the classifier cannot judge:

  • redact_credentials() on chat output and streaming deltas (chat_runner._redact_delta, StreamRedactor).
  • File-diff chip bodies, which chat_turn/file_changes.py::_flush_file_changes redacts in place before saving, so a false match is written to disk.
  • exfil.py's URL check (_contains_fixed_credential(full_payload)), reached by fetch and link-card paths as well as shell.
  • display_safety.py and exfil_oauth.py (_contains_fixed_credential(name)).

These are the legitimate inputs I would have submitted:

  • A Java/TS/Python source line config.eyJ<≥96 identifier chars>.<43-char member>(x) where an identifier carries a -. That can't happen in Java or Python code, but a kebab-case CSS module or i18n key accessed as messages.eyJ…-… could, and the - arm of the guard would now redact it in place.
  • A dotted identifier chain after . whose payload happens to have one of A-Z/a-f at every fourth position from the fifth on, over 96+ characters. For real identifiers this is very unlikely.
  • A dashboard link-card URL whose path segment follows a . (for example …/r?q=prefix.<token>). The new test expects this to be withheld, and it should be.

None of these can be confirmed without a redaction-surface classifier. The narrowing I can argue but not confirm is the - arm: it accepts any - anywhere in either segment, not only in the token's own payload shape.

[SCOPE-REVIEWED] 89354d2

@JLargent42

Copy link
Copy Markdown
Contributor Author

Backend Tests (Windows) (7): test_sibling_list_check.py::test_a_heading_is_found_exactly_when_the_template_check_finds_it fails on other heads that do not touch it too (#23257, #23277); open fix #23264 skips that bash cross-check on Windows. Not caused by this diff.

@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 Oct 23, 2026
@JLargent42
JLargent42 force-pushed the fix/redact-link-token-after-dot-21550 branch from f86d12d to ce70eba Compare October 23, 2026 06:33
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main for the #23264 Windows fix.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ce70eba
  • What rule changed: the left boundary of the two-segment link-token alternative in security/redaction_patterns.py changes from (?<![A-Za-z0-9_.-]) to (?<![A-Za-z0-9_-]); the stdlib mirror in the prepare-pr skill's _review_contract.py and docs/system-specs/modules/security.md match.
  • Before -> after (what was allowed/blocked, now): before, a token of this shape right after a . was kept in full, while the same token at the start of a text or after a space was redacted. After, it is redacted in all three positions. A letter, digit, - or _ right before eyJ still keeps it from matching inside a longer word.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): over-redaction of text that has a . before an eyJ run of at least 96 base64url characters, a ., and exactly 43 more. Dotted identifiers and file names are kept by those lengths, and test/test_link_token_dot_boundary.py pins that. Nothing is redacted less than before.
  • Evidence checked (which sandbox result proves it): N/A, no sandbox rule or command floor is touched. Redaction behaviour is checked by test/test_link_token_dot_boundary.py (the three after-. cases fail against main's pattern and pass here) and by the security suites below.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed; the streamed chat-save path is covered by test_chat_runner_coverage.py (all pass), including the save guard's record check, which fails when that call is disabled.
    • Backward compatible (old config / old data / old callers still work, how checked): yes; the pattern removes a superset of what it removed before, and no config, stored data or call signature changes.
    • Existing tests (which suites passed on this head): test_security.py, test_security_stream_redaction.py, test_chat_runner_coverage.py, test_link_token_dot_boundary.py, test_redaction_mirror_parity.py, test_security_gate_liveness.py (1021 passed on this head); flake8, black, isort, comment-history, docs-lint clean.
  • How to undo: revert the PR; the boundary, its mirror, the spec text and the tests come out together.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 23, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 23, 2026

@bolichen97 bolichen97 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.

HOLD

Removing the dot boundary makes the secret redactor consume valid dotted identifier chains. A member shaped as eyJ plus a long base64url name, followed by a second 43-character member, is redacted even though it is ordinary code. The new compatibility test never builds that two-segment shape, so it passes before and after the change.

Please add the exact dotted-chain regression and retain or replace the boundary with a discriminator. If this over-redaction is intentional, document and explicitly approve that contract.

[Security: the change closes a real token-redaction gap, but it also alters stored and displayed non-secret content while claiming compatibility. No new secret exposure was found.]

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 23, 2026
@JLargent42
JLargent42 force-pushed the fix/redact-link-token-after-dot-21550 branch from ce70eba to 84fb52c Compare October 23, 2026 16:45
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 84fb52c
  • What rule changed: the two-segment link-token alternative in security/redaction_patterns.py keeps the lookbehind (?<![A-Za-z0-9_-]) and adds a start guard right after a .: there the token starts a match only when a segment holds a - or the payload is shaped as base64url of ASCII JSON. The stdlib mirror in the prepare-pr skill's _review_contract.py and docs/system-specs/modules/security.md match.
  • Before -> after (what was allowed/blocked, now): on main a token of this shape right after a . is kept in full. After, a token that passes the guard (every minted token does) is redacted there as at the start of a text; a dotted member chain of the same lengths is kept, as on main. At every position not right after a . the alternative is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a token after a . that is neither ASCII-JSON-shaped nor carries a - stays unredacted, as on main; generate_token cannot produce one (json.dumps output is ASCII), pinned by a 200-mint test. Nothing is redacted less than on main.
  • Evidence checked (which sandbox result proves it): N/A, no sandbox rule or command floor is touched. test/test_link_token_dot_boundary.py pins the dotted-chain cases (12 fail on the previous head), the minted-token and filler after-. cases, and a linear-time scan under a timeout; disabling either guard arm turns a test red.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed; the streamed chat-save path is covered by test_chat_runner_coverage.py (all pass).
    • Backward compatible (old config / old data / old callers still work, how checked): yes; against main the pattern removes a superset, and no config, stored data or call signature changes.
    • Existing tests (which suites passed on this head): 220 redaction, credential, security, URL-check, stream, prepare-pr and chat-runner test files plus test_redaction_mirror_parity.py, 13551 passed, including the security package line budget; flake8, isort, mypy, comment-history, docs-lint clean.
  • How to undo: revert the PR; the guard, its mirror, the spec text and the tests come out together.

@JLargent42

Copy link
Copy Markdown
Contributor Author

@bolichen97 thanks, the finding held. Addressed in 84fb52c (one commit, same base):

  • Regression added: test_a_full_length_dotted_member_chain_is_kept builds the exact two-segment chain (eyJ plus a 102-character member, then a 43-character member) after config., self.cache. and a lone ., followed by (x), nothing, .close() or = None. All 12 cases fail on ce70eba and pass now.
  • Boundary replaced with a discriminator: the lookbehind no longer admits . on its own. Right after a . the token starts a match only when it carries what an identifier chain cannot: a - in either segment, or a payload shaped as base64url of ASCII JSON (every fourth character from the fifth is A-Z/a-f). Every generate_token payload is ASCII JSON, so a new test mints 200 tokens (with and without - in the signature) and checks each is removed after obj.. Disabling either arm of the guard turns a test red, and a 400,000-character run after .eyJ scans under a timeout.
  • Mirror and spec: _review_contract.py carries the same alternative byte for byte; security.md and the parity helper describe the guard. The PR body and the Sensitive Change Review template are updated for the new head.

@JLargent42
JLargent42 requested a review from bolichen97 October 23, 2026 16:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 23, 2026

@bolichen97 bolichen97 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.

Re-review at 84fb52c. The issue in my earlier review on ce70eba is fixed: a dotted member chain with the token's exact lengths (config.eyJ<102 char member>.<43 char member>(x)) is kept again, and test_a_full_length_dotted_member_chain_is_kept pins that shape.

What I checked on this head:

  • The start guard reads correctly. After a ., a match starts only when the payload or signature holds a -, or every fourth payload character from the fifth on is in A-Za-f. That second property is true for base64url of ASCII bytes, and generate_token encodes its payload with the default ASCII json.dumps.
  • Each guard arm reads at most two segments from one start, and only at a position right after a ., so the scan stays linear.
  • origin/main still has the old (?<![A-Za-z0-9_.-]) boundary, so this change is not superseded.
  • test/test_link_token_dot_boundary.py, test/test_redaction_mirror_parity.py and test/test_chat_runner_coverage.py pass locally on this head (122 passed).
  • The _review_contract.py copy has the same pattern as the backend, and website/src/utils/sanitize.ts has no start boundary, so it is not affected.

On the GPT lane finding at test/test_link_token_dot_boundary.py:98: the assertion fails only if all 200 minted tokens fall in one category. Each token has no - with a probability of about one half, so the chance per run is near 2 x 0.5^200. I read this as not a real flake risk, but a maintainer has to decide on that lane.

One small comment inline. Nothing blocks from my side.

Status: this touches the redaction patterns, so it needs a maintainer approval. That approval and the GPT lane decision are still open, and some test shards were still running when I checked.

@@ -31,7 +31,8 @@
# HMAC-SHA256 digest), the payload bound is a generator-derived floor rather
# than a guess (a guessed floor is beatable by a verbose identifier), and the
# left boundary (incl. `.`, so attribute access is excluded) keeps ordinary

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.

🟡 This comment still says the left boundary includes .

# left boundary (incl. `.`, so attribute access is excluded) keeps ordinary
# dotted code intact unless what follows the `.` carries a `-` or a payload

The lookbehind is now (?<![A-Za-z0-9_-]), so it no longer includes .. A reader of this copy can think attribute access is still excluded by the boundary itself.

Suggestion: Reword it to match the backend comment: the lookbehind covers letters, digits, - and _, and a guard after a . keeps obj.eyJ... code unless the token has a - or a payload shaped as base64url of ASCII JSON.

@JLargent42
JLargent42 force-pushed the fix/redact-link-token-after-dot-21550 branch from 84fb52c to 3c3f8ea Compare October 23, 2026 17:43
@JLargent42

Copy link
Copy Markdown
Contributor Author
  • span=86febadc0204 test/test_link_token_dot_boundary.py: signature-category assertion depends on random nonces

Fixed in 3c3f8ea. The assertion that 200 mints include both signature categories is removed. The payload-shape arm is now covered by a fixed case: a fixed claim set in the generator encoding plus a fixed 43-character signature with no -, redacted after obj.. That test fails when the payload-shape arm is disabled and passes with it on; the 200-mint loop remains as an outcome check that holds for every mint.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 3c3f8ea
  • What rule changed: the two-segment link-token alternative in security/redaction_patterns.py keeps the lookbehind (?<![A-Za-z0-9_-]) and adds a start guard right after a .: there the token starts a match only when a segment holds a - or the payload is shaped as base64url of ASCII JSON. The stdlib mirror in the prepare-pr skill's _review_contract.py and docs/system-specs/modules/security.md match. This head changes only a test.
  • Before -> after (what was allowed/blocked, now): on main a token of this shape right after a . is kept in full. After, a token that passes the guard (every minted token does) is redacted there as at the start of a text; a dotted member chain of the same lengths is kept, as on main. At every position not right after a . the alternative is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a token after a . that is neither ASCII-JSON-shaped nor carries a - stays unredacted, as on main; generate_token cannot produce one (json.dumps output is ASCII). Nothing is redacted less than on main.
  • Evidence checked (which sandbox result proves it): N/A, no sandbox rule or command floor is touched. test/test_link_token_dot_boundary.py pins the dotted-chain cases, a fixed ASCII-JSON payload with a --free signature, minted tokens, filler after-. cases and a linear-time scan under a timeout; disabling either guard arm turns a test red.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed; the streamed chat-save path is covered by test_chat_runner_coverage.py (all pass).
    • Backward compatible (old config / old data / old callers still work, how checked): yes; against main the pattern removes a superset, and no config, stored data or call signature changes.
    • Existing tests (which suites passed on this head): test_link_token_dot_boundary.py (26 passed) on this head; the 220-file redaction/credential/security/stream/prepare-pr/chat-runner selection passed on the previous head (13551), and this head changes only that test file.
  • How to undo: revert the PR; the guard, its mirror, the spec text and the tests come out together.

@bolichen97 bolichen97 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.

Re-review at 3c3f8ea.

Fixed since 84fb52c: the probabilistic assertion in test_minted_link_tokens_after_a_dot_are_redacted is gone, and the new test_an_ascii_json_payload_without_a_dash_is_redacted_after_a_dot pins the base64url-of-ASCII arm with fixed input. I checked that it is a real pin: with that arm removed from the pattern, the test's token is no longer matched after a ..

Still blocking: the copy in _review_contract.py is compiled inside _SECRET_RE, which starts with (?i). Under that flag the new [A-Za-f] class matches every letter, so the shape guard passes for any all-letter member. I reproduced it on this head: config. + an eyJ... member of 100, 102, 103, 104, 106 or 107 letters + .deserializeFromStringValueUsingMapperConfig(x) is redacted by the review script's redact() and kept by redact_credentials. This is the same dotted-chain over-redaction my earlier review raised, now only in the mirror. test_redaction_mirror_parity.py compares the pattern text, so it cannot see a flag difference.

Also still open: the stale boundary comment at _review_contract.py:33 from my previous review.

What I ran on this head: test/test_link_token_dot_boundary.py, test/test_redaction_mirror_parity.py and test/test_chat_runner_coverage.py (123 passed), plus the reproduction above. This PR changes redaction code, so approval will come from a maintainer, not from this review.

# boundary is satisfied by a `.` and would leave `.signature` in the printed
# log. That shape is covered by a test.
r"|(?<![A-Za-z0-9_.-])eyJ[A-Za-z0-9_-]{96,}\.[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])"
r"|(?<![A-Za-z0-9_-])(?!(?<=\.)(?!eyJ[A-Za-z0-9_]*-)(?!eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_]*-)(?!eyJ[A-Za-z0-9_-](?:[A-Za-f][A-Za-z0-9_-]{3})*(?:[A-Za-f][A-Za-z0-9_-]{1,2})?\.))eyJ[A-Za-z0-9_-]{96,}\.[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])"

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.

🔴 The ASCII shape guard is case-insensitive in this copy

_SECRET_RE is compiled from r"(?i)(...", so in this alternative [A-Za-f] matches every letter. The guard that should keep obj.eyJ... code then passes for any all-letter member whose length mod 4 is 0, 2 or 3, and the match starts after the ..

r"|(?<![A-Za-z0-9_-])(?!(?<=\.)...(?!eyJ[A-Za-z0-9_-](?:[A-Za-f][A-Za-z0-9_-]{3})*...

Reproduced on this head: config. + a 102-letter eyJ... member + .deserializeFromStringValueUsingMapperConfig(x) becomes config.[REDACTED](x) through redact(), while redact_credentials keeps it unchanged. The verbatim text check in test_redaction_mirror_parity.py passes because the text is identical; only the flags differ.

Suggestion: wrap this alternative in (?-i:...) so it is case-sensitive like the backend, and add a behavior test that runs the dotted member chain cases through this script's redact() as well as redact_credentials.

Rule: two copies of a security pattern must behave the same, and a parity test should check behavior, not only text.

@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 Oct 23, 2026
@JLargent42
JLargent42 force-pushed the fix/redact-link-token-after-dot-21550 branch from 3c3f8ea to 89354d2 Compare October 23, 2026 21:14
@JLargent42

Copy link
Copy Markdown
Contributor Author
  • src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-prepare-pr/scripts/_review_contract.py:44: the copy's payload-shape check runs under the regex's global (?i)

Fixed in 89354d2. The two-segment alternative in _review_contract.py is now wrapped in (?-i:…), so it is case-sensitive like the backend copy; the inner text is still byte-identical to security/redaction_patterns.py and the mirror parity test passes. New tests in test/test_link_token_dot_boundary.py load the script's redact() and check that config. + the long member (lengths covering every remainder mod 4) + a 43-character member is kept by both copies, and that a fixed token after obj. is still removed by the script. Against the old _review_contract.py, 9 of those cases fail; with the fix all pass.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 89354d2
  • What rule changed: the two-segment link-token alternative in security/redaction_patterns.py keeps the lookbehind (?<![A-Za-z0-9_-]) and adds a start guard right after a .: there the token starts a match only when a segment holds a - or the payload is shaped as base64url of ASCII JSON. The stdlib mirror in the prepare-pr skill's _review_contract.py and docs/system-specs/modules/security.md match. This head wraps the mirror's copy in (?-i:…) so it stays case-sensitive inside that file's (?i) regex, and adds tests for that copy.
  • Before -> after (what was allowed/blocked, now): on main a token of this shape right after a . is kept in full. After, a token that passes the guard (every minted token does) is redacted there as at the start of a text; a dotted member chain of the same lengths is kept, by the backend and by the review script alike. At every position not right after a . the alternative is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a token after a . that is neither ASCII-JSON-shaped nor carries a - stays unredacted, as on main; generate_token cannot produce one (json.dumps output is ASCII). Nothing is redacted less than on main.
  • Evidence checked (which sandbox result proves it): N/A, no sandbox rule or command floor is touched. test/test_link_token_dot_boundary.py pins the dotted-chain cases for both copies, a fixed ASCII-JSON payload with a --free signature, minted tokens, filler after-. cases and a linear-time scan under a timeout; 9 review-script cases fail against the previous _review_contract.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed; the prepare-pr script tests (test_prepare_pr_*.py, test_pr_status_owners.py, test_pr_readiness_evaluate.py) pass on this head.
    • Backward compatible (old config / old data / old callers still work, how checked): yes; against main the backend pattern removes a superset, and no config, stored data or call signature changes.
    • Existing tests (which suites passed on this head): 2937 passed across the dot-boundary, mirror-parity, prepare-pr, PR-status, readiness, security-gate-liveness and redaction test files.
  • How to undo: revert the PR; the guard, its mirror, the spec text and the tests come out together.

@bolichen97 bolichen97 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.

Re-review at 89354d2.

Fixed since 3c3f8ea: the two-segment alternative in _review_contract.py is now wrapped in (?-i:...), so [A-Za-f] is case-sensitive again inside the (?i) regex. The new test_the_review_script_copy_keeps_the_same_dotted_chains compares behaviour, not pattern text, across all four member lengths mod 4, and test_the_review_script_copy_redacts_a_token_after_a_dot keeps the positive case. I checked that these tests are a real pin: with the 3c3f8ea copy of _review_contract.py restored, 9 of them fail; on this head test_link_token_dot_boundary.py and test_redaction_mirror_parity.py pass (51 tests). This also covers the dotted-chain over-redaction from my first review, so I am dismissing my two earlier change requests.

One small thing left, inline: the comment at _review_contract.py:33 still says the left boundary includes .. It does not block.

Security path change, so approval stays with a maintainer.

@@ -31,7 +31,8 @@
# HMAC-SHA256 digest), the payload bound is a generator-derived floor rather
# than a guess (a guessed floor is beatable by a verbose identifier), and the
# left boundary (incl. `.`, so attribute access is excluded) keeps ordinary

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.

🟡 This comment still says the left boundary includes .

# left boundary (incl. `.`, so attribute access is excluded) keeps ordinary

The lookbehind is (?<![A-Za-z0-9_-]), which does not include .. Attribute access is kept by the guard that runs after a ., not by the boundary. A reader of this copy can think the boundary itself still excludes attribute access.

Suggestion: say that a start after a . is checked by the guard that follows, which is what keeps attribute access.

Rule: comments must describe the code as it is.

@bolichen97
bolichen97 dismissed stale reviews from themself October 23, 2026 22:03

Fixed at 89354d2: the mirror alternative is case-sensitive again and behavioural tests pin it.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 24, 2026

@bolichen97 bolichen97 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.

Approving head 89354d2. Verified on this head: readiness label passed, PR Readiness green, all review lanes and required checks green (cancelled runs were superseded by later green runs), no open change requests. Queuing squash auto-merge pinned to this head.

@bolichen97
bolichen97 enabled auto-merge (squash) October 24, 2026 02:04
@bolichen97
bolichen97 merged commit da11bc5 into main Oct 24, 2026
164 of 175 checks passed
@bolichen97
bolichen97 deleted the fix/redact-link-token-after-dot-21550 branch October 24, 2026 02:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 24, 2026
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.

Credential redactor keeps a link token that follows a '.'

2 participants