Skip to content

fix(kas): read kiro-cli shell spellings when lifting denyByDefault - #32282

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/kas-shell-allowlist-normalized
Nov 7, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/kas-shell-allowlist-normalized

Conversation

@buluoray

@buluoray buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A KAS agent whose allowedTools names the shell as executeCmd, execute_cmd or @builtin/execute_cmd runs its shell commands like one that writes execute_bash, instead of having every command refused under denyByDefault.

A spec with tools: ["executeCmd"], allowedTools: ["executeCmd"] and toolsSettings.shell.denyByDefault: true (no allowedCommands) should behave as kiro-cli does: naming the shell in allowedTools lifts denyByDefault. On KAS it recorded an empty spec-shell-allowlist, so ordinary commands such as pwd were refused. The execute_bash spelling worked. Found by the GPT review on the 0.12.1 backport #32202.

Why it matters

Every shell command of such an agent is refused outright, including in scheduled jobs, for a spec kiro-cli runs as written. executeCmd and execute_cmd are spellings kiro-cli accepts and Crew's projection already folds everywhere else.

Not a goal

  • No change to how wildcard entries (*, e*, execute_*) are read here: they still grant nothing, as test_an_agent_whose_allowed_tools_does_not_name_the_shell_is_still_refused pins.
  • No change to deniedCommands carriage (shell_denies_carried) or to the allowlist patterns.

What changed (motivation → approach → change)

to_client_custom_agent folds allowedTools through expand_kiro_cli_allowed_tools for every other reader, but spec_shell_allowlist gets the raw list and allowed_tools_grant_shell compared each entry against execute_bash and shell exactly. allowed_tools_grant_shell now folds each entry (after the @builtin/ prefix) through canonical_kiro_cli_tool_name, the same table the projection uses, before comparing. The fix sits in the shared check rather than at the call site, so wildcard entries keep their fail-closed reading (the expanded list would turn * into the shell name). The comment on _SHELL_TOOL_NAMES and security.md say so.

Backwards compatibility

Compatible: every entry that granted the shell before still does; only the kiro-cli shell spellings are added.

Removes nothing: the change only lets more specs lift denyByDefault, never fewer.

Tests

  • test_an_agent_whose_allowed_tools_names_the_shell_is_not_refused gains ["executeCmd"], ["execute_cmd"] and ["@builtin/execute_cmd"]; each fails without the fold.
  • Every test file that imports kas_permissions or names spec_shell_allowlist / allowed_tools_grant_shell: 2578 passed.

Proof: PROVEN test/test_kas_deny_by_default.py::test_an_agent_whose_allowed_tools_names_the_shell_is_not_refused[allowed_tools8], test/test_kas_deny_by_default.py::test_an_agent_whose_allowed_tools_names_the_shell_is_not_refused[allowed_tools9], test/test_kas_deny_by_default.py::test_an_agent_whose_allowed_tools_names_the_shell_is_not_refused[allowed_tools10] (head 5a76edf)

Manual verification

N/A — unit coverage sufficient: the test drives the projection and the gate's spec-shell-allowlist row end to end.

Related Issues

Source of the finding: #32202 (GPT review on the 0.12.1 backport).

Sibling sweep

Swept: git grep -n "_SHELL_TOOL_NAMES|allowed_tools_grant_shell(" -- src/
Sibling: src/kiro_crew/acp/kas_permissions.py:450 -- changed here -- spec_shell_allowlist calls the fixed check, its only caller

Pattern harvest

Rule candidate: review-prompt
Pattern: a raw allowedTools entry compared to a tool name without canonical_kiro_cli_tool_name

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 7, 2026 11:39
@buluoray
buluoray requested a review from tim-finnigan November 7, 2026 11:39
@buluoray
buluoray enabled auto-merge (squash) November 7, 2026 11:39
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f97f336b55847d90b73aa6fcdfede4cf7030e459 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 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f97f336b55847d90b73aa6fcdfede4cf7030e459 — 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: a fix at mechanism level that reuses the existing canonical_kiro_cli_tool_name fold, and its new test cases fail on base.

What this change ships

Inventory (3 items) — 3 justified

Intent: a KAS agent whose allowedTools writes the shell as executeCmd/execute_cmd can run shell commands under denyByDefault, as it can on kiro-cli. FIX.

  1. executeCmd, execute_cmd and @builtin/execute_cmd in allowedTools now lift denyByDefault on KAS — justified
  2. @builtin/executeCmd and a doubled @builtin/ prefix are pinned as granting nothing — justified
  3. The security.md row describing which allowedTools entries count as naming the shell is reworded — justified

[FIRST-PRINCIPLES-REVIEWED] f97f336

Description read

[DESCRIPTION-READ] 0cd0e7248cd4a711f3522348b9b36f3d060e3214ac3d3375c47f359ff1e0a7b4

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the fix folds entries through the projection's existing canonical_kiro_cli_tool_name table instead of adding a second spelling list, and wildcard entries still grant nothing.

[DESIGN-REVIEWED] f97f336

Description read

[DESCRIPTION-READ] 087e5fd4ab31c9ad2feb7c260bc92d022e43942454f2f16db005945e5e04615e

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.

buluoray added a commit that referenced this pull request Nov 7, 2026
A spec whose allowedTools names the shell lifts toolsSettings
denyByDefault, as kiro-cli does. allowed_tools_grant_shell compared the
raw entry against execute_bash and shell only, so executeCmd,
execute_cmd and @builtin/execute_cmd, all spellings kiro-cli accepts and
the projection already folds, kept an empty allowlist: every shell call
of that agent, pwd included, was refused.

Fold each entry through canonical_kiro_cli_tool_name before comparing.
Wildcard entries still grant nothing.

(cherry picked from commit 5a76edf)

Backport of #32282 from main. One hunk resolved by hand: the
kas_permissions.py import block keeps this branch's imports and adds
canonical_kiro_cli_tool_name; main's tools_settings_aliases import
belongs to work this branch does not carry.
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f97f336

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

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

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f97f336

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

A spec whose allowedTools names the shell lifts toolsSettings
denyByDefault, as kiro-cli does. allowed_tools_grant_shell compared the
raw entry against execute_bash and shell only, so executeCmd,
execute_cmd and @builtin/execute_cmd, all spellings kiro-cli accepts and
the projection already folds, kept an empty allowlist: every shell call
of that agent, pwd included, was refused.

Fold each entry through canonical_kiro_cli_tool_name before comparing.
Wildcard entries still grant nothing.
@buluoray
buluoray force-pushed the crew/slack/kas-shell-allowlist-normalized branch from 5a76edf to f97f336 Compare November 7, 2026 12:16
buluoray added a commit that referenced this pull request Nov 7, 2026
A spec whose allowedTools names the shell lifts toolsSettings
denyByDefault, as kiro-cli does. allowed_tools_grant_shell compared the
raw entry against execute_bash and shell only, so executeCmd,
execute_cmd and @builtin/execute_cmd, all spellings kiro-cli accepts and
the projection already folds, kept an empty allowlist: every shell call
of that agent, pwd included, was refused.

Fold each entry through canonical_kiro_cli_tool_name before comparing.
Wildcard entries still grant nothing.

(cherry picked from commit f97f336)

Backport of #32282 from main. One hunk resolved by hand: the
kas_permissions.py import block keeps this branch's imports and adds
canonical_kiro_cli_tool_name; main's tools_settings_aliases import
belongs to work this branch does not carry.
@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

span=be34f8190a37

fixed in f97f336: allowed_tools_grant_shell no longer strips @builtin/; it folds the whole entry through canonical_kiro_cli_tool_name, which accepts @builtin/<name> only for names kiro-cli takes there. ["@builtin/executeCmd"] and ["@builtin/@builtin/execute_cmd"] are now cases in test_an_agent_whose_allowed_tools_does_not_name_the_shell_is_still_refused; the docstring and security.md say which spellings count where.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

span=a7cb148677e1

fixed in f97f336: the @builtin/ prefix is no longer stripped before canonicalizing; the intact entry goes through canonical_kiro_cli_tool_name, which validates the builtin reference. @builtin/executeCmd and nested @builtin/@builtin/execute_cmd keep denyByDefault and are pinned in test_an_agent_whose_allowed_tools_does_not_name_the_shell_is_still_refused.

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

Reviewed at f97f336. Thank you: allowed_tools_grant_shell now folds each allowedTools entry through the existing canonical_kiro_cli_tool_name, so the shell spellings kiro-cli itself accepts (bare executeCmd and execute_cmd, and @builtin/execute_cmd) lift denyByDefault the same way execute_bash does. Spellings kiro-cli does not accept (@builtin/executeCmd, a doubled prefix, glob characters, a non-list value) still grant nothing, and both sides are pinned by the tests. This only stops refusing names kiro-cli already treats as the shell, so it adds no restriction, and it uses exact name folding rather than any pattern matching.

Gates at this head: all 97 checks pass with none red or pending, there is no regex in product code, and no change request is open. Approving; the auto-merge you set stays as it is.

@buluoray
buluoray merged commit 64effc0 into main Nov 7, 2026
98 of 99 checks passed
@buluoray
buluoray deleted the crew/slack/kas-shell-allowlist-normalized branch November 7, 2026 14:03
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
buluoray added a commit that referenced this pull request Nov 7, 2026
A spec whose allowedTools names the shell lifts toolsSettings
denyByDefault, as kiro-cli does. allowed_tools_grant_shell compared the
raw entry against execute_bash and shell only, so executeCmd,
execute_cmd and @builtin/execute_cmd, all spellings kiro-cli accepts and
the projection already folds, kept an empty allowlist: every shell call
of that agent, pwd included, was refused.

Fold each entry through canonical_kiro_cli_tool_name before comparing.
Wildcard entries still grant nothing.

(cherry picked from commit f97f336)

Backport of #32282 from main. One hunk resolved by hand: the
kas_permissions.py import block keeps this branch's imports and adds
canonical_kiro_cli_tool_name; main's tools_settings_aliases import
belongs to work this branch does not carry.
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