Skip to content

fix: name the rule that refused an environment credential command - #34992

Merged
bolichen97 merged 1 commit into
mainfrom
fix/34526-env-cred-refusal-names-rule
Nov 20, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/34526-env-cred-refusal-names-rule

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A refusal from the always-on environment credential check names the rule that refused the command, in the refusal message and in every security event that stores the refusal text.

When this check refuses a shell command, every one of its rules answers with the same sentence: "Blocked: command reads AWS credentials from environment variables". A user who believes a refusal is wrong cannot tell which rule matched, so they cannot check it against their command or report it precisely (#34526).

Why it matters

The check cannot be switched off, so its refusal text is all a user gets. A refusal that names no rule looks the same whether it is right or wrong, and the usual reaction is to re-spell the command until it passes.

Not a goal

What changed (motivation → approach → change)

A refusal from this check says which rule refused the command, so a user who thinks it is wrong can check that rule against the command and report it by name. The first line of the refusal stays exactly as it is. Under it, the refusal adds the Refusal diagnostic: line the size-ceiling refusal already carries: the rule id (the catalog id when the rule has one), the matched span as offsets, and a character-class count, never the matched text. A security event that stores the refusal text, as a background turn's does (a cron run, a workflow agent), names the rule as well, and the debug view files those rows as denied-rule refusals instead of unclassified. The security spec says which refusals of this gate carry that line, and a row in test/security_line_budget/ raises the line budget of the src/kiro_crew/security package by three, this change's own growth.

Backwards compatibility

Compatible: the first line of the refusal is unchanged, and the added line has the format the debug view already reads.
Removes nothing: the check refuses exactly the commands it refused before.

Tests

  • One parametrized shell-gate test: for every rule of the check, the two commands from Env-credential deny rule blocks commands that only mention "env" and "AWS" as text #34526 included, the refusal keeps its first line and its diagnostic names that rule.
  • The tool-argument shell-gate test compares the refusal's first line exactly, because the refusal has two lines.
  • Determinism: the changed tests passed 20 runs at -n0, 10 runs at -n 4 --dist loadgroup beside test/test_security_denied_commands.py and test/test_denied_commands_security.py, and one shuffled order (seed 2264350906).

Proof: PROVEN test/test_security_bash_gate.py::TestARefusalNamesItsRuleAndSpan::test_an_env_credential_refusal_names_which_rule_fired[env | grep AWS_SECRET-credential-exfil-env-grep-aws], test/test_security_bash_gate.py::TestARefusalNamesItsRuleAndSpan::test_an_env_credential_refusal_names_which_rule_fired[printenv AWS_SECRET_ACCESS_KEY-credential-exfil-printenv-aws], test/test_security_bash_gate.py::TestARefusalNamesItsRuleAndSpan::test_an_env_credential_refusal_names_which_rule_fired[declare -p AWS_SECRET_ACCESS_KEY-keystone-env-cred-declare], test/test_security_bash_gate.py::TestARefusalNamesItsRuleAndSpan::test_an_env_credential_refusal_names_which_rule_fired[echo $AWS_SECRET_ACCESS_KEY-keystone-env-cred-echo], test/test_security_bash_gate.py::TestARefusalNamesItsRuleAndSpan::test_an_env_credential_refusal_names_which_rule_fired[awk 'BEGIN{print ENVIRON["AWS_SECRET_ACCESS_KEY"]}'-keystone-env-cred-awk-environ] (head ef348876ce0d)

Manual verification

On Linux (Python 3.12), through the real shell gate (is_sensitive_bash_command), with an isolated KIROCREW_HOME:

$ env | grep AWS_SECRET
Blocked: command reads AWS credentials from environment variables
Refusal diagnostic: rule=credential-exfil-env-grep-aws component=env-credential span=0..21 shape=len=21,seen=21,upper=9,lower=7,digit=0,sep=0,space=3,symbol=2,other=0

printenv, declare -p and echo of AWS_SECRET_ACCESS_KEY name credential-exfil-printenv-aws, keystone-env-cred-declare and keystone-env-cred-echo the same way, and no diagnostic carries the matched text, only its offsets and a character-class count. The two commands from #34526 are still refused, by keystone-env-cred-interpreter and credential-exfil-env-awk-sed-aws. ls -la and git status are still allowed.

Real-machine verification

Machine: EC2 m7i.2xlarge, Ubuntu 24.04 x86_64, 8 vCPU / 32 GiB, Python 3.12.3, no inbound rules
Before (main c0d672b): prove.py, which puts main's code back under the five rule-naming tests listed under Tests -> PROVEN: an assertion failed with the bug reintroduced; on main the check returns only the first line, so no refusal names its rule
After (tree 245987d506c7, this patch on main c0d672b; head 6e5d3f9 is the same patch on 3688176): the same five tests pass, and env | grep AWS_SECRET through is_sensitive_bash_command -> Blocked: command reads AWS credentials from environment variables then Refusal diagnostic: rule=credential-exfil-env-grep-aws component=env-credential span=0..21 ..., as under Manual verification
Cleanup: the run's worktree and isolated data home were deleted; the instance is a shared short-lived verification host that keeps serving other runs and is terminated once idle, so it was not terminated for this PR

Screenshots / video

N/A — no frontend change.

Related Issues

Part of #34526

Sibling sweep

Siblings: none -- the size-ceiling refusal already names its rule, and the IMDS refusal names the spelling it matched.

Pattern harvest

Not generalizable: this was the one refusal of the gate that shares a fixed sentence across several rules.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • 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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 11, 2026 01:49
@bolichen97
bolichen97 requested a review from Zedmor November 11, 2026 01:49
@bolichen97
bolichen97 enabled auto-merge (squash) November 11, 2026 02:17
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/denied_rules.py

  • @bolichen97 posted a complete reasoning template for 6e5d3f9.

@bolichen97
bolichen97 force-pushed the fix/34526-env-cred-refusal-names-rule branch from 0dfab42 to 583eefa Compare November 11, 2026 12:10
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md, test/test_security_gate_liveness.py since this head went green (fd016ef -> 7db81f6); CI re-running.

The rebase clears a merge conflict in both files: the security spec keeps the sentences main added to the same bullet, and the package line budget is re-measured on the new base. The earlier run on 0dfab42 did not finish its review and test lanes because GitHub API rate limits cut it short, so its reds say nothing about the code.

[operator: bolichen97]

@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 Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 6e5d3f967790a417be6e66d6221b6b179977f185 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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 6e5d3f967790a417be6e66d6221b6b179977f185 — 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. The change reuses the existing refusal_diagnostic/annotate_refusal (security/diagnostics.py) for the one refusal of this gate whose rules all share a single first line (#34526). It also makes true a claim the base spec already made ("Each refusal carries a refusal_diagnostic").

What this change ships

Inventory (5 items) — 5 justified

Intent: let a user whose shell command was refused by the always-on environment-credential check see which rule refused it, so they can check or report it. FIX.

  1. An environment-credential refusal now has a second line, Refusal diagnostic:, naming the rule id, the span offsets and the character-class shape — justified
  2. The four keystone-only patterns now have names (keystone-env-cred-*), and the diagnostic line shows them — justified
  3. Security events that store the refusal text name the rule too, and the debug view files them as denied-rule refusals instead of unclassified — justified
  4. The spec no longer says the IMDS refusal carries a diagnostic, and says which refusals of this gate do — justified
  5. The security package line budget goes up by 3, recorded in test/security_line_budget/ — justified

[FIRST-PRINCIPLES-REVIEWED] 6e5d3f9

Description read

[DESCRIPTION-READ] 2d36df44c97cce7ac83aaacc734e011c7c50324a59337dafb26137715e595cb9

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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the refusal reuses the existing refusal_diagnostic/annotate_refusal seam that the size-ceiling refusal already uses, its first line is unchanged, and the gate refuses exactly the same commands as before.

Notes

[DESIGN-REVIEWED] 6e5d3f9

Description read

[DESCRIPTION-READ] be19d13bce3aefcc53967be12bd3af51d2680d821033ad5a4a37aafe481414f8

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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 6e5d3f967790a417be6e66d6221b6b179977f185 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6e5d3f9

Verdict parsed from the review's SHA-scoped output markers for commit 6e5d3f967790a417be6e66d6221b6b179977f185.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 6e5d3f967790a417be6e66d6221b6b179977f185 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 6e5d3f967790a417be6e66d6221b6b179977f185 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6e5d3f9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 6e5d3f967790a417be6e66d6221b6b179977f185 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 071a698c45e598ab81130ad5e8bbadca047976b6 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): 10 classified, 0 newly refused, 10 still allowed.
  • ubuntu-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • windows-latest (platform windows): 4 classified, 0 newly refused, 4 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: This change only adds a diagnostic line. _check_env_credential_access returns the same first-line refusal on the same matches as before, now followed by a refusal_diagnostic line naming the rule id. No pattern, rule, or match condition changed, and annotate_refusal leaves an empty (allowed) reason as it is, so nothing new can be refused. The two over-blocks pinned in the new test (a grep for _ENV_DUMP_GREP_AWS|… caught by keystone-env-cred-interpreter, and a heredoc caught by credential-exfil-env-awk-sed-aws) were already refused on the base; the PR only records them. They are known narrowing work, not new regressions.

TIGHTENING: env-credential tier diagnostic (sensitive-bash, denied_rules._check_env_credential_access) -- no new threat is refused. The hunk only replaces the bare return with an annotated one: diagnostic = refusal_diagnostic(rule.id, "env-credential", command) / return annotate_refusal(_ENV_CRED_DENIAL_REASON, diagnostic), and _ENV_CRED_PATTERNS becomes a dict keyed by keystone-env-cred-* ids holding the same four regexes, unchanged.

ADJUDICATED: 14 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix and windows. The diff adds no assumptions about paths, separators, interpreters or executable names; the regexes are byte-identical to the base. Posix rows probe the non-secret neighbours of each rule (env | grep KIROCREW_, printenv AWS_REGION, echo $AWS_PROFILE, declare -p PATH, awk ENVIRON["HOME"], a python3 -c read of os.environ). Windows rows cover the %VAR% echo, a .venv\Scripts\python.exe interpreter read, and the aws sts get-caller-identity check, because the interpreter rule matches python\S*, which a .exe name also satisfies. No assumed platform is left without a probe.

[SCOPE-REVIEWED] 071a698

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

KiroCrewCaptain commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 7% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

Adds a Refusal diagnostic: line to environment-credential refusals so each one names the rule that fired, using the existing refusal_diagnostic/annotate_refusal helpers. The first line is unchanged, and the check refuses exactly the same commands (same regexes, matcher and order, now held in an ordered dict). Rule ids pass _DIAGNOSTIC_ID_RE. Every caller of is_sensitive_bash_command already handles a multi-line refusal from this gate, as it does for the size-ceiling refusal. The only other exact-match test already compares just the first line. The debug view's classifier and its rule-id reader handle the new line. The only reader of _ENV_CRED_PATTERNS is the test this PR updates. The line-budget bump of 3 matches the net source change. The new parametrized test fails without the change. The two rows from #34526, which the PR's proof list leaves out, were traced by hand to the expected rules: the interpreter regex crosses the newline, and the fragment matcher matches across lines for the awk/sed rule.

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 57944a3993 · 79 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 11, 2026
@bolichen97
bolichen97 force-pushed the fix/34526-env-cred-refusal-names-rule branch from 583eefa to 5f6fb4e Compare November 11, 2026 22:35
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md, test/test_security_gate_liveness.py since this head went green (7db81f6 -> 2df02ab); CI re-running.

The rebase clears a merge conflict in the security package's line budget: main raised it three times since the last base, and this change's three lines sit on top of main's figure, re-measured on the new base. The security spec merged without a conflict and keeps this change's wording.

[operator: bolichen97]

@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 readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 11, 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 Nov 12, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed on head 68b4d4d. The env-credential tier now appends one refusal diagnostic line that names the rule that fired. The first line of the refusal stays byte-identical. We checked that the four patterns are unchanged and keep their order after the list-to-dict change, that every new rule id passes the diagnostic id filter, and that every caller of is_sensitive_bash_command handles the two-line reason. We also checked that the debug view now files these rows as denied-rule refusals and that the line budget rise matches the measured +3 lines. Reverting the fix reds 7 tests. The touched test files pass locally (751 passed).

Security: this touches the denied-command tier, but only the refusal text changes. Every command that main refuses is still refused, and nothing new is refused or allowed. The added line carries offsets and character counts, never the matched bytes.

Done well: the parametrized test pins one row per rule, including both over-blocks from #34526. A later narrowing therefore has to change a test row on purpose.

Optional:

  • Also assert the span= field in test_an_env_credential_refusal_names_which_rule_fired. Dropping match.span() keeps every test green today.
  • The Sensitive Change Review check still needs the filled reasoning template for head 68b4d4d.
  • One line in the body could say that the spec also stops claiming the IMDS refusal carries a diagnostic, because it never did.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 12, 2026
@bolichen97
bolichen97 force-pushed the fix/34526-env-cred-refusal-names-rule branch from 68b4d4d to 57944a3 Compare November 13, 2026 02:54
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md, test/test_security_gate_liveness.py since this head went green (029b6db -> a02e90c); CI re-running.

The rebase clears the merge conflict in the security package's line budget: main raised it twice, to 35,804 and then 35,824, and this PR's three lines put it at 35,827, the package's re-measured size. The security spec merged cleanly. The change itself is unchanged.

[operator: bolichen97]

@github-actions github-actions Bot added 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: passed Eligible automated validation passed for the current revision labels Nov 13, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

The review found no blocking issue on this head. It cannot be approved yet because PR Readiness is red on 57944a3.

What the review checked on this head:

  • Line 1 of every environment-credential refusal is byte-identical to main. The diagnostic is added on its own line through the existing refusal_diagnostic / annotate_refusal helpers.
  • The set of refused commands is unchanged. Every regex is the same, and the dict keeps the old order and first-match behaviour.
  • The diagnostic line carries only rule and component ids, offsets and a character-class count. All seven ids pass the id screen.
  • Callers that test the result for truth or read line 1 still work. The debug view now files these rows as denied_rule.
  • The line budget rises by exactly the measured growth (35,824 to 35,827 lines).
  • The touched test files pass on this head. With the source reverted to the merge-base, all seven rows of the new parametrized test fail.

Done well: the PR reuses the payload-free diagnostic format other refusals already use, so no second format appears. The two #34526 over-block rows are pinned on purpose and say so in the test.

Why it waits: the AI review lanes, Security Scope and Sensitive Change Review failed on this head because of a GitHub API rate limit, not because of the code. The lane verdicts on record are for the previous head, which carries the same code. Those lanes need a rerun, Sensitive Change Review needs its reasoning or an approval on this head, and then readiness needs a new run. A maintainer will take it from there.

Optional:

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

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md, test/test_security_bash_gate.py, test/test_security_gate_liveness.py since this head went green (a02e90c -> 5672158); CI re-running.

The rebase clears the merge conflict in the security package's line budget. Main now takes each change's raise as its own row under test/security_line_budget/, so this PR adds one row of +3 and no longer edits test/test_security_gate_liveness.py. In the security spec, main had extended the same paragraph; this PR's sentence is applied on top of main's text. Main's edits to test/test_security_bash_gate.py and to the rest of the security package apply cleanly. The change itself is unchanged.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/34526-env-cred-refusal-names-rule branch from 57944a3 to 8c06190 Compare November 17, 2026 21:38
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Answers to the three optional notes in the review of 57944a3, one per note:

  • Proof line. It is the line prove.py printed for this head, pasted unchanged. The two Env-credential deny rule blocks commands that only mention "env" and "AWS" as text #34526 rows it does not list ran with the other five in this head's determinism runs (20 at -n0, 10 under -n 4 --dist loadgroup, one shuffled order). The body's "The security spec says which refusals of this gate carry that line" covers the IMDS sentence.
  • Span on the keystone refusals. Left as is on purpose. The goal is naming the rule, and the test pins the rule id on every row. The offsets come from the shared refusal_diagnostic helper, so an exact-offset check per rule would pin each regex's match boundaries rather than this change.
  • Shared _PACKAGE_LINE_BUDGET line. It is no longer shared. This head raises the budget through its own row, test/security_line_budget/env-credential-refusal-rule.txt, and does not edit test/test_security_gate_liveness.py, so another PR's raise cannot conflict with it.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md since this head went green (5672158 -> 256d5af); CI re-running.

The rebase onto current main applied cleanly and the change itself is unchanged. Main also changed other files of the security package in that range; none of them is on the refusal path this PR changes, and the package's line budget still holds with this PR's +3 row. On the previous head every check was green except Sensitive Change Review, which needs a sensitive-change review recorded for the new head, and PR Readiness, which folds it in, so no code fix was needed. The targeted gates, the proof and the determinism runs were repeated on the rebased tree and pass; the description's proof and real-machine lines now name the new head.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/34526-env-cred-refusal-names-rule branch from 8c06190 to 071a698 Compare November 19, 2026 13:39
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Backend Tests (3.12, 1), Backend Tests (Windows) (4) and Coverage Gate are red on this head for the same reason they are red on main at this PR's base (256d5af): test/test_process_cache_floor_ratchet.py::test_every_new_module_level_cache_has_a_per_test_reset flags src/kiro_crew/subagent_persistence.py::_NOT_DUE_MEMO, a cache this PR does not touch, and Coverage Gate fails closed on that backend shard. The fix is #39479 (tracked in #39478). This PR waits for it: once it merges, the branch is rebased onto main and CI re-runs. Nothing in this PR's change needs fixing for these reds.

The always-on environment credential check answered with one fixed
sentence whichever of its rules matched, so a user who thought a
refusal was wrong could not tell which rule had fired. The refusal
keeps that sentence and adds a diagnostic line naming the rule and the
matched span, never the matched text. A security event that stores the
refusal text, as a background turn's does, carries the rule as well;
the dashboard and CLI chats keep their fixed refusal code. What the
check refuses is unchanged.

Part of #34526
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/conftest.py, test/conftest_resets.py and files that share a directory with this PR's (docs/system-specs/modules/ among them) since this head went green (256d5af -> 3688176); CI re-running.

The rebase picks up #39479, which fixed test/test_process_cache_floor_ratchet.py::test_every_new_module_level_cache_has_a_per_test_reset, the one test behind the red Backend Tests (3.12, 1), Backend Tests (Windows) (4) and Coverage Gate on the old head; it was red on main at the old base as well. The rebase applied cleanly, the patch is byte-identical, and main changed none of the files this PR edits.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/34526-env-cred-refusal-names-rule branch from 071a698 to 6e5d3f9 Compare November 19, 2026 19:45
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6e5d3f9
  • What rule changed: no refusal rule changed. The always-on environment-credential check of the shell-command gate now appends the existing Refusal diagnostic: line naming which of its rules fired; its four check-only patterns are now keyed by a keystone-env-cred-* rule id. Every pattern, the match order and the first-match return are unchanged.
  • Before -> after (what was allowed/blocked, now): before, every refusal from this check was the single sentence Blocked: command reads AWS credentials from environment variables, whichever rule matched. After, that sentence is still the first line, byte for byte, and a second line Refusal diagnostic: rule=<id> component=env-credential span=<start>..<end> shape=<character-class counts> names the rule. The same commands are refused and the same commands are allowed as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a reader that compares the whole refusal string for equality sees one extra line. Nothing that was refused becomes allowed, because the matching code path is unchanged, and no secret leaks, because the added line carries rule id, offsets and character counts only, never the matched text.
  • Evidence checked (which sandbox result proves it): on a disposable Linux test machine the same patch (identical patch-id) was applied to a clean checkout of an earlier main commit, c0d672b, rather than this pull request's base, with an isolated data home, and the gate was called directly. env | grep AWS_SECRET, printenv AWS_SECRET_ACCESS_KEY, declare -p AWS_SECRET_ACCESS_KEY and echo $AWS_SECRET_ACCESS_KEY were each refused with the unchanged first line and a diagnostic naming credential-exfil-env-grep-aws, credential-exfil-printenv-aws, keystone-env-cred-declare and keystone-env-cred-echo; none of the four diagnostics contained the matched text. The run's one failed check was the issue report's read-only grep of the rule source, which the gate did not refuse in the spellings run there with or without this patch, so this change does not affect it (the same grep under a path that names a Python install is still refused, as the new test pins). On this head, CI's namespace sandbox backend lane and the Denial Differential lanes on Linux, macOS and Windows passed.
  • No regression:
    • Tools still work (which tools/commands were run, result): on that machine ls -la and git status passed through the gate with no refusal, and a multi-line heredoc rebuilt from the issue report was still refused as before, now naming credential-exfil-env-awk-sed-aws.
    • Backward compatible (old config / old data / old callers still work, how checked): the first line of every refusal is unchanged, which the new and updated tests assert by comparing the first line exactly; the added line uses the diagnostic format other gate tiers already append; no config, caller signature or stored-data format changed and nothing needs migrating, though refusal text recorded from now on, such as a background turn's security event, includes the added line.
    • Existing tests (which suites passed on this head): CI on this head passed Backend Tests (3.12) shards 1-8, Backend Tests (Windows) shards 1-8, the namespace sandbox lane, Denial Differential and Security scope adjudication on Linux, macOS and Windows, New-test stability on Linux and Windows, and the Coverage Gate. On the test machine, with the same patch applied to that earlier main commit rather than this head, the shell-gate and gate-liveness suites (448 passed) and the denied-commands suite (354 passed) passed, and a 370-test set holding the new tests passed 20 of 20 serial repeats and 10 of 10 parallel repeats run alongside other tests (790 passed each).
  • How to undo: revert the single commit of this pull request; there is no config or data migration to roll back.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 20, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head 6e5d3f9. The environment-credential check refuses exactly the same commands as before, and the first line of its refusal is unchanged. The refusal now adds the existing diagnostic line naming the rule that fired, with offsets and a character-class count, never the matched text. Every reader of this refusal text already handles the extra line. The related security, cron and offload test files pass on this head, and the new test fails on the base for every rule row. Nothing blocks.

@bolichen97
bolichen97 merged commit 0f6bdf6 into main Nov 20, 2026
105 of 108 checks passed
@bolichen97
bolichen97 deleted the fix/34526-env-cred-refusal-names-rule branch November 20, 2026 00:55
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 20, 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.

2 participants