Skip to content

fix(kas): add opt-in fail-closed for an uncarried web_fetch.blocked - #36329

Merged
bolichen97 merged 1 commit into
mainfrom
crew/issue-triage/30167-kas-web-fetch-blocked
Nov 13, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
crew/issue-triage/30167-kas-web-fetch-blocked

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let an operator opt in to refusing every web fetch on KAS when a web_fetch.blocked entry they set cannot be applied, so that entry is never silently ignored.

On the KAS backend, a toolsSettings.web_fetch.blocked entry that KAS cannot carry becomes no rule. That covers an entry naming a scheme or path, one using other regex syntax, and one that is too long. The session notice names it, but the fetch it was meant to block still runs.

Why it matters

A user who writes blocked: ["https://evil\\.com/.*"] expects that URL to be refused, as kiro-cli refuses it. On KAS the agent fetches it with no refusal. An operator who would rather lose all fetches than run with a deny that does nothing has no way to choose that today.

Not a goal

What changed (motivation → approach → change)

Per @bolichen97's review (default stays as on main; the * deny only behind an opt-in that is off by default), this adds one setting.

agent.kas_fail_closed_web_fetch_blocked Uncarried blocked entry Session notice
false (default) no rule; other entries' host denies travel as on main names the entry, as on main
true the key sends one KAS web_fetch deny over * in place of its host denies names the entry and ends with ; every web fetch is refused until this entry is fixed

The setting copies the existing agent.kas_refuse_plain_http_mcp_headers opt-in: a field in config/sections_agent.py with help text in sections_agent_fields.py, read in loader_builders.py, and read at session start by kas_unread_commands.fails_closed_on_uncarried_blocked (only a JSON true turns it on; an unreadable config reads as off). kas_permissions.tools_settings_to_permissions and the notice both ask that one reader. No regex is added.

The security.md spec line, the agent-spec-fields.md row, configuration.md and the generated config-baseline.json describe the setting. The settings label comes from the config schema; no website strings change.

Backwards compatibility

Compatible: the setting is off by default, and with it off the translation and the notice are the same as main for every spec. Turning it on is the operator's choice; then an agent with an uncarried blocked entry cannot fetch any URL until the entry is fixed.

Removes nothing: the change adds one opt-in setting and changes no default.

Tests

  • test_by_default_an_uncarried_blocked_entry_adds_no_rule (whole-URL, regex syntax, over-long): setting off, an uncarried entry adds no rule, the carried host deny still travels, the key is named. Same as main.
  • test_opted_in_an_uncarried_blocked_entry_denies_every_fetch (same three): setting on, one web_fetch deny over *.
  • test_opted_in_the_notice_says_every_fetch_is_refused: setting on, the notice item ends with the refusal mark. The existing notice tests pin main's text for the default.
  • test_fail_closed_is_read_from_the_agent_config: only a JSON true under agent turns it on.
  • Run: test/test_kas_tools_settings.py, test/test_kas_web_fetch_patterns.py, test/test_config_baseline.py, test/test_configuration_doc_defaults.py, test/test_configuration_doc_facts.py (124 passed).

Proof: not provable -- other: prove.py reverts the setting reader together with the guard, so the tests error at collection (INCONCLUSIVE rc=21, --per-hunk rc=2); manual mutants instead: guard forced on fails 3 default-path tests, guard forced off fails 3 opt-in tests

Manual verification

N/A — unit coverage sufficient: the change is a translation from a spec dict to KAS rules gated by one config boolean, and a deny over * is a shape KAS already takes from a .* entry on main.

Related Issues

Closes #30167

Part of #33068

Sibling sweep

Swept: git grep -n "converted(" -- src/kiro_crew/acp/kas_permissions.py
Sibling: src/kiro_crew/acp/kas_spec_denies.py -- not affected -- an uncarried deniedCommands entry is already refused at Crew's gate (uncarried_denied_commands)
Sibling: src/kiro_crew/acp/kas_permissions.py -- not affected -- deniedPaths entries travel verbatim as globs; only an entry past the length bound is dropped and named

Pattern harvest

Not generalizable: the other KAS deny translations already refuse or carry each entry; web_fetch.blocked was the last one that dropped a deny silently.

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

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 13, 2026 02:46
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 13, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/30167-kas-web-fetch-blocked branch from 1d4ac32 to 1704e15 Compare November 13, 2026 02:57
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 234056ece11f978b563b2ee470c3f250a71a19d3 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 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The setting is opt-in and off by default, so the default path matches main. Turning it on only tightens fetches, and an operator can flip it back to undo it.

Notes

  • The translation (tools_settings_to_permissions) and the notice each call fails_closed_on_uncarried_blocked(), so config.json is loaded twice per session start. If the file changes between the two loads, the notice can disagree with the rules that were sent. Reading the flag once and passing it to both would close that gap.

[DESIGN-REVIEWED] 234056e

Description read

[DESCRIPTION-READ] 5e8d7bb73d24982754943a0fc9553e256f72d68773adb086c1aba16e163ee73f

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 234056ece11f978b563b2ee470c3f250a71a19d3 — 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

The new opt-in key is off by default and is read by two call sites. KAS can't match a whole URL, which is the real cause; the description leaves that to #33068.

Notes

What this change ships

Inventory (3 items) — 1 justified

Intent: let an operator have KAS refuse all web fetches rather than silently ignore a web_fetch.blocked entry it can't apply. This is an ADDITION framed as a fix.

  1. New setting agent.kas_fail_closed_web_fetch_blocked: when on, an entry KAS can't apply turns that key's host denies into one deny over * — inherited, existing authored-permissions deny covers it
  2. With the setting on, each such entry's line in the session notice ends "every web fetch is refused until this entry is fixed" — justified
  3. Settings label and help text, plus doc rows in security.md, agent-spec-fields.md and configuration.md — oversized, permanent sync cost for an off-by-default key

[FIRST-PRINCIPLES-REVIEWED] 234056e

Description read

[DESCRIPTION-READ] 16f147da494b98cef4f737c7803a272bdda2eecbcf876fc5bac8f3d3bfbfa688

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 234056e

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

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 234056e

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

@iamwhatever

iamwhatever commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=a7cb148677e1 The fallback deny can discard all translated restrictions

Rebutted: not a new defect. The overflow is the existing rule-bound behaviour on main: past _MAX_RULES (200) tools_settings_to_permissions returns no block and names (all: too many rules) (kas_permissions.py:1930-1931). On main any carried web_fetch.blocked entry adds the same one rule at the same cap, so this PR adds one more input that reaches an overflow main already has; it does not create the class.
Reaching it needs a spec with about 6,400 to 12,800 distinct deniedPaths that land the count exactly on rule 200, plus an uncarried blocked regex.
When it fires it is loud and fails toward a prompt: the notice names the loss, reads lose their KAS deny and ask, never run unasked; the Crew gate still refuses write deniedPaths (kas_spec_denies.py:307).
Refusing the whole projection on overflow changes the bound policy on main for every key, outside this PR goal.
This is security-class, so it needs a human writer to verify and record the override; the agent posts none.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

Adds an opt-in setting, agent.kas_fail_closed_web_fetch_blocked (off by default). With it on, a web_fetch.blocked entry KAS cannot carry turns that key's host denies into one KAS web_fetch deny over "*", and the session notice adds a refusal mark. With it off, the rules and the notice are unchanged from main for every spec. A KAS deny refuses the fetch before Crew's gate sees any request, so the gate's trusted-URL grant cannot bypass it. All three tools_settings_to_permissions callers (notice, projection, tool view) stay consistent. The config wiring copies kas_refuse_plain_http_mcp_headers in every place that setting appears. Tests cover both settings for three kinds of uncarried entry, the notice mark, and the config reader. Source Gates and Fast Gate are red, but I could not tie the failure to this diff.

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

@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 Nov 13, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/30167-kas-web-fetch-blocked branch from 1704e15 to 5c6024d Compare November 13, 2026 04:50
@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 13, 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.

Requesting changes on one part: the "*" fallback.

I agree with the goal. On main, a web_fetch.blocked entry KAS cannot carry is dropped. converted (acp/kas_permissions.py:1780-1790) puts it only on lost, and the web_fetch branch (:1890-1903) sends just the host denies it could build. So a fetch the user blocked still runs, and the notice is the only trace.

The fix overshoots that, though. blocked = ["*"] turns one uncarried entry into a deny over every URL. With blocked: ["https://evil\\.com/.*"], the agent can then no longer fetch docs.python.org or github.com, which the user never blocked and which kiro-cli fetches for that same spec. That makes a fetch fail where main and kiro-cli let it run, so it adds a refusal beyond what the user wrote.

Please:

  1. Keep main's translation by default for an entry KAS cannot carry: no rule from it, the other entries' host denies as before, and the notice naming it as not applied.
  2. If you want the fail-closed behaviour, put the "*" deny behind an opt-in setting that is off by default, and have the notice mark say so only when it is on.
  3. Keep the new test for the opt-in path, and add a default-path test where an uncarried entry adds no rule and the carried host deny still travels.

The rest is fine: the carried .*evil\.com.* case, the notice text change and the docs. No regex is added.

Not checked: I ran no tests locally. "Publish readiness signal" is red on this head, and I did not read its log, since I am not approving this round.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

This PR asks the security owner to decide whether failing closed is right here. That decision stays with the security owner. No sign-off is recorded on the PR yet, so it waits for that decision before it can merge.

Review result on head 5c6024d: no blocking findings. PR Readiness is green. The fix sits in the single writer (tools_settings_to_permissions) with no new gate row or regex. The session notice uses the same predicate as the translation, so the two cannot disagree. Reviewers reproduced the 236 passing tests and the stated mutant (removing the guard fails the new test 3 times). The parametrized test covers all three uncarried shapes, and the body is upfront that the change is Breaking.

For the security review:

  • A web_fetch.blocked entry with a scheme or path (the normal whole-URL shape) is not carried, so it now produces a KAS deny over *. That deny also blocks the plain-URL web_fetch.trusted grant from fix(kas): answer a plain-URL web_fetch.trusted at Crew's gate #33073. Example: blocked https://docs\.example\.com/private/.* with trusted https://docs\.example\.com/.*. On main, a fetch of https://docs.example.com/guide runs without a prompt. With this PR it is refused. The grant now works only when blocked is empty or holds host-only entries. The Backwards compatibility section and the web_fetch_gate Reader line do not mention this.

Optional:

  • test_trusted_runs_unprompted_unless_blocked and test_gate_adds_no_refusal check only the gate verdict. Both projected specs now carry the deny over *, so the verdicts they assert no longer happen on KAS. Asserting on out["permissions"] would pin the decided outcome.
  • The security.md trusted-grant paragraph, the web_fetch_gate docstring ("KAS's host deny stays as on main") and the test module docstring still describe main's behaviour.
  • The guard is pinned against deletion only. Loosening it to if lost: passes every related test. One case with a carryable blocked list next to an uncarried key from another tool would catch that.

@iamwhatever iamwhatever changed the title fix(kas): fail closed on a web_fetch.blocked entry KAS cannot carry fix(kas): add opt-in fail-closed for an uncarried web_fetch.blocked Nov 13, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/30167-kas-web-fetch-blocked branch from 5c6024d to 6eb2e68 Compare November 13, 2026 08:24
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 13, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Source Gates is red on main, not on this diff: docs-lint reports docs/request-for-change/rfc-app-agent-tools-third-party-grant.md unreachable from any index (main issue #36503 / #36497; fix PRs #36504, #36510). This PR waits for that fix to merge, then rebases once.

@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 Nov 13, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/30167-kas-web-fetch-blocked branch from 6eb2e68 to 530ea8d Compare November 13, 2026 09:40
@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 13, 2026
On KAS a toolsSettings.web_fetch.blocked entry KAS cannot carry (a
scheme or path, other regex syntax, too long) becomes no rule, and only
the session notice names it. A new setting,
agent.kas_fail_closed_web_fetch_blocked (off by default), turns that
key into one KAS web_fetch deny over "*" and makes the notice say every
fetch is refused. With the setting off, behaviour matches main.
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/30167-kas-web-fetch-blocked branch from 530ea8d to 234056e Compare November 13, 2026 10:24
@iamwhatever

Copy link
Copy Markdown
Contributor Author

@bolichen97 ready for another look at 234056e. Your 08:06Z review is addressed:

  1. Default is main's translation: an entry KAS cannot carry adds no rule, the other entries' host denies travel, and the notice text matches main (test_by_default_an_uncarried_blocked_entry_adds_no_rule).
  2. The * deny sits behind agent.kas_fail_closed_web_fetch_blocked, off by default, built like agent.kas_refuse_plain_http_mcp_headers. The notice mark appears only when it is on.
  3. Tests cover both paths, with mutants: forcing the setting on fails the default tests, forcing it off fails the opt-in tests. No regex.

All CI checks pass on this head; PR Readiness waits only on your review decision. The one Linux shard red was the tracked transcribe flake (#36364), green on rerun.

@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 13, 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 on 234056e. My point on the "*" fallback is fixed:

  • By default an uncarried web_fetch.blocked entry adds no rule, as on main. The carried host denies still travel, and the notice names the entry without the "every fetch is refused" mark. test_by_default_an_uncarried_blocked_entry_adds_no_rule pins this for the whole-URL, regex-syntax and over-long cases.
  • The deny over "*" now sits behind agent.kas_fail_closed_web_fetch_blocked, which defaults to off. fails_closed_on_uncarried_blocked turns it on only for a JSON true and reads off when the config cannot be loaded, so a broken config keeps main's behaviour. test_fail_closed_is_read_from_the_agent_config covers true, false, "true" and unset. The opt-in path and its notice mark have their own tests.
  • The setting is in AgentConfig, the loader, config-baseline.json and the docs.
  • No regex.

Not checked: I ran no tests locally and relied on CI (97 green).

@bolichen97
bolichen97 merged commit 1f358a6 into main Nov 13, 2026
152 of 154 checks passed
@bolichen97
bolichen97 deleted the crew/issue-triage/30167-kas-web-fetch-blocked branch November 13, 2026 12:23
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 13, 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.

KAS: a web_fetch.blocked entry KAS cannot carry is not refused

3 participants