Skip to content

fix(sandbox): name the min_level floor when it refuses a backendless spawn - #33447

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/sandbox-floor-powerless-key-remedy
Nov 15, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/sandbox-floor-powerless-key-remedy

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #32738

Problem / Motivation

Goal: On a governed host, a backendless-spawn refusal names the sandbox.min_level floor that actually forbids the spawn instead of pointing the operator at the powerless agent.sandbox_allow_unsandboxed_exec key.

On a host with no sandbox backend, sandbox.wrap_argv fails closed and raises
SandboxUnavailableError with a remedy the operator can act on. When a
governance sandbox.min_level floor mandates isolation (any level above the
loosest, e.g. cc or strict), that floor is the real reason the spawn is
refused, and agent.sandbox_allow_unsandboxed_exec is powerless against it
whatever its value.

The governed remedy that names the floor was only reached when the opt-in was
set true (floor_mandates_sandbox and opted_in). A host where the floor mandates
isolation but the opt-in is declared false fell through to the "change that key
to true" branch, and a host where it is unset fell through to the
"allow_unsandboxed_exec is not set" branch. Both send the operator to a config
key the floor makes inert, and the SEL sel_reason carried in the audit event
never named the floor in those cases either.

Why it matters

The refusal message and the audit sel_reason are the only diagnostics the
operator and the audit log get for a security-relevant denial. On a governed
host they pointed at a lever that cannot move the outcome, so an operator would
edit config.json and see the spawn refused again with no explanation of why.

Not a goal

The refuse/allow decision is not touched. Whether a spawn is refused or proceeds
is unchanged for every combination of floor (none / cc / strict) x opt-in key
(unset / true / false) x backend (present / absent) -- all 18 cases. Only the
remedy wording and the sel_reason string change, and only on the refusal path
that a mandating floor already governs.

What changed

  • src/kiro_crew/sandbox_wrap.py: the governed remedy (message + sel_reason)
    is now selected on floor_mandates_sandbox alone, not on
    floor_mandates_sandbox and opted_in. The message no longer asserts the flag
    "is set on this host"; it states the flag is powerless against the policy
    whatever its value.
  • test/test_sandbox_platform_default_exec.py: a new test class covering
    floor+declared-false and floor+unset (both now name the floor and drop the
    powerless-key remedy), plus a matrix test asserting the refuse/proceed verdict
    across all 18 floor x key x backend combinations is exactly what the gate logic
    dictates, independent of the remedy wording.
  • test/test_sandbox_first_party_exec.py: two existing tests updated. main had
    a test (test_governed_host_without_the_opt_in_...) that deliberately asserted
    the policy wording stayed OUT of the floor+unset case, keeping the plain
    "allow_unsandboxed_exec is not set" message there. That assertion is reversed
    here on purpose: because the floor also makes the key powerless when it is
    unset, the floor+unset case must name the floor too, so the test now asserts
    the floor wording appears and the plain missing-opt-in wording does not. The
    second updated test tracks the one-word change in the sel_reason string
    ("overridden" -> "powerless here").

Tests

Added and run; 49 passed across the two touched files:

  • test/test_sandbox_platform_default_exec.py
  • test/test_sandbox_first_party_exec.py

Also re-ran test/test_sandbox_governance_mask.py (733 passed across the three
files together). flake8, black, and mypy are clean on the touched files.

Why this change

A sandbox.min_level floor that mandates isolation is the authority that refuses
the spawn; the config opt-in cannot relax it. The remedy and the audit trail
should name the authority that actually decided, so the operator is pointed at
the policy owner / a working backend rather than at a key that does nothing on a
governed host. Keying the governed remedy on the floor alone makes the three
refusal messages agree with the one thing that decided the refusal, without
shifting any allow/refuse boundary.

Pattern harvest

  • The message, the SEL sel_reason, and the allow/refuse gate are three readers
    of the same floor verdict; when they can disagree about which lever matters, a
    governed operator gets a dead-end remedy. Selecting diagnostics off the same
    predicate the gate uses keeps them consistent.
  • A "keep the policy wording out of this case" assertion is correct only while
    that case is governed by something other than the policy. When the policy also
    governs it, the assertion inverts -- the lesson is to tie such message tests to
    the actual authority, not to the branch that happens to emit the text.

Rule candidate: when a message, an audit-trail reason, and an allow/refuse gate
all read the same policy verdict, select the diagnostics off the exact predicate
the gate uses — otherwise a governed operator can be handed a remedy that points
at a lever the authority has already overruled. Corollary: a "keep this wording
out of this case" test is only valid while something other than that policy
governs the case; tie such tests to the actual deciding authority, not to the
branch that happens to emit the text.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/sandbox_unavailable.py

  • src/kiro_crew/sandbox_wrap.py

  • @chenmingwei23 posted a complete reasoning template for d778120.

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

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of d77812049ad01d9707735e1e78126ea485cf77e1 — 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 fix fully addresses the dead-end remedy. One part goes unmentioned in the description: the diff reverses the old "replace the remedy" decision and now appends a note instead.

Notes

  • Item 3 — undeclared: the deleted comment said "Replace the remedy rather than appending to it." The new comment says "NEVER replace the guidance under the floor… append a note." The description's "What changed" never mentions this reversal. The new comment does give a real reason: the floor forbids only unsandboxed execution, so the host-level fixes still work. That keeps this a note, not a block.

What this change ships

Inventory (5 items) — 3 justified

Intent: on a governed host, a refused backendless spawn tells the operator that the sandbox.min_level floor refused it, instead of pointing at a config key the floor makes powerless. This is a FIX (#32738).

  1. A floor with the opt-in unset or set false now names the floor, not the opt-in key — justified
  2. The audit sel_reason now names the floor whenever the floor mandates isolation — justified
  3. Under the floor, the host-specific remedy is kept and a governed note is appended, instead of the remedy being replaced — undeclared, reverses the prior "replace" comment
  4. Under the floor, the container guidance drops options (b) and (c), the unsandboxed-consent ones — undeclared
  5. _no_backend_guidance(include_optout=…) leaves out the opt-out sentence under the floor (1 production caller, passing both values) — justified

[FIRST-PRINCIPLES-REVIEWED] d778120

Description read

[DESCRIPTION-READ] b5e0ad575d4ea6468ce681a95ea69a3e31d4addbad48a3755845254dbcffc90d

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the refusal and its audit reason now name the authority that actually refuses, and the refuse/allow gate is untouched.

Notes

  • The description doesn't match the diff. "What changed" lists only sandbox_wrap.py and the tests, and says the governed remedy "is now selected on floor_mandates_sandbox alone". The diff does more: it stops replacing the guidance with a fixed governed message. Instead it keeps each host-specific remedy (the AppArmor profile, a retry, seccomp) and appends a note naming the floor. It also strips the opt-out from _no_backend_guidance (via include_optout) and drops options (b)/(c) from the container text. Neither sandbox_unavailable.py nor the container change is mentioned. Add both to the description so reviewers can follow the move from replacing the text to appending a note.
  • guidance.replace(container_optin_options, "") removes the opt-in options by matching a string after the text is built. Choosing whether to add the tail while building the text would avoid this, and a future edit to either string could no longer leave the powerless options in by accident.

[DESIGN-REVIEWED] d778120

Description read

[DESCRIPTION-READ] 3d9c7c6451be6c910d1fc08838a6e4764f0e2ca9bad4fd1484d0929bb7ba6fec

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] d778120

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

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d778120

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

@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 8, 2026
@chenmingwei23 chenmingwei23 changed the title Name the sandbox.min_level floor when it refuses a backendless spawn fix(sandbox): name the min_level floor when it refuses a backendless spawn Nov 8, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/sandbox-floor-powerless-key-remedy branch from 83f5370 to a7d6233 Compare November 8, 2026 22:29
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a7d6233
  • What rule changed: On a host with no sandbox backend, the refusal remedy and the audit sel_reason emitted by sandbox.wrap_argv when a governance sandbox.min_level floor mandates isolation. The governed remedy that names the floor was reached only when the opt-in was set true; it is now reached whenever the floor mandates isolation, regardless of the opt-in key's value.
  • Before -> after (what was allowed/blocked, now): The allow/block decision is unchanged in every case. Only the message text changes. Before: a governed host with the opt-in declared false saw "change that key to true"; with the opt-in unset it saw "allow_unsandboxed_exec is not set". After: both see the floor-naming remedy that points at the policy owner or a working backend. The audit sel_reason on the floor path reads "powerless here" instead of "set but overridden".
  • Worst case if wrong (breaks commands / leaks secret / locks user out): None of those. The change touches only the human-readable refusal string and the audit sel_reason string on an already-failing (fail-closed) refusal path. It cannot allow a spawn that was refused, nor refuse one that was allowed, so it cannot lock a user out of anything that worked before or let an unconfined spawn through. No secret is read or written.
  • Evidence checked (which sandbox result proves it): A reproduction drove wrap_argv with no backend, floor=cc, opt-in declared false: before the change the refusal said "Change that key to true" and sel_reason omitted the floor; after, the refusal and sel_reason both name sandbox.min_level='cc'. A matrix test asserts the raise-vs-return verdict is identical for all 18 combinations of floor (none/cc/strict) x opt-in (unset/true/false) x backend (present/absent).
  • No regression:
    • Tools still work (which tools/commands were run, result): The spawn path returns bare argv for a present backend and raises SandboxUnavailableError for a backendless refusal exactly as before; the matrix test exercises both outcomes and all pass.
    • Backward compatible (old config / old data / old callers still work, how checked): No config schema, data format, or call signature changed. wrap_argv's signature, return shape, and exception kind are untouched; only two string literals and a boolean predicate that selects between them changed.
    • Existing tests (which suites passed on this head): test/test_sandbox_platform_default_exec.py and test/test_sandbox_first_party_exec.py pass (49 together); test/test_sandbox_governance_mask.py also passes (733 across the three). flake8, black, and mypy are clean on the touched files.
  • How to undo: Revert the single commit on this branch (a7d6233). It touches src/kiro_crew/sandbox_wrap.py and two test files only; reverting restores the prior refusal wording and sel_reason with no data or config migration needed.

@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 8, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/sandbox-floor-powerless-key-remedy branch from a7d6233 to 300c6c5 Compare November 9, 2026 03:30
@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 9, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Addressed in 300c6c5.

Under a mandating floor, the refusal no longer replaces the class-specific guidance wholesale. For a transient probe failure, a foreign macOS Seatbelt, or a container seccomp/AppArmor policy, the host-level fix is kept (those remedies work under the floor) and a note naming the floor is prepended; only the two unsandboxed-consent options in the container guidance (KIROCREW_ALLOW_UNSANDBOXED and agent.sandbox_allow_unsandboxed_exec=true) are dropped, since the floor makes them powerless. The full governed replacement is used only for the plain no_backend class with no container remedy, whose own text is just "install a backend or opt out" and whose opt-out the floor negates. The raised kind (transient / foreign_sandbox / no_backend) is unchanged and now agrees with the guidance.

Allow and refuse are unchanged in all 18 floor x opt-in x backend combinations. A new test asserts floor + transient keeps the retry guidance, names the floor, and offers no opt-in option.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 300c6c5
  • What rule changed: On a host with no sandbox backend, the refusal remedy and the audit sel_reason emitted by sandbox.wrap_argv when a governance sandbox.min_level floor mandates isolation. The governed remedy that names the floor is now reached whenever the floor mandates isolation, regardless of the opt-in key's value. Under the floor, class-specific guidance (transient retry, foreign macOS Seatbelt setting, container seccomp/AppArmor profile) is kept with a prepended floor note; only the unsandboxed-consent options the floor makes powerless are dropped. The full governed replacement is used only for the plain no_backend class with no container remedy.
  • Before -> after (what was allowed/blocked, now): The allow/block decision is unchanged in every case. Only the message text and sel_reason change. Before: a governed host with the opt-in declared false saw "change that key to true"; with the opt-in unset it saw "allow_unsandboxed_exec is not set"; and a transient/foreign/container refusal under the floor had its working remedy replaced by "get a working backend or ask the policy owner". After: all name the floor, keep the remedy that works under the floor, and omit the powerless opt-in options.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): None of those. The change touches only the human-readable refusal string and the audit sel_reason on an already-failing (fail-closed) refusal path. It cannot allow a spawn that was refused, nor refuse one that was allowed, so it cannot lock a user out of anything that worked before or let an unconfined spawn through. No secret is read or written.
  • Evidence checked (which sandbox result proves it): A reproduction drove wrap_argv with no backend, floor=cc/strict, opt-in unset/false across the transient, foreign-sandbox, container and plain no_backend classes: every refusal names the floor, carries no opt-in option, and keeps the class remedy for transient/foreign/container while the plain no_backend class gets the full governed note; the raised kind (transient/foreign_sandbox/no_backend) is unchanged. A matrix test asserts the raise-vs-return verdict is identical for all 18 combinations of floor (none/cc/strict) x opt-in (unset/true/false) x backend (present/absent).
  • No regression:
    • Tools still work (which tools/commands were run, result): The spawn path returns bare argv for a present backend and raises SandboxUnavailableError for a backendless refusal exactly as before; the matrix test exercises both outcomes and all pass.
    • Backward compatible (old config / old data / old callers still work, how checked): No config schema, data format, or call signature changed. wrap_argv's signature, return shape, and exception kind are untouched; only message strings and the predicate that selects between them changed.
    • Existing tests (which suites passed on this head): test/test_sandbox_platform_default_exec.py, test/test_sandbox_first_party_exec.py, and test/test_sandbox_governance_mask.py pass (734 together). flake8, black, and mypy are clean on the touched files.
  • How to undo: Revert the single commit on this branch (300c6c5). It touches src/kiro_crew/sandbox_wrap.py and two test files only; reverting restores the prior refusal wording and sel_reason with no data or config migration needed.

@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 9, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/sandbox-floor-powerless-key-remedy branch from 300c6c5 to d0304b9 Compare November 9, 2026 03:57
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Addressed in d0304b9.

Under a mandating floor the guidance is never replaced now; the floor note is prepended and the host-specific remedy follows unchanged. The full_governed replacement branch is gone. For the plain no-backend class, _no_backend_guidance now takes include_optout, and wrap_argv passes include_optout=False under the floor: on stock Ubuntu (apparmor_restrict_unprivileged_userns=1) the "kirocrew service install" / "kirocrew sandbox install-profile" steps are kept and only the opt-out sentence is dropped; the generic no-restriction case keeps the "install a backend" half and drops the "set ...=true" half.

Wording note also fixed: the floor prefix no longer says "give this host a working backend", so it no longer contradicts the foreign-Seatbelt "your sandbox is NOT broken" text.

Allow and refuse are unchanged in all 18 floor x opt-in x backend combinations. A new test pins a governed Ubuntu no-backend host keeping the profile-install steps, naming the floor, with no opt-out text.

@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 9, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d0304b9
  • What rule changed: On a host with no sandbox backend, the refusal remedy and the audit sel_reason emitted by sandbox.wrap_argv when a governance sandbox.min_level floor mandates isolation. The governed remedy that names the floor is reached whenever the floor mandates isolation, regardless of the opt-in key's value. Under the floor the guidance is never replaced: a floor note is prepended and the host-specific remedy follows (AppArmor profile install, transient retry, kiro-cli Seatbelt setting, container seccomp/AppArmor). Only the unsandboxed-consent options the floor makes powerless are dropped, via a new include_optout parameter on _no_backend_guidance and a tail split in the container guidance.
  • Before -> after (what was allowed/blocked, now): The allow/block decision is unchanged in every case; only message text and sel_reason change. Before: a governed host with the opt-in declared false saw "change that key to true"; with the opt-in unset it saw "allow_unsandboxed_exec is not set"; and transient/foreign/container/plain-Ubuntu refusals under the floor had their working remedy replaced by "get a working backend or ask the policy owner". After: all name the floor, keep the remedy that works under the floor (including the Ubuntu profile install), and omit the powerless opt-in options.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): None of those. The change touches only the human-readable refusal string, the audit sel_reason, and a new keyword-only-defaulted parameter on a guidance helper, all on an already-failing (fail-closed) refusal path. It cannot allow a spawn that was refused, nor refuse one that was allowed, so it cannot lock a user out of anything that worked before or let an unconfined spawn through. No secret is read or written.
  • Evidence checked (which sandbox result proves it): A reproduction drove wrap_argv with no backend, floor=cc/strict, opt-in unset/false across transient, foreign macOS Seatbelt, container, plain no_backend, and stock-Ubuntu (apparmor_restrict_unprivileged_userns=1) classes: every refusal names the floor, carries no opt-in option, keeps its class remedy (the Ubuntu case keeps "kirocrew service install"), and the Seatbelt case has no contradictory "working backend" line; the raised kind (transient/foreign_sandbox/no_backend) is unchanged. A matrix test asserts the raise-vs-return verdict is identical for all 18 combinations of floor (none/cc/strict) x opt-in (unset/true/false) x backend (present/absent).
  • No regression:
    • Tools still work (which tools/commands were run, result): The spawn path returns bare argv for a present backend and raises SandboxUnavailableError for a backendless refusal exactly as before; the matrix test exercises both outcomes and all pass.
    • Backward compatible (old config / old data / old callers still work, how checked): No config schema, data format, or caller changed. _no_backend_guidance's new parameter defaults to the prior behavior, so existing callers are unaffected; wrap_argv's signature, return shape, and exception kind are untouched.
    • Existing tests (which suites passed on this head): test/test_sandbox_platform_default_exec.py, test/test_sandbox_first_party_exec.py, test/test_sandbox_governance_mask.py, test/test_sandbox_refactor_facade.py pass (1339 together). flake8, black, and mypy are clean on the touched files.
  • How to undo: Revert the single commit on this branch (d0304b9). It touches src/kiro_crew/sandbox_wrap.py, src/kiro_crew/sandbox_unavailable.py and two test files only; reverting restores the prior refusal wording, sel_reason, and the guidance helper signature with no data or config migration needed.

@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 9, 2026
@chenmingwei23
chenmingwei23 marked this pull request as draft November 14, 2026 16:47
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Thank you for the review. Both findings reproduce on head 131f138.

  1. src/kiro_crew/sandbox_wrap.py:1214-1217: the refusal prefix only says a governance policy forbids unsandboxed execution, and the floor note is appended after the remedy. In a governed container the first 1200 characters kept by _sanitize_probe_error end before sandbox.min_level appears.
  2. src/kiro_crew/sandbox_wrap.py:1226-1232: the floor note has no pointer to the policy owner relaxing sandbox.min_level.

This PR is parked as a draft for the maintainer to decide on the suggested smallest fix: name sandbox.min_level in the refusal prefix, and add a governed-container test that asserts sandbox.min_level appears in message[:_PROBE_ERROR_MAX_CHARS]. No further push until then.

@chenmingwei23
chenmingwei23 force-pushed the fix/sandbox-floor-powerless-key-remedy branch from 131f138 to bc22a0c Compare November 15, 2026 01:21
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: bc22a0c
  • What rule changed: On a host with no sandbox backend, the refusal remedy and the audit sel_reason emitted by sandbox.wrap_argv when a governance sandbox.min_level floor mandates isolation. The governed remedy that names the floor is reached whenever the floor mandates isolation, regardless of the opt-in key value. Under the floor the guidance is never replaced: the host-specific remedy comes first (AppArmor profile install, transient retry, kiro-cli Seatbelt setting, container seccomp/AppArmor) and a short floor note follows it, so a long repair command is not pushed past the 1200-char probe-error cap. The short refusal prefix itself names the floor, so the floor name survives that cap in a governed container. Only the unsandboxed-consent options the floor makes powerless are dropped. The floor note on every branch now also says the policy owner can relax sandbox.min_level.
  • Before -> after (what was allowed/blocked, now): The allow/block decision is unchanged in every case; only message text and sel_reason change. Before: a governed host with the opt-in declared false saw "change that key to true"; with the opt-in unset it saw "allow_unsandboxed_exec is not set"; and transient/foreign/container/plain-Ubuntu refusals under the floor had their working remedy replaced. After: all name the floor, keep the remedy that works under the floor, and omit the powerless opt-in options.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): None of those. The change touches only the human-readable refusal string, the audit sel_reason, and a keyword-only-defaulted parameter on a guidance helper, all on an already-failing (fail-closed) refusal path. It cannot allow a spawn that was refused, nor refuse one that was allowed. No secret is read or written.
  • Evidence checked (which sandbox result proves it): A matrix test asserts the raise-vs-return verdict is identical for all 18 combinations of floor (none/cc/strict) x opt-in (unset/true/false) x backend (present/absent). New tests pin that the AppImage repair command stays inside the 1200-char cap and ahead of the note, that a governed container names the floor inside the first 1200 chars with the opt-in options gone, and that the policy-owner pointer appears on the Windows and AppArmor branches. The new tests fail without the source change.
  • No regression:
    • Tools still work (which tools/commands were run, result): The spawn path returns bare argv for a present backend and raises SandboxUnavailableError for a backendless refusal exactly as before; the matrix test exercises both outcomes and passes.
    • Backward compatible (old config / old data / old callers still work, how checked): No config schema, data format, or caller changed. wrap_argv signature, return shape, and exception kind are untouched.
    • Existing tests (which suites passed on this head): test/test_sandbox_platform_default_exec.py, test/test_sandbox_first_party_exec.py, test/test_s10_cron_env_governance_escape.py and test/test_facade_mirror_guards.py pass locally after rebasing onto current main (449920c). black, isort, flake8 and mypy are clean on the touched files.
  • How to undo: Revert the single commit on this branch (bc22a0c). It touches src/kiro_crew/sandbox_wrap.py, src/kiro_crew/sandbox_unavailable.py and two test files only; no data or config migration is needed.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Re: review 5905884736 - fixed in bc22a0c.

  1. sandbox_wrap.py:1214-1217: the short refusal prefix now names sandbox.min_level, so it stays inside the 1200-char cap in a governed container. A new test uses is_docker_container=True, a seccomp-denied unshare and floor cc, and asserts the floor name is in message[:_PROBE_ERROR_MAX_CHARS], the opt-in options are gone and the seccomp fix stays.
  2. sandbox_wrap.py:1226-1232: the floor note now says the policy owner can relax sandbox.min_level, on every branch. The generic branch in sandbox_unavailable.py keeps only the install sentence, so the pointer has one owner. A new test checks it on the Windows and AppArmor branches.

Also fixed the stale "prepend" comments and made the AppImage test assert the repair command comes before the floor note.

@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 15, 2026 01:21
@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 15, 2026
@chenmingwei23
chenmingwei23 marked this pull request as draft November 15, 2026 03:09
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Parked for the maintainer. After the final push bc22a0c, two checks failed twice: Backend Tests (3.12, 7) test/test_denied_commands_security_cost.py::TestSelfModuleIndexIsLinear::test_the_scan_is_linear_not_quadratic (AssertionError: 2k tokens took 0.651s, limit 0.5s; earlier runs 0.707s and 0.516s), and macOS shard 4 test/test_readonly_source_skill_install.py::TestBuiltinSyncFromReadonlySource (test_provenance_marker_written, test_0455_copy_installs_marker_and_verifies, test_second_sync_does_not_read_install_as_user_customized). No further pushes or reruns from this lane; leaving the call to the maintainer.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Thanks for the update. Both items from the earlier change request are fixed on this head:

  1. Floor name cut off in a governed container: fixed. The short refusal prefix in sandbox_wrap.py now names sandbox.min_level. The new governed-container test checks message[:_PROBE_ERROR_MAX_CHARS] and checks that the unsandboxed-consent options are gone.
  2. No policy-owner pointer in the floor note: fixed. The note now says "The policy owner can relax sandbox.min_level." on every branch, and a test parametrized over win32 and linux checks it.

The optional items on the stale "prepend" comment and the AppImage ordering assertion are also done. Our review of this head found no blocking problem. The allow/refuse verdict is unchanged, and the 18-case floor x key x backend matrix pins that. One thing done well: the tests check what doctor and the dashboard actually keep (the first 1,200 chars), not only the full string.

This cannot be approved yet. PR Readiness is red on this head, with failing runs in Backend Tests (3.12, 7) (test_denied_commands_security_cost), macOS shard 4 (test_readonly_source_skill_install) and the Coverage Gate after them. The PR is also still a draft. Neither failing test touches the sandbox modules this PR changes, but nobody has shown yet that they are unrelated. A maintainer will decide how to handle those checks.

Optional:

  • The include_optout suppression has a test at only one of its three sites. If the generic branch or the AppImage branch of _no_backend_guidance gets the opt-out sentence back, every test stays green. Two one-line asserts would catch it: "sandbox_allow_unsandboxed_exec=true" not in message in the policy-owner test, and "As a last resort" not in message in the AppImage cap test.
  • On a governed Windows host, the generic branch now says to install a Linux or macOS backend, which that host cannot do. The floor note after it still gives the right lever.
  • "What changed" and "Tests" in the body still leave out the sandbox_unavailable.py change, the container (b)/(c) drop, the switch from replace to append, and the shorter governed note. The "49 passed" count also predates the new tests. Please update those two sections only.

@KiroCrewCaptain
KiroCrewCaptain dismissed their stale review November 15, 2026 03:24

Withdrawn: every item in this review is fixed or answered on the current head (see the follow-up comment). Other holds on this PR are listed there.

…spawn

On a host with no sandbox backend, a governance sandbox.min_level floor that
mandates isolation is the real refuser whatever agent.sandbox_allow_unsandboxed_exec
holds. The refusal remedy was only generalized to name the floor when the opt-in
was set true; a floor+false (or floor+unset) host fell through to the ordinary
'change that key to true' / 'is not set' branches, pointing the operator at a key
the floor makes powerless, and the SEL sel_reason never named the floor either.

Key the governed remedy on floor_mandates_sandbox alone. The refuse/allow decision
is unchanged for every floor x key x backend combination; only the message and
sel_reason wording change.
@chenmingwei23
chenmingwei23 force-pushed the fix/sandbox-floor-powerless-key-remedy branch from bc22a0c to d778120 Compare November 15, 2026 11:23
@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 15, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d778120
  • What rule changed: On a host with no sandbox backend, the refusal remedy and the audit sel_reason emitted by sandbox.wrap_argv when a governance sandbox.min_level floor mandates isolation. The governed remedy that names the floor is reached whenever the floor mandates isolation, regardless of the opt-in key value. Under the floor the guidance is never replaced: the host-specific remedy comes first (AppArmor profile install, transient retry, kiro-cli Seatbelt setting, container seccomp/AppArmor) and a short floor note follows it, so a long repair command is not pushed past the 1200-char probe-error cap. The short refusal prefix itself names the floor, so the floor name survives that cap in a governed container. Only the unsandboxed-consent options the floor makes powerless are dropped. The floor note on every branch now also says the policy owner can relax sandbox.min_level.
  • Before -> after (what was allowed/blocked, now): The allow/block decision is unchanged in every case; only message text and sel_reason change. Before: a governed host with the opt-in declared false saw "change that key to true"; with the opt-in unset it saw "allow_unsandboxed_exec is not set"; and transient/foreign/container/plain-Ubuntu refusals under the floor had their working remedy replaced. After: all name the floor, keep the remedy that works under the floor, and omit the powerless opt-in options.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): None of those. The change touches only the human-readable refusal string, the audit sel_reason, and a keyword-only-defaulted parameter on a guidance helper, all on an already-failing (fail-closed) refusal path. It cannot allow a spawn that was refused, nor refuse one that was allowed. No secret is read or written.
  • Evidence checked (which sandbox result proves it): A matrix test asserts the raise-vs-return verdict is identical for all 18 combinations of floor (none/cc/strict) x opt-in (unset/true/false) x backend (present/absent). New tests pin that the AppImage repair command stays inside the 1200-char cap and ahead of the note, that a governed container names the floor inside the first 1200 chars with the opt-in options gone, and that the policy-owner pointer appears on the Windows and AppArmor branches. The new tests fail without the source change.
  • No regression:
    • Tools still work (which tools/commands were run, result): The spawn path returns bare argv for a present backend and raises SandboxUnavailableError for a backendless refusal exactly as before; the matrix test exercises both outcomes and passes.
    • Backward compatible (old config / old data / old callers still work, how checked): No config schema, data format, or caller changed. wrap_argv signature, return shape, and exception kind are untouched. This head is the previous head rebased onto main dc4692c with no change to the diff.
    • Existing tests (which suites passed on this head): test/test_sandbox_platform_default_exec.py, test/test_sandbox_first_party_exec.py, test/test_readonly_source_skill_install.py and test/test_denied_commands_security_cost.py pass locally (181 together) on this head. isort, flake8 and mypy are clean on the touched files.
  • How to undo: Revert the single commit on this branch (d778120). It touches src/kiro_crew/sandbox_wrap.py, src/kiro_crew/sandbox_unavailable.py and two test files only; no data or config migration is needed.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The two earlier reds were not caused by this PR, and the branch is now rebased onto main dc4692c (head d778120, same diff).

The related tests (181) pass locally on the rebased head. CI on this head will decide the rest.

@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 15, 2026 13:31
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Rebased onto main. The two earlier red checks were fixed on main by #37539 and #37476; no code change in this push. All CI on d778120 is green, so marking ready for review.

@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 15, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 15, 2026 14:20

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

Thanks for this. On head d778120 the review checked three things. The refuse/allow predicate (floor_mandates_sandbox or not opted_in) and the first-party carve-out are unchanged, and the 18-case floor x key x backend matrix test pins them. The refusal prefix and the SEL sel_reason now name sandbox.min_level whether the opt-in key is true, false or unset. Callers that do not pass include_optout get the same text as before. One thing done well: the tests check the text that doctor and the dashboard keep (the first 1,200 chars), not only the full string.

Both items from the earlier change request are fixed on this head. (1) The short refusal prefix names the floor, so the floor name fits inside the probe-error cap in a governed container, and a test pins this. (2) The floor note gives the policy-owner pointer on every branch, and a test covers win32 and linux.

Security: the PR changes files under the sandbox paths, but only the text of an existing refusal changes. Every spawn this path refused on main is still refused, every spawn it allowed is still allowed, and the SEL denied event is still emitted on each refusal. No seal, mask or refusal is added or widened, and no secret is read or written.

Optional:

  • On a governed Windows host, the generic branch of _no_backend_guidance (sandbox_unavailable.py:467) tells the operator to install a Linux or macOS backend. Windows cannot do that. Under a floor on that platform, you could skip that sentence and let the policy-owner note stand as the remedy.
  • include_optout is pinned at only one of its three sites, and the REMEDY_MOUNT_DENIED container strip is not pinned. Two checks would cover this. Assert "sandbox_allow_unsandboxed_exec=true" not in message in the AppImage cap test and in the policy-owner test, and add a mount-denied leg to the governed-container test. Building the container text without (b)/(c) (sandbox_wrap.py:1190) would also remove the post-hoc replace.
  • "What changed" and "Tests" in the body still leave out several things: the sandbox_unavailable.py change, the container (b)/(c) drop, the switch from replacing the remedy to appending a note, and the new refusal prefix. The "49 passed" count is also out of date. You can fix these by editing the body, without a push.

@KiroCrewCaptain
KiroCrewCaptain merged commit bdff21a into main Nov 15, 2026
107 of 108 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/sandbox-floor-powerless-key-remedy branch November 15, 2026 14:20
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 15, 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.

Sandbox refusal under a sandbox.min_level floor tells a host with agent.sandbox_allow_unsandboxed_exec=false to set it to true, which the floor ignores

2 participants