Skip to content

revert: #13273 apps-tree mask breaks every app script cron - #16072

Merged
bolichen97 merged 1 commit into
mainfrom
revert/13273-apps-mask
Oct 2, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
revert/13273-apps-mask

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Summary

Reverts #13273 ("fix(cron): mask the apps tree from every cron child that runs model-supplied code", 0496784) on main. Owner decision, P0.

#13273 replaced ~/.kiro/crew/apps/ with an empty mask inside the cron sandbox and re-exposed only each app's data/. An app's cron code lives in that bundle: the script a script cron names, the file a command cron runs, and the sibling modules, lib/ and node_modules/ they import. So every app cron failed before its first line with ModuleNotFoundError / MODULE_NOT_FOUND / "can't open file".

What is removed

  • run_script_sandboxed and run_command_sandboxed no longer pass the apps tree as a mask, its data windows, its identity pin or its alias inodes. The command path keeps the shell helpers later commits added (fix(cron): run command crons where /bin/sh is bash, incl. macOS #15253).
  • sandbox drops the helpers that existed only for the apps mask: materialize_caller_masked_dir, materialize_app_data_window, masked_dir_identity, refuse_if_an_app_secret_is_linked, aliased_app_secret_ids, app_data_window_targets, AppDataWindow, MAX_APP_DATA_WINDOWS.
  • test/test_cron_apps_secret_mask.py is deleted.

What is kept, and why

Later commits (#13715/#15252, #14021, #15729, #15309) built on these, and other callers' private windows (the ACP scratch windows) go through them:

  • the caller-pinned extra_hidden_dir_ids / extra_private_dir_ids / extra_alias_credential_ids parameters on wrap_argv and the backends;
  • the launcher's descriptor-pinned window staging, nested re-mask and stage retirement;
  • _MNT_DETACH / umount2.

No caller passes identities any more, so these behave as name-only. Their tests move to test/test_sandbox_caller_pinned_ids.py, unchanged apart from dropping the cron wiring cases and the producer helpers.

Security trade-off

After this revert, cron children can again read other apps' .app_secret, as they could before #13273. #12518 is open again in practice. The plan is to re-land the protection through #16061, which re-exposes app code read-only, rebased as a full re-land on top of this revert.

Regression test

test/test_app_script_cron_sibling_import.py covers both exec paths. In each case the app's bundle code imports a sibling helper.py and a lib/ package:

  • On every host: a recording passthrough for wrap_argv requires that no requested mask covers the bundle unless a window re-exposes the bundle itself. The real child must also succeed.
  • Where the host can carry masks (credential_mask_applies("cc")): a real sandboxed spawn with nothing patched must succeed.

I checked it against the pre-revert tree. All 4 cases fail there: the call-site check names the apps mask with only data/ windowed, the real script cron fails opening job.py, and the real command cron exits 2. After the revert, all 4 pass. CI Linux runners forbid unprivileged unshare, so the two real-sandbox cases skip there. I ran them on a host with user namespaces.

Validation

  • pytest test/test_cron*.py test/test_sandbox*.py test/test_mcp_cron*.py test/test_app_cron*.py + the new file: 5154 passed, 4 skipped
  • black 26.3.1 baselined gate (scripts/check_black_formatting.py): passed
  • isort --check-only src/kiro_crew test conftest.py xdist_budget.py: clean
  • flake8 on the changed files: clean
  • mypy src/kiro_crew/: no issues (2046 files)
  • scripts/check_comment_history.py: passed

Refs: Taskei Mesh-3988, Mesh-3989; follow-up #16061.

#13273 masked `<config_dir>/apps` from both cron exec paths and re-exposed only
each app's `data/`. An app's cron code lives in that bundle -- the script a
script cron names, the file a command cron runs, and the sibling modules,
`lib/` and `node_modules/` they import -- so every app cron failed before its
first line with ModuleNotFoundError / MODULE_NOT_FOUND / "can't open file".

This removes the behaviour #13273 added at the cron call sites and the helpers
that existed only for it:

* `run_script_sandboxed` and `run_command_sandboxed` no longer pass the apps
  tree as a mask, its data windows, its identity pin or its alias inodes; the
  command path keeps the shell helpers later commits added.
* `sandbox` drops `materialize_caller_masked_dir`, `materialize_app_data_window`,
  `masked_dir_identity`, `refuse_if_an_app_secret_is_linked`,
  `aliased_app_secret_ids`, `app_data_window_targets`, `AppDataWindow` and
  `MAX_APP_DATA_WINDOWS`.
* `test_cron_apps_secret_mask.py` goes with them.

Kept, because later commits built on them and other callers' windows go
through them: the caller-pinned `extra_hidden_dir_ids` / `extra_private_dir_ids`
/ `extra_alias_credential_ids` parameters, the launcher's descriptor-pinned
window staging, nested re-mask and stage retirement, and `_MNT_DETACH`. With no
caller passing identities they behave as name-only. Their tests move to
`test_sandbox_caller_pinned_ids.py` unchanged apart from dropping the cron
wiring cases.

Trade-off: a cron child can again read other apps' `.app_secret`, as it could
before #13273. The protection is to re-land via #16061, which re-exposes app
code read-only.

`test_app_script_cron_sibling_import.py` pins the regression on both exec
paths: a recording passthrough requires that no requested mask hides the
bundle, and where the host can carry masks a real sandboxed spawn must import
the bundle's sibling modules. All four cases fail on the pre-revert tree.

This reverts commit 0496784.
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of aa6fca7e06e142b5bcb70b30b38c682aba1e380e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Confirm the owner's P0 sign-off is recorded on the PR, since this knowingly reopens #12518 until #16061 re-lands.

The deleted pin (test_cron_apps_secret_mask.py) is treated as a reversed decision, not a gap — trade-off stated, follow-up named — and the replacement test's assertion ("no mask covers the bundle unless a window re-exposes the bundle itself") deliberately leaves room for #16061's read-only re-land, so it won't need rewriting. Tree holds no dangling references to the deleted helpers, and the retained identity-pin plumbing keeps live callers (ACP scratch windows) plus its own moved tests.

[DESIGN-REVIEWED] aa6fca7

Description read

[DESCRIPTION-READ] 96f4c087a7341132a77e33ecfa3bd0204e8a145a95b3210452da3357524cad7c

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of aa6fca7e06e142b5bcb70b30b38c682aba1e380e — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify #16061 re-lands: the kept identity-pin params (extra_hidden_dir_ids/extra_private_dir_ids/extra_alias_credential_ids) have zero producers after this revert and are dead surface if it stalls.

The defect has checkable provenance: the regression test this PR adds (test/test_app_script_cron_sibling_import.py) is stated failing 4/4 on the pre-revert tree, and the fix is pure subtraction at cause level — the mask itself was what broke every app cron. The reversed pin (test_cron_apps_secret_mask.py, 2285 lines) is declared, not recast: the description names the reopened exposure (#12518) and the re-land path. The restored shape is what the app platform already pinned, so no RFC applies. Counted: grep extra_private_dirs= finds 5 real producers (ACP scratch windows, decisions runtime) justifying the kept window machinery; grep for the three *_ids params finds producers only inside sandbox.py/sandbox_launcher.py — zero external, exactly as the description admits. If #16061 does not consume them, the subtraction is those three params plus test/test_sandbox_caller_pinned_ids.py (576 lines). No leftover references to the seven deleted helpers anywhere in the repo.

What this change ships

Inventory (8 items) — 8 justified

Intent: restore every app's cron, which #13273's apps-tree mask broke before its first line — a FIX (revert).

  1. App script crons can read and import their own bundle code again — justified
  2. App command crons likewise — justified
  3. Cron children can again read other apps' .app_secret (declared trade-off, re-land via fix(cron): re-expose an app's code directories read-only inside the apps-tree mask #16061) — justified
  4. Seven apps-mask helpers/constants deleted from sandbox.py — justified
  5. New regression test pins both cron exec paths against re-masking the bundle — justified
  6. Identity-pin parameters kept name-only, zero producers; tests moved to test_sandbox_caller_pinned_ids.py — justified
  7. test_cron_apps_secret_mask.py deleted — the reversed pin, declared with evidence — justified
  8. Comments in sandbox_exec_argv and the hardlink-scan test rewritten to drop stale cron claims — justified

[FIRST-PRINCIPLES-REVIEWED] aa6fca7

Description read

[DESCRIPTION-READ] 60df84df4971f090696d65885f1ef4afd56a8f8fa72fa6f9c8f40d346ad31c9d

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging aa6fca7e06e142b5bcb70b30b38c682aba1e380e. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/cron_script.py:2213 -- Cron children can steal another app’s credential
hidden = () / wrap_argv(argv, mode="cc")
Model-supplied cron -> reads apps/<victim>/.app_secret -> exchanges it for a victim-scoped token.
Anchor: residual/security
Fix: Expose required bundle code while masking every .app_secret in both execution paths.
[BLOCK-MERGE] aa6fca7
[GPT-REVIEWED] aa6fca7

Adjudication (Opus 5) — is blocking on each finding proportionate?

UNBOUNDED (security-class): .app_secret is a bearer credential — dashboard/token_auth.py:1245 reads it and dashboard/handlers/core.py:3684 exchanges a match for an app=<name> scoped token on X-App-Secret alone.
Conditions confirmed: both cron exec paths now pass no apps mask (cron_script.py:2213 hidden = (), cron_script.py:2752 wrap_argv(argv, mode="cc")), and <config_dir>/apps is in none of the crew-home dispositions — _CC_DIRS/_STRICT_DIRS (sandbox.py:4607, sandbox.py:4581) carry only _CREW_HIDDEN_LEAVES, which masks apps/aws-control/data and apps/meetings/data/edits but not apps/<app>/.app_secret; the child is handed _KIROCREW_DIAL_PORT (cron_script.py:2261) so the exchange endpoint is reachable. Recovery path: none — sel().log_api_access records a granted exchange, indistinguishable from the app's own.
Conditions are ordinary operation (one installed app plus a model-supplied script or command body, which is the feature itself), not an extreme combination, so no rarity argument supports a FLAG.

[ADJUDICATION] aa6fca7e06e142b5bcb70b30b38c682aba1e380e total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] aa6fca7e06e142b5bcb70b30b38c682aba1e380e

[ADJUDICATION-FENCED] aa6fca7e06e142b5bcb70b30b38c682aba1e380e fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/cron_script.py:2213 -- With the apps tree absent from every mask list, a model-supplied cron body reads any installed app's `.app_secret` and exchanges it at `/api/apps/{name}/token` for that app's scoped identity, under ordinary conditions and with the audit trail reading as a legitimate grant.
[GPT-ADJUDICATED-FENCED] aa6fca7e06e142b5bcb70b30b38c682aba1e380e

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

@bolichen97
bolichen97 merged commit cfb4284 into main Oct 2, 2026
88 of 94 checks passed
@bolichen97
bolichen97 deleted the revert/13273-apps-mask branch October 2, 2026 06:17
bolichen97 added a commit that referenced this pull request Oct 2, 2026
….8.0) (#16075)

Backport of #16072. #13273 reached release/0.8.0 inside the batch-2 squash
4b9e9f0 (#15631), so this reverts only #13273's changes from it, on
release's own layout; the #15255 command-shell helpers that batch resolved
against are kept.

#13273 masked `<config_dir>/apps` from both cron exec paths and re-exposed only
each app's `data/`, hiding every app cron's own code and the sibling modules it
imports, so every app cron failed with ModuleNotFoundError / MODULE_NOT_FOUND.

Removed: the cron call-site mask, windows, identity pin and alias inodes; the
app-only `sandbox` helpers (`materialize_caller_masked_dir`,
`materialize_app_data_window`, `masked_dir_identity`,
`refuse_if_an_app_secret_is_linked`, `aliased_app_secret_ids`,
`app_data_window_targets`, `AppDataWindow`, `MAX_APP_DATA_WINDOWS`); and
`test_cron_apps_secret_mask.py`. Kept, as on main: the caller-pinned
`extra_*_ids` parameters and the launcher's pinned window staging, nested
re-mask and stage retirement, which behave as name-only with no caller passing
identities; their tests move to `test_sandbox_caller_pinned_ids.py`.

Trade-off: a cron child can again read other apps' `.app_secret`, as before
#13273. The protection is to re-land via #16061.

`test_app_script_cron_sibling_import.py` pins the regression for a command cron
running bundle code that imports its siblings (release has no bundle-script
resolution for script crons); both cases fail on the pre-revert tree.
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review — 🔴 changes requested (blocking)

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

BLOCKING: both cron exec paths lose the <config_dir>/apps mask, so model-supplied cron code can read every installed app's .app_secret bearer credential and mint that app's scoped dashboard token.

BLOCKING — src/kiro_crew/cron_script.py:2213

        else:
            hidden = ()

and at src/kiro_crew/cron_script.py:2752: sandboxed_argv, sandbox_cleanup = wrap_argv(argv, mode="cc")
An agent-authored cron_add job — ungranted script body or command string — reading ~/.kiro/crew/apps/<other-app>/.app_secret → run_script_sandboxed takes the hidden = () branch (wrap_argv(..., extra_hidden_dirs=())) / run_command_sandboxed passes no extra_hidden_dirs at all, and nothing downstream covers the leaf: _CREW_HIDDEN_LEAVES (sandbox.py:250) carries only apps/aws-control/data, apps/meetings/data/edits, apps/.dev-grants.json, _SENSITIVE_HOME_DIRS has no app_secret entry so _CRON_CRED_PATH_RE / _vet_script_contents never match it, and a spawned child's open() reaches no tool gate → the child reads any app's credential and POST /api/apps/{name}/token with X-App-Secret returns that app's scoped token (token_auth.validate_app_secret, handlers/core.api_app_token), so the cron acts as an app it was never granted.
Fix: pass <config_dir>/apps as extra_hidden_dirs on both call sites again, with extra_private_dirs opened on the running app's whole bundle directory rather than only its data/, which keeps every sibling app's .app_secret masked while leaving the bundle's own modules importable; this requires restoring the materialize_caller_masked_dir / window helpers this PR deleted from sandbox.py.

[BLOCK-MERGE] aa6fca7
[OPUS-REVIEWED] aa6fca7

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

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

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.

1 participant