Skip to content

fix(apps): sign an app's whole manifest and every packaged file - #34390

Open
CrysisDeu wants to merge 1 commit into
mainfrom
crew/bug-resolve/34319-app-signature-files
Open

CrysisDeu wants to merge 1 commit into
mainfrom
crew/bug-resolve/34319-app-signature-files

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On a fleet that requires app signatures, an app whose packaged files changed after the publisher signed it is refused at install, update, activation and every point where its code is registered or run.

The App Kit admission policy (app_admission.json, require_signature) checks a signature over selected manifest fields only (AppManifest.signing_payload). No packaged file is bound, so a signed app's backend, hooks, agents, skills or UI bundle can be swapped with the signature still verifying. After install, only manifest fields are rechecked at enable, boot and restart, and nothing rechecks content where code is registered or run.

Why it matters

A fleet turns on require_signature to run only publisher-approved code. Today the signature approves a description of the app, not the app: anyone who can change files in the package or in the installed app folder runs their code under the publisher's signature.

Not a goal

  • Sealing the installed tree: files the signed inventory does not list stay allowed (see Accepted costs).
  • Asymmetric publisher keys; the HMAC trust keys stay as they are.
  • Any change for fleets without require_signature.

Intended? / Repro

Intended? No. The maintainer filed #34319 with the expected behavior: under the signature policy the signature binds the complete manifest and every packaged file, and install, update, activation and executable-resource registration refuse content that no longer matches. Code on main 4022acf:

  • src/kiro_crew/apps/manifest.py:851-1055 (signing_payload) builds the signed bytes from selected manifest fields; no file content goes in.
  • src/kiro_crew/apps/admission.py:162-176 (_signature_valid) verifies only that payload.
  • src/kiro_crew/apps/manager_activation.py:160 and src/kiro_crew/apps/backend_runtime/startup.py:113, :189 skip admission for any record whose writable installed.json says origin: "builtin".

Repro (by reading main; no local test run on this host): fleet policy {"mode": "enforce", "require_signature": true, "trust_keys": {"acme": "<key>"}}. Sign an app's app.json the scheme-1 way, install it, then replace backend/app.py in the installed folder. enable_app, boot and restart call app_admission_denied(name, manifest=...), which recomputes the field payload. It still matches, so the app is admitted and the replaced backend runs. Setting origin: "builtin" in the app's own installed.json skips admission entirely.

What changed (motivation → approach → change)

Symptom → cause → change:

  • Signature scheme 2 (src/kiro_crew/apps/package_signature.py, new). The HMAC (the shared platform.admission.hmac_signature) covers the whole parsed app.json object except signature, through canonical_signing_bytes. The object carries signatureScheme: 2 and signedFiles, a SHA-256 for each packaged file. inventory_refusal pins each directory through its parent (pinned_directory, child_if_real_dir) and opens the file through the pin (dir_fd-relative with O_NOFOLLOW on POSIX, open_file_no_reparse(links_only=True) on Windows), with an fstat regular-file check, so a link or junction at the file or above it is refused. Inventory keys that are absolute or contain .., ., empty parts, \ or : are refused with plain string checks (no regex). On POSIX, digests are cached by the opened file's fstat identity, so one activation reads each file once. On Windows, where st_ctime is the creation time, every check hashes again. AppManifest.document keeps the parsed object; to_dict leaves signedFiles out of app listings.

  • Code paths must be signed. declared_code_paths / unsigned_code_path, one rule: a path counts when it resolves to a file inside the app folder and is code. Code means an agent, skill or SOP, the backend entry point, a hook module (exactly {base}.py, the file load_app_module opens), a cron script, a UI entry, or in MCP command/args, setup, openCommand and cron commands: the command word when it is a path, an interpreter's script argument, a -m target, or a .py/.js/.mjs/.cjs/.sh word. Data words (state.db) never count. Paths are normalised (posixpath.normpath, backslashes as /); a relative path that leaves the folder is refused, a system python is not a packaged file. A code path under data/, node_modules, .venv or another name the inventory builder leaves out can never be listed, so it is refused under the policy (no special case).

  • Admission (src/kiro_crew/apps/admission.py). Under require_signature, only a valid scheme-2 signature is admitted; scheme 1 gets a re-sign message. app_admission_denied(app_root=...) checks the package there. It is passed by:

    • install_app and update_app, on the source (built-in adoption goes through update_app; kirocrew app import output installs through install_app);
    • the cloned registry checkout, before its build (install_clone);
    • enable_app, the boot resource pass and restart, on app_dir(name).
  • Execution and registration boundaries (src/kiro_crew/apps/execution.py). app_execution_denied(manifest=...) takes the manifest the caller is about to act on. Given that and an app_root, it:

    • verifies the installed app.json;
    • checks that the caller's manifest is that verified one: package_signing_payload bytes for an AppManifest, or canonical JSON of the whole projection except contributes. A caller with no manifest gets its own reason.
    • checks the package.

    Callers that pass a manifest: backend spawn; hook enable, boot and reconcile; bridge registration of agents, skills, MCP servers and crons (including the boot cron restore, now off the loop); lifecycle scripts; openCommand. The async callers run the gate through asyncio.to_thread.

  • Audit rows. A signed-package refusal is a PackageRefusal: a str that also carries a fixed classification (signed_package_mismatch / signed_package_unverified). Every audit row that records an admission or execution refusal writes only that classification and resources="signed_package", never the app name or a path. That covers install, update, enable, self-registration, the three registry gates, the cloned-checkout gate, boot, restart and its backstop, and app_execution_denied. The detailed reason still goes to the caller. The execution side reads the policy without an audit row per call; an unreadable policy counts as requiring signatures.

  • Bytecode beside a signed .py. Under the policy:

    • The gateway starts an app's backend, the stdio MCP servers whose command is a Python interpreter itself (python, python3.12, pythonw; never a console script such as python-lsp-server) and cron scripts with -B -X pycache_prefix=<that spawn's own dir> right after the interpreter (signed_pycache_flags), which still holds under -E/-I.

    • Those, plus lifecycle scripts, openCommand and onInstall, also get PYTHONPYCACHEPREFIX and PYTHONDONTWRITEBYTECODE (signed_pycache_env). The dir is fresh and empty for each spawn (see Per-spawn bytecode cache).

    • In-process hook modules compile from source (_SourceOnlyLoader). A sys.path_hooks entry scoped to a signed app's root (_SignedFirstFinder, dropped on unload) imports the listed file when a module name has one, before any unlisted extension, package directory or bytecode of that name. Otherwise it keeps the stock search, including a listed bare .pyc.

    • The same finder runs in the Python children the gateway builds the argv for (src/kiro_crew/apps/signed_first.py, new, stdlib-only; module_loader now imports it from there). The backend (plain and ASGI/uvicorn), stdio MCP servers and app cron scripts start python [options] <abs>/signed_first.py <app> <target> (admission.signed_first_python_args); the shim installs the finder and runs the target through deps_boot's dispatch (launch_entries / run_target, split out of deps_boot.main unchanged). The checked list (app, resolved root, every entry of the verified signedFiles with its signed SHA-256, so an extensionless script or a .pyz target is re-hashed too) is never written to a file; the shim is inserted whenever that inventory is non-empty, and its finder compares only importable names. A child the gateway spawns itself, the backend and a cron script, reads it from a pipe only that child inherits (admission.signed_first_pipe: pass_fds on POSIX, a handle_list on Windows; KIROCREW_SIGNED_FIRST_FD holds the number). A stdio server is spawned by kiro-cli, so no fd can reach it; the gateway writes its list to <kiro agents dir>/.kirocrew-signed-first/<app>.json and its launch-config env holds only that path (KIROCREW_SIGNED_FIRST_LIST); the file is in the kiro agents tree, which every sandboxed spawn already mounts read-only (src/kiro_crew/sandbox_tiers.py:45 _resolved_kiro_agents_targets, applied at src/kiro_crew/sandbox_argv.py:401). No new seal or mask. The shim reads the list once, before any app code, drops both variables, and refuses to run without a list for its app. So an unlisted backend/app/__init__.py beside a signed backend/app.py, an unlisted worker/ package beside a signed worker.py under -m, and an unlisted helpers/ beside a signed helpers.py do not load; an unlisted module whose name nothing signed uses imports as before.

    With the policy off, argv, env, spawn arguments, launcher text and loaders are as on main: no pipe, no variable, no file.

  • The gateway's npm installs. Under the policy only, the Node backend install runs npm ci --omit=dev --no-audit --no-fund when package-lock.json exists and npm install --production --no-audit --no-fund --no-save otherwise; the registry build step runs npm ci, or npm install --no-save. The signed lockfile decides the versions and is never rewritten. With the policy off both argvs are unchanged.

  • Built-ins (builtin_admission_exempt). With the policy on, the exemption needs a shipped package under that name, not only an origin: "builtin" record. It never raises.

  • Dev mode. The ui/ skip applies only under the existing operator grant (dev_mode.dev_mode_granted_root), bound to the current resolved ui root, when that root resolves outside the install (the --confirm-out-of-install-root case). Every ui/ path the manifest names as code (agents, skills, SOPs, hooks, backend entry, cron script, MCP command, args and -m targets, setup and openCommand scripts) stays checked, compared case-folded; only the UI entry modules dev mode serves live are skipped. An in-install ui/ is always checked. No new bypass was added.

  • Publisher command. kirocrew app sign <dir> --signer <id> reads the key from KIROCREW_APP_SIGNING_KEY (never argv) and writes all four fields.

  • Registration sources and deferred launches (policy on only). The agent-config rebuild (agent_materialization/mcp_sources.py, _collect_app_mcp_servers) runs installed_package_refusal on each app before taking its live spec or manifest fallback, so a server registration refused stays out. A builtin is recognised only from this build's own package (shipped_builtin_app_root), never from the data home or the app folder, and skips that check. Third-party crons register from the verified manifest (_cron_defs_from_manifest), never from the app-writable app-crons.json; every caller (enable, boot, install route, CLI, boot restore, prune) goes through bridges_crons._admitted_app_cron_defs. run_script_sandboxed re-checks an app script's package at every fire, before the spawn. Ownership comes from both the persisted path and the resolved file: a path under an app must resolve to that same app's listed regular file, so a signed job.py swapped for a link elsewhere is refused. The resolved file is opened once (no link followed at it), its bytes are checked against the signed digest, and the launcher runs exactly those bytes, handed over through the shim's pipe; it does not read the file again. The checked list handed to a child carries every signed file's SHA-256, and the shim re-hashes them before the target runs, which covers stdio servers that kiro-cli starts long after registration. A cron script spec is split drive-aware (cron_script_paths._split_script_spec), so C:\...\job.py:run is checked as that file. The signed-first path hook claims directories only, as FileFinder.path_hook does, so runpy.run_path(<script>) still runs a script entry.

  • Code-path rules (policy on only). A command word (MCP command, cron command, setup, openCommand, the backend entry) that names a file inside the app folder is code whatever its extension, so an extensionless launch must be signed; a system python3 or npx names no packaged file. MCP command and arguments are expanded as the runtime expands them (env.expand_spec_args) before the check, so a ${HOME} argument naming an unsigned data/server.py is refused. A package directory beside a signed module of the same name (worker/ beside worker.py) wins the import, so every module file in it must be signed too (signed_first.unlisted_package_files), at admission and again in the child. Contributed UI entries (sessionControls and the rest) are checked like any other manifest-named path. Every hash this PR adds opens the file once and hashes that handle: O_NOFOLLOW on POSIX, open_file_no_reparse in the gateway on Windows, and in the stdlib-only shim a reparse-point and samestat check of the name against the open handle.

  • Child recheck exceptions. The checked list names unchecked entries the shim does not re-hash: exactly the ui/ files the dev-mode grant leaves out at admission (_ui_skip), and the listed files under directories the spawn hides (a granted cron's script folder), which the gateway checked at that spawn; the finder still uses the whole list. Clustered Python options (-Bm worker, -Bmworker, -Bc code) are split as Python consumes them before the shim takes the target's place. The rebuild's manifest fallback prepares a Python stdio spec with the same signed launch as registration (bridges_mcp._signed_stdio_launch: flags, shim, checked list), and an exempt shipped builtin's servers come from its shipped manifest (_registration_source), never the installed copy.

  • Per-spawn bytecode cache. Each spawn gets its own fresh, empty bytecode cache dir: admission.new_pycache_dir makes a 0700 mkdtemp dir under <data home>/run/app-pycache/ (gateway-owned, read-only to sandboxed children, never the shared cache/app-pycache/<name>), passed as both -X pycache_prefix= and PYTHONPYCACHEPREFIX. It is removed when the child exits: a cron script in the run's finally; a lifecycle script, onInstall and openCommand when the gateway's wait on the asyncio child returns (release_pycache_dir_after); a backend on stop, on a failed spawn, or when the next spawn replaces it (backend:<app>). kiro-cli starts stdio MCP servers, so their dir lives per registration (mcp:<app>): each re-registration makes a new one and removes the old, the agent-config rebuild reuses the held one, and deregistration removes it. Dirs a crashed gateway left behind stay, empty, under run/app-pycache/.

  • Builtin exemption. A shipped builtin skips admission only while everything its installed manifest runs is this build's shipped code: its backend, mcpServers, crons, setup and openCommand equal the shipped manifest's in the form the builtin install writes it (discovery._manifest_to_builtin_dict, through JSON), so an unmodified installed builtin matches and only an added or changed executed item differs, and a module-style backend entry resolves inside the shipped package (shipped_builtin_module_path); otherwise it takes the full signature and inventory checks (admission._runs_only_shipped_code). A module-style backend entry the build does not ship for the app (http.server) is checked against the installed folder at spawn. The shim's per-file hash follows no link or junction anywhere below the app root.

  • Load preparation off the loop. For a third-party hook or route load, module_loader.prepare_signed_load (the verified-inventory read and the realpath scan of the importer cache) runs in a worker thread when the caller is on the event loop (signed_load_off_loop, used by RouteRegistry.register_app_routes and LifecycleDispatcher._invoke); load_app_module then applies it without I/O. Unload drops signed roots by their recorded spellings with no I/O. The backend spawn log line names only the command and its argument count, never the argv.

  • Stdio checked list by file. The checked list for a stdio server kiro-cli starts is no longer an environment value: signed_first_launch_env writes it to signed_first_list_path(app) in the kiro agents tree (already read-only to every sandboxed spawn) and the env names only that path, so the launch env stays small whatever the inventory size. The shim opens the file once, no link followed, regular files only; deregistration removes it. Backend and cron children keep the inherited pipe.

  • Self-registered apps keep main's launch. signed_first_payload applies the same _self_registered test admission uses (a lifecycle: "app" record, no manifest code in the folder, only allowed entries), so a real self-registered app gets no shim and no list.

  • Shim imports never shadow a signed app module. The shim snapshots sys.modules on its first line. Before the target runs, every module cached since then (by the shim, deps_boot or runpy, e.g. json, zipfile) whose top-level name a signed file provides at the top of the app's import path (the script's directory, or the app root for -m/-c) leaves sys.modules with its submodules, so the app's own module wins, as on main; sys, os, builtins, importlib and anything loaded before the shim are never dropped, and the shim keeps its own module references. Link checks work on interpreters older than 3.12: without os.path.isjunction a Windows junction is read from lstat's reparse-point attribute, and the shim and deps_boot parse under the 3.8 grammar.

  • Docs, same commit: docs/app-kit/manifest-reference.md, docs/system-specs/modules/app-kit-platform.md §38, docs/system-specs/modules/security.md, docs/system-specs/modules/cli.md.

Design not taken: refuse any file the inventory does not list (strict). It lost because it refuses every registry app whose build step or onInstall writes output into its checkout, and every app that writes into its own folder outside data/. The chosen rule refuses a missing, changed, non-regular or relinked signed file, and a manifest code path that is not signed.

Review fixes on 05d340e (after the rebase onto main bebda6d, where main's §38 took the number; after the rebase onto main ee52eac, where main added §39 and §40, this PR's section was §41; after the rebase onto main 549cc1a, where main added §41, it is §42):

  • Rebased onto main ee52eac (head 6e7b967): the app-kit-platform.md section is renumbered §41 and the two §39 links in cli.md and security.md follow it; manager_install.py and cli_commands.py keep both main's and this PR's imports.
  • Rebased onto main 549cc1a (head 0ed79db): the section is renumbered §42 after main's new §41 (app-owned chat slots), the §41 links in cli.md and security.md follow it, and module_loader.py keeps both main's seams import and this PR's verified_signed_files import.
  • Rebased again onto main d9839ee (head c43e134): main added a local _restore_denied to the boot cron restore in apps/bridges_crons.py; it now calls this PR's _cron_restore_denied, so the unreadable-record branch also passes the source manifest to the execution decision.
  • kirocrew app sign parses app.json with loads_user_json, as AppManifest.from_json_file does, so a manifest with a leading UTF-8 byte-order mark signs as it installs (Opus 5.5 on cf7d433). Test: test_a_manifest_with_a_byte_order_mark_signs_and_is_admitted.
  • The shim's POSIX opens of a listed file and of the checked-list file carry O_NONBLOCK, so a FIFO in their place gets the existing not-a-regular-file refusal instead of hanging MCP, backend or cron startup (GPT 6.1 on cf7d433). The gateway side already opened with O_NONBLOCK (PinnedDirectory._open_file). Tests: test_a_fifo_in_a_listed_files_place_is_refused_without_a_writer, test_a_fifo_as_the_checked_list_file_is_refused_without_a_writer.

Known limitations

  • Medium: Hash-to-use window. Files are hashed at each boundary and read again by the loader, interpreter or shell that runs them. A process that can write the app folder can swap a listed file in between. The boundaries include every cron fire and every stdio server start (the shim re-hashes the listed files against the signed digests); the check does not run continuously.

  • Medium: Child-process shadowing of unsigned names. Unlisted files are allowed. In a Python child the gateway starts, the script's own folder comes first on sys.path, and the signed-first finder only decides names a signed file uses, so an unlisted json.py (or a dependency name) beside a signed script still shadows the standard library or that dependency for that child.

  • Low: Launches the gateway does not build the Python argv for. Python started through an exec backend's shebang, a cron command, or a lifecycle, openCommand or onInstall shell line gets no signed-first finder, and with -E/-I also keeps the stock bytecode behaviour (it still gets the environment variables otherwise). A gateway-built launch whose shape the shim cannot take (-x, a -- before a dash-led operand) keeps the stock import order.

  • Medium: Windows stdio servers. App children on Windows run without an OS sandbox, so nothing seals the kiro agents tree there, and an app child could rewrite the launch config that carries its stdio servers' checked list (and their command). Backend and cron children on Windows get the list over an inherited handle and are not affected.

  • Medium: Writable-path limit. A file the inventory does not list is not checked, apart from the code paths the manifest names. Sealing the installed tree is the separate decision named in the issue.

  • Low: Build output must not touch signed files. The registry checkout is checked before the build and install_app checks the built tree, so a build step or onInstall that rewrites a committed file is refused. Publishers sign only files that ship unchanged (documented).

  • Low: Re-sign required. Under require_signature, scheme-1 signatures stop being admitted until the publisher runs kirocrew app sign.

  • Medium: Self-registered first-boot rule. register_external_app and the registry prefetch have no package on disk, so only the manifest signature is checked there. A self-registered app keeps that rule at every later enable, boot, restart and execution boundary only while all three hold: its record says lifecycle: "app", no code path its verified signed manifest names is an existing file inside the app folder (its agents, skills and commands live elsewhere), and the folder holds nothing beyond app.json, installed.json, approved-grants.json (an older install's copy: fix: keep app approvals and the owner's disable out of the app's tree #34177 moved the approved set to member-records/app-grants/ and its import leaves the old file), .app_secret and data/. The record is app-writable, so it never decides this alone; otherwise the full inventory and code-path checks run. Test: a registry app with lifecycle forged to "app" and a changed listed backend/app.py is refused.

  • Low: Unreadable policy. A present but unreadable app_admission.json also counts as requiring signatures at the execution boundaries, not only at install and enable.

  • Low: Cost of each check. Under the policy, each boundary opens and fstats every listed file and reads a file again only when its fstat identity changed (every time on Windows). With the policy off, the added work per decision is one stat of app_admission.json plus a deep copy of each parsed manifest.

  • Low: Code paths under dropped names. A code file under data/, node_modules, .venv or another name build_file_inventory leaves out can never be in signedFiles, so a signing fleet refuses a manifest that names one.

  • Low: Overlap with fix(apps): mint app tokens only for owner-enabled apps #34251 (merged). It also touches manager_activation.py, manager_external.py and app-kit-platform.md and adds host_exec_grants; the overlap is in files only. This PR does not reuse its grant record as a self-registration marker: no real self-registered app ships code in its installed folder, so the folder contents and the signed manifest decide the skip without a new trust record.

  • Medium, fails closed: GPT 6.1 on c43e134 (security-class, machine-flagged as an edge case): a backend or stdio MCP server launched through the dependency shim (deps_boot.py inside signed_first.py) has target[0] set to the shim, so _yield_names evicts nothing (src/kiro_crew/apps/signed_first.py:392). A signed app that ships its own module under a name the shim already imported (backend/json.py) gets the stdlib copy and fails to start with an ImportError. Nothing unsigned runs. A maintainer rules on it (see the PR comment).

  • Medium: GPT 6.1 on c43e134 (security-class, machine-flagged as an edge case): under the operator's out-of-install ui/ dev grant, an ABSOLUTE setup, openCommand, MCP or cron path into the installed ui/ is not mapped back to an inventory path, so a changed file there is not checked (src/kiro_crew/apps/admission.py:278). The relative spelling is refused. Same class as the f6faf61 ui/server.mjs finding above. A maintainer rules on it (see the PR comment).

Open review findings (not fixed in this PR)

  • Low: C9: a cron script child gets the -X flags but not the env vars, so a grandchild Python reads __pycache__ (src/kiro_crew/cron_script.py:382).
  • Low: C11: a non-exec backend entry with a Python shebang gets no -X (src/kiro_crew/apps/backend.py:1077).
  • Medium: E2: shell-string parsing does not follow sh -c '...', cd sub && ... or node -e (src/kiro_crew/apps/package_signature.py, _argv_groups).
  • Medium: GPT 6.1 on 3963552: on a case-insensitive volume (default macOS), the in-process signed-first finder matches inventory names by exact string (src/kiro_crew/apps/signed_first.py:129). A signed package listed as Worker/ but imported as worker misses the match, so an unlisted Worker/helper.so can win over the signed helper.py inside the gateway. GPT 6.1 raised it again on 85c30d0 (security-class, so it blocks that lane), also naming the child-side finder (signed_first.py:426), and again on 6e7b967 (fenced, upheld). Listed under the owner's no-more-patches rule.
  • Medium: GPT 6.1 on f6faf61: under an operator's out-of-install ui/ grant, an absolute MCP argument that names <app_root>/ui/server.mjs is skipped by the inventory check, so a changed ui/ script can still be registered and run (src/kiro_crew/apps/admission.py:277). Listed under the owner's no-more-patches rule.
  • Medium: GPT 6.1 on f6faf61: a signed Node backend with no node_modules is checked before the gateway's npm ci/npm install. An npm lifecycle script can then rewrite the signed entry point before Node starts, and Node has no child-side recheck (src/kiro_crew/apps/backend.py:1035). Listed under the same rule.
  • Medium: GPT 6.1 on 786894d: a live stdio spec registered before require_signature was turned on is reused by _collect_app_mcp_servers without the signed-launch preparation (src/kiro_crew/agent_materialization/mcp_sources.py:170). The next re-registration prepares it. GPT 6.1 raised it again on 05d340e (security-class, upheld; it also names the app-agent spec copies in agent_capabilities.py and bridges_agents.py). Left open under the owner's last-pass rule; a maintainer rules on it.
  • Low: F: conftest floor entries for the new module globals; private cross-module calls (PinnedDirectory._open_file, manager_tree._COPY_IGNORE); _owning_root iterates a dict another thread may change; cron_script imports the app layer even with the policy off; Windows rehashes every check; line growth in src/kiro_crew/apps/backend.py and src/kiro_crew/apps/registry_pipeline/install.py; contributes is left out of the projection compare (src/kiro_crew/apps/admission.py, _acted_on_refusal).

Backwards compatibility

Compatible for fleets without require_signature: admission, activation and every execution boundary decide exactly as on main. No child argv or environment changes, the module loader uses the stock loaders, and the npm flags are unchanged. verified_signer (provenance only, never denies) also names a valid scheme-2 signer. AppManifest.to_dict drops only signedFiles, a key nothing before this change wrote. Audit rows for refusals other than a signed-package refusal are written as before.

Breaking for fleets that set require_signature: a scheme-1 signature is no longer admitted. This is the re-sign requirement the issue asks to document. Also, an origin: "builtin" record for a name this build does not ship no longer skips admission, and a signed manifest whose code path inside the app is not in signedFiles is refused. Writer sweep on origin/main @ 4022acf: no shipped built-in carries a signature (test_no_shipped_builtin_carries_a_signature). The only in-repo writers of app signatures are tests, updated here to sign with scheme 2 (test_app_manager.py, test_external_registry.py). The scheme-1 payload tests now read the provenance check (test_app_signing_payload_*).

Reader: src/kiro_crew/apps/admission.py:verified_signer -- app -- accepts either scheme, so provenance for scheme-1 apps is unchanged | test_a_signature_issued_under_the_pre_change_payload_still_verifies
Reader: src/kiro_crew/apps/manager_activation.py:enable_app -- app -- real shipped built-ins keep the exemption through shipped_builtin_app_root | test_a_builtin_is_not_refused_by_admission_under_require_signature
Reader: src/kiro_crew/apps/backend_runtime/startup.py:start_enabled_app_backends -- release -- same exemption at boot | test_builtin_still_boots_under_require_signature
Reader: src/kiro_crew/apps/builtin_adoption_checks.py:admission_refusal -- release -- an unsigned adoption stays refused under the policy, as before | test_an_admission_policy_blocks_visibly_then_adopts_once_relaxed
Reader: src/kiro_crew/apps/manager_lookup.py:get_app -- crew page -- the listing loses only signedFiles, which no reader consumes | test_app_package_signature_boundaries.py::test_a_boundary_judges_the_manifest_the_caller_acts_on

Tests

test/test_app_package_signature.py:

  • The inventory lists what the copy carries.
  • An untouched package is admitted. A changed or missing signed file is refused, and so is one reached through a link (make_escaping_link), one under a linked directory (make_dir_link), and a listed path that is not a regular file. Unlisted files are tolerated.
  • A same-size rewrite with its mtime restored is refused (the digest cache does not hide it).
  • A manifest edit or an inventory rewrite breaks the signature. Only integer scheme 2 is accepted. Unusable paths are refused.
  • A named entry point missing from signedFiles is refused under the policy and admitted with it off. A system python -m command is not a packaged file. A file an MCP argument names must be signed. A hook needs exactly {base}.py signed, and a hook under data/ is refused; a data word in args (state.db) does not count; a path that normalises out of the folder is refused; only a Python interpreter itself counts as one (python-lsp-server does not). The digest cache skips stamps within 2 s of the hash (clock injected).
  • With the policy off nothing is checked. A forged built-in record needs a shipped package. A file changed after install is refused at backend spawn. kirocrew app sign reads its key from the environment.

test/test_app_package_signature_boundaries.py:

  • A changed signed file is refused at enable, restart, the boot resource pass (positive control first: the untampered package registers) and update.
  • A boundary refuses a caller manifest that differs (projection or AppManifest document), gives its own reason to a caller with no manifest, and refuses when the check raises. Code from a shipped built-in package is exempt, and the built-in exemption falls back to provenance when the policy cannot be read.
  • Audit rows carry only the classification at install, update, enable and app_execution_denied.
  • Dev mode: an out-of-install linked ui/ under the grant skips only non-code ui/ files, so a ui/ agent and a ui/ script named by setup stay checked; an in-install grant skips nothing.
  • Bytecode: a planted .pyc (asserted inside the app root) is run by the stock loader (control) and not by _SourceOnlyLoader; a hook's sibling import skips it; a signed module wins over an unlisted package of the same name; a listed bare .pyc still imports. An autouse fixture restores sys.path_hooks, the signed roots and the digest cache.
  • Children (test_app_package_signature_children.py, real subprocesses through the shim, list handed over a pipe as the gateway does): an unlisted backend/app/__init__.py does not stand in for the signed ASGI backend/app.py (control: a plain launch picks the package), -m worker runs the signed worker.py over an unlisted worker/ package, an unlisted helper that shadows nothing still imports, and app code that forges its list (a planted list file, both channel variables, a pipe of its own) still gets the signed helpers.py. The shim refuses to run with no list or another app's. Without the policy the argv helpers, the launch env and the pipe are all empty and nothing is written; with it the shim sits at the launch target (including -mworker) and only importable entries are handed over.
  • Registration and deferred launches (test_app_package_signature_children.py): a script entry runs through the shim; the shim refuses a listed file changed after the list was made; a cron script changed after activation is refused at the next fire (control: the signed script reaches its spawn); a job planted in app-crons.json is not registered; a refused app's MCP server is not restored by a config rebuild (control first); a drive-qualified cron script names its file; a signed job.py swapped for a link to an unsigned crons/ file is refused; a changed extensionless signed MCP target is refused at child start; mochi's MCP servers survive a rebuild under the policy; a data-home app whose installed.json and app.json claim to be builtin is still checked and refused when unsigned.
  • Code-path rules and child exceptions: an extensionless MCP command in the app folder must be signed and a system command names none; an unsigned package beside a signed module is refused at admission and by the shim, and a signed one is admitted; an unsigned sessionControls entry is refused; a ${HOME} argument naming an unsigned data/server.py is refused; the shim refuses a listed file reached through a link (make_escaping_link); ["-Bm", "worker"] launches through the shim; the child skips exactly the dev-mode ui/ files admission skips, and an edited skipped file does not stop it; a granted signed cron reaches its spawn; a server added to an installed builtin's manifest is not emitted; the manifest fallback spec carries the shim. The link-swap cron test uses make_escaping_link and no longer skips on Windows.
  • Last pass: the three shadowing child tests now assert the shim's refusal (each keeps the plain-launch control); the forged-list test plants the package only after forging every channel and still gets the signed module, and a second start with the package present is refused; each spawn gets a distinct empty 0700 dir that is gone after the child exits, and a re-hold or release removes the previous one; a builtin whose installed backend is changed to http.server loses its exemption while the unmodified one keeps it; the granted-cron test reaches its spawn behind a wrapped argv.
  • Final pass: all six shipped builtins (design-tweak, dev-fleet, file-explorer, md-notebook, workflows, ops-mission-control), as register_builtin_apps writes them, stay exempt, and enable, boot and restart all decide through that exemption; one with an added stdio server loses it and is refused unsigned; the http.server case still refuses; the boot test's fake shipped root now has the manifest a real one has; the load preparation runs off the loop thread and the load reuses it.
  • Coverage and ci11: test_app_signed_first_unit.py calls the shim in-process (read_checked by pipe, file, missing, other app, forged or malformed list, linked or non-file list path; the finder's signed-wins, package, extension and pass-through cases; the directory-only path hook; install and cache dropping; the per-file hash and recheck on match, mismatch, missing, linked file, linked directory, non-regular; main's usage, refusal and success paths) with sys import state restored after each test. A ~300 KiB list keeps the stdio launch env under 4 KiB and the shim still reads it; a self-registered app's launch carries no shim and no list.

Child-environment sites, each asserting the flags or keys under the policy and their absence without it:

  • backend spawn: test_app_backend_spawn_env.py, argv and env;
  • stdio MCP: test_app_bridges_mcp.py, args and env;
  • lifecycle: test_lifecycle_scripts_cov80.py;
  • openCommand: test_app_execution.py;
  • onInstall env helper and cron script argv: test_app_package_signature_children.py.

test_app_package_signature_children.py also pins both npm argvs, policy on and off. test_app_bridges_mcp.py checks a console-script server keeps its args. test_app_package_signature_boundaries.py checks a self-registered app is judged by its manifest signature only, and that the enable route audits only the classification.

test_apps_registry_identity_admission.py checks that the cloned-checkout gate is handed the checkout as app_root and audits only the classification.

Updated for the new contract: test_app_manager.py, test_external_registry.py, test_app_backend_spawn_env.py, test_app_signing_payload_executed_fields.py, test_app_signing_payload_resource_and_ui_fields.py, test_apps_registry_identity_admission.py, test_app_bridges_agent_configs.py, test_app_bridges_mcp.py, test_hook_reconcile.py, test_app_sync_keeps_crons.py, test_apps_routes_coverage_update_uninstall.py, test_app_backend_composition_contract.py and test_apps_registry_composition_contract.py (new frozen names).

Proof: not provable -- other: this host forbids local test runs, so prove.py was not run; CI runs the suite

Manual verification

N/A: CI runs the unit tests for each gate and boundary. Static gates were run locally with the repo pins (black 26.10.1 on touched non-baselined files, isort 6.0.0, flake8 7.1.0, mypy 1.14.1 on touched files), plus check_comment_history, check_brand_name, check_file_line_cap and check_sync_io_in_async.

Related Issues

Refs #34319

Sibling sweep

Swept: git grep -n "app_admission_denied(|app_execution_denied(|origin") != "builtin"|origin != "builtin"" -- src/kiro_crew/apps
Sibling: src/kiro_crew/apps/registry_pipeline/install.py -- changed here -- onInstall gets the out-of-folder bytecode cache; its post-build gates run before install_app, which checks the files
Sibling: src/kiro_crew/apps/manager_external.py -- not affected -- self-registration ships no files; its later registrations check app_dir
Sibling: src/kiro_crew/apps/builtin_adoption_checks.py -- not affected -- adoption installs through update_app, which checks the files
Sibling: src/kiro_crew/cron_script.py -- changed here -- an app cron script child gets the pycache-prefix flags
Sibling: src/kiro_crew/apps/backend_runtime/supervision.py -- not affected -- re-asks about a running backend with no app root; it runs no new code
Sibling: src/kiro_crew/apps/module_loader.py -- changed here -- loads hook modules after the hook gate; under the policy it compiles from source

Pattern harvest

Rule candidate: review-prompt
Pattern: a signature or trust check over a description of executable content (manifest fields) instead of the content itself

Known limitations

  • Four files already over 1,600 lines grow with this PR's own change and are not split here: src/kiro_crew/apps/backend.py 1,909 vs 1,819 on main, src/kiro_crew/apps/manifest.py 1,618 vs 1,610, src/kiro_crew/apps/registry_pipeline/install.py 1,736 vs 1,699, test/test_app_bridges_agent_configs.py 1,621 vs 1,616.

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 (CI runs them; this host runs no tests) 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

Contributions are accepted under the project's Apache-2.0 license.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 10, 2026 07:38
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 6ff9df617f4b6b0b9e18bc81581805270a8c8471 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 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the maintainer asked for the scheme-1 refusal in #34319, and only fleets that turn on require_signature are affected.

Notes

  • Every fleet with require_signature on sees each installed scheme-1 app refused at the first boot after upgrade, because its signature binds no packaged file. The manifest-reference doc says to re-sign, but nothing tells the operator before the refusal. A startup log line naming which installed apps need kirocrew app sign would make the upgrade visible.
  • This PR adds a second way of loading Python: the bytecode controls, the signed_first.py shim and the _SignedFirstFinder. That is a lot of surface for a residual the spec already accepts: unlisted files are tolerated, and a file can change between its hash and its run. A follow-up that seals the installed tree would make most of it unnecessary, so it is worth tracking as its own issue before more is built on it.

[DESIGN-REVIEWED] 6ff9df6

Description read

[DESCRIPTION-READ] a4cffd8d16d457ca0d638d8188abc37f22343802c35902d45ad79c68cb6cfcd2

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 6ff9df617f4b6b0b9e18bc81581805270a8c8471 — 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

Every item comes from the maintainer-filed defect #34319 or follows from it, and it all applies only when require_signature is on. The one rider, the spawn log no longer printing argv, has no harm.

What this change ships

Inventory (10 items) — 9 justified

Intent: a fleet that requires app signatures should run only the code the publisher signed, so an app whose files changed after signing is refused. This is a FIX.

  1. Under require_signature, the signature covers the whole app.json plus a SHA-256 of every packaged file (scheme 2). — justified
  2. Apps signed the old way (scheme 1) are refused under the policy, with a message asking for a re-sign. — justified
  3. Package contents are rechecked at install, update, registry clone, enable, boot and restart. — justified
  4. Backend spawn, hooks, bridge registration, crons, lifecycle scripts and openCommand refuse content that doesn't match the signature. — justified
  5. An origin: builtin line in the app's own installed.json no longer skips admission. — justified
  6. New kirocrew app sign --signer command; the key comes from KIROCREW_APP_SIGNING_KEY. — justified
  7. Under the policy, app Python children run with no bytecode from the app folder and a shim that loads signed files first; hooks compile from source. — justified
  8. Under the policy, npm runs npm ci or --no-save, so the signed lockfile and package.json stay unchanged. — justified
  9. Audit rows for a signed-package refusal record only its classification, never the app name or a path. — justified
  10. The backend spawn log shows an argument count instead of the argv, for every user. — rides along

[FIRST-PRINCIPLES-REVIEWED] 6ff9df6

Description read

[DESCRIPTION-READ] f86c0596059da573841ab830a1bb47f02caf2a0ab3ef6f3018be9f7e32404ed6

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 6ff9df6

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

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

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 6ff9df617f4b6b0b9e18bc81581805270a8c8471. 3 of 4 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/agent_materialization/mcp_sources.py:170 -- Live stdio registrations bypass newly enabled signature protections

chosen = _signed_stdio_launch(name, spec, dict(spec), flags, child_env)
Trigger: Register a signed Python MCP app with signature enforcement off, then enable enforcement and rebuild the agent config. _collect_app_mcp_servers verifies the package but takes the existing live spec, bypassing this launch preparation.
Outcome: The next server launches without signed-first loading or bytecode isolation. An unsigned cache entry with a matching header can replace an imported signed source module despite successful package verification.
Anchor: residual/security
Fix: Rebuild live stdio launches from the verified manifest and apply the launch protections; retain live HTTP URL handling separately.
Sites: The live-spec branch at src/kiro_crew/agent_materialization/mcp_sources.py:156, reading persisted registrations from src/kiro_crew/apps/bridges_mcp.py:1164.

BLOCKING -- src/kiro_crew/apps/admission.py:278 -- Absolute executable paths receive the live-UI exemption

if candidate.casefold().startswith("ui/")
Trigger: A signed setup.onEnable command names an absolute installed ui/worker.py path. After the operator grants an out-of-install UI link, _ui_skip omits that absolute declaration from kept, while unsigned_code_path ignores it because its resolved destination is outside the installation.
Outcome: Changing the linked worker passes the package check, and run_lifecycle_script executes the changed executable under the publisher’s unchanged signature.
Anchor: residual/security
Fix: Convert absolute declarations lexically beneath the installation root to inventory-relative paths before calculating the UI exemption.
Sites: Absolute MCP and openCommand declarations collected at src/kiro_crew/apps/package_signature.py:539 and src/kiro_crew/apps/package_signature.py:542; the same exemption is propagated into child verification by src/kiro_crew/apps/admission.py:768.

BLOCKING -- src/kiro_crew/apps/signed_first.py:439 -- Script dispatch resolves its internal dependency through the app

sys.path[:0] = dispatch.launch_entries(target)
dispatch.run_target(target)
Trigger: A signed plain Python backend or stdio script has a sibling signed pkgutil.py without get_importer. The shim exposes the script directory, then deps_boot.run_target calls runpy.run_path, whose internal from pkgutil import get_importer resolves the app module.
Outcome: The child raises ImportError before executing its entry point, although launching that script directly succeeds.
Anchor: residual/crash-data-loss-corruption
Fix: Dispatch ordinary script files without resolving runpy’s internal dependencies through the app’s import path.
Sites: Backend wrapping at src/kiro_crew/apps/backend.py:1259, stdio wrapping at src/kiro_crew/apps/bridges_mcp.py:563, and the shared script dispatch at src/kiro_crew/apps/deps_boot.py:181.

BLOCKING -- test/test_app_package_signature_children.py:177 -- Independent cases cold-start interpreter children across workers

return subprocess.run(
Trigger: The default --dist loadgroup suite schedules this module’s independently collected cases across workers. Numerous cases start fresh interpreters through _shim_run or their own spawn, without a module-scoped child or dedicated group.
Outcome: The shard performs concurrent interpreter cold starts—the contention pattern explicitly prohibited by tests-are-deterministic item 6 because it stalls sharded runs.
Anchor: tests-are-deterministic
Fix: Use a shared module-scoped interpreter harness in a dedicated xdist_group, with indispensable fresh-start exceptions justified individually.
Sites: Additional launches in test/test_app_package_signature_children.py at lines 215, 238, 283, 491, 582, 769 and 910.

[BLOCK-MERGE] 6ff9df6
[GPT-REVIEWED] 6ff9df6

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

F4: This is anchored to tests-are-deterministic item 6 (D8), which .review-base-rules/AUTOSDE.yaml:392 marks blocking: true. Item 6 flags a new test that starts its own real interpreter child when the module's other tests do the same. This whole file is new in the PR (1001 added lines). It has no xdist_group and no module-scoped child, and test/test_app_package_signature_children.py:177, :215, :238 and :283 each spawn a fresh sys.executable. The rule's flag outranks any weighing of harm against remedy cost.
F1–F3 (fenced): I didn't open the code they cite, so I can't build the evidence a FLAG needs. Each stays UPHOLD-FENCED by default.

[ADJUDICATION] 6ff9df617f4b6b0b9e18bc81581805270a8c8471 total=1 uphold=1 downgrade=0
UPHOLD F4 test/test_app_package_signature_children.py:177 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 6ff9df617f4b6b0b9e18bc81581805270a8c8471

[ADJUDICATION-FENCED] 6ff9df617f4b6b0b9e18bc81581805270a8c8471 fenced=3 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/agent_materialization/mcp_sources.py:170 -- Turning on enforcement after an app is registered is a normal operator action, so a live stdio spec that skips the launch protections is a plausible bypass of the signature policy.
UPHOLD-FENCED F2 src/kiro_crew/apps/admission.py:278 -- An absolute path in a signed declaration plus an operator-granted UI link are both conditions the system allows, so running changed code under an unchanged signature is plausible.
UPHOLD-FENCED F3 src/kiro_crew/apps/signed_first.py:439 -- I didn't open the cited code this run, so the evidence needed to FLAG is incomplete and the finding stands as written.
[GPT-ADJUDICATED-FENCED] 6ff9df617f4b6b0b9e18bc81581805270a8c8471

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

@KiroCrewCaptain

KiroCrewCaptain commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Request changes

Why: the decider found 3 problems and estimates an 80% chance that this change introduces a defect, at or above the 80% level where it asks for changes.

I'm requesting changes. The PR's goal is that, on a fleet with require_signature on, a signed app whose files changed is refused at every point where its code is registered or run. The PR's own open-findings list admits paths where that doesn't hold, and I confirmed two of them in the code. First, a stdio MCP spec registered before the policy was turned on is reused on rebuild without the signed launch, so kiro-cli can later start a server with swapped files. Second, a Node backend's npm install runs after the package check and before Node starts, with no recheck in between, so its install scripts can rewrite the signed entry point. Third, by the PR's own account, an absolute-path spelling into ui/ under the dev grant skips the code-path check. Each of these is a fail-open on the trust boundary the PR exists to add. They block even though the description acknowledges them. On top of that, the PR has a merge-conflict label, most CI was still pending, and both AI review lanes had blocking security findings on the previous head that haven't been re-checked on this one.

Problems found:

  • After a fleet turns on require_signature, an agent-config rebuild reuses any stdio MCP spec registered before that point exactly as it was: no signed-first shim, no checked list and no pycache flags. kiro-cli starts that server long after the check, so a signed file swapped in between runs without (src/⁠kiro_crew/agent_materialization/mcp_sources.py, medium)
  • For a signed Node backend with no node_modules, the package check runs before the gateway's npm install. npm lifecycle scripts (including those of dependencies) run in the app folder after that check and can rewrite the signed entry point before Node starts. Code that no longer matches the signatu (src/⁠kiro_crew/apps/backend.py, medium)
  • Under the dev-mode ui/ grant, the code-path check can be skipped by spelling a code path as an absolute path. A changed ui/ script named by setup, openCommand, MCP args or a cron is then registered and run without being checked. The description says that every ui/ code path stays checked, (src/⁠kiro_crew/apps/admission.py, medium)

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 50d3a81de0 · 6559 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 10, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Re First Principles item 9 ("rides along; harm unnamed"): the redaction is not extra scope. This PR adds a new refusal, the signed-package check. Its detailed reason carries the app name and a file path the publisher wrote into signedFiles (packaged file 'backend/app.py' ...). Without the redaction, that text would go into audit rows at every boundary this PR wires. Two things would then hold that do not hold on main:

  • The execution-boundary rows (app_execution_admission) would name the app. On main they deliberately leave the app name out (docs/system-specs/modules/security.md, pinned by test_denial_audit_uses_action_without_untrusted_app_name).
  • Audit rows would carry a publisher-controlled path. No existing refusal row does.

So the fixed classification (signed_package_mismatch / signed_package_unverified) only keeps this PR's own new rows as bare as the existing ones. The detailed reason still goes back to the caller and to the log line.

@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from 6a1d626 to 2c39c00 Compare November 10, 2026 08:19
@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 10, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

This PR and #34469 both fix #34319: they bind an app's signature to its whole manifest and a SHA-256 inventory of its packaged files, and they change 28 of the same files, including src/kiro_crew/apps/admission.py, src/kiro_crew/apps/manifest.py and docs/app-kit/manifest-reference.md. Please keep one of #34390 and #34469 and close the other, carrying over anything only this one has.

@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from 2c39c00 to 15c90a7 Compare November 10, 2026 09:44
@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 10, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from 15c90a7 to ed663bc Compare November 10, 2026 11:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Nov 10, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from ed663bc to d5707f9 Compare November 10, 2026 11:53
@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 10, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from d41223d to 86765be Compare November 11, 2026 00:48
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Nov 11, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from 86765be to 3963552 Compare November 11, 2026 01:20
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 11, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34319-app-signature-files branch from 3963552 to f072509 Compare November 11, 2026 01:52
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 11, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

A maintainer ruling is needed on two GPT 6.1 security-class findings on head c43e134. Both came after the last fix round, so this PR does not change code for them. Both are now under Known limitations in the description.

  1. src/kiro_crew/apps/signed_first.py:392: a backend or stdio MCP server started through the dependency shim does not evict modules the shim already imported. A signed app that ships its own backend/json.py gets the stdlib copy and fails to start with an ImportError. It fails closed: nothing unsigned runs.
  2. src/kiro_crew/apps/admission.py:278: under the operator's out-of-install ui/ dev grant, an absolute setup, openCommand, MCP or cron path into the installed ui/ is not mapped back to an inventory path, so a changed file there is not checked. It needs the host-only dev grant plus a signed manifest that hard-codes that absolute path.

The lane's adjudicator flagged both as edge cases. Options per finding: accept it as a known limitation (an override that records the decision), or ask for a fix in this PR or a follow-up.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebase only: 0ed79db190 is 6e7b967971 on main 549cc1a. The spec section is now §42 (main added §41), and module_loader.py keeps both imports. No code changed.

The re-run lanes raised two findings on this head. Both are added to the open list under the owner's no-more-patches rule, and are not fixed here:

  • Medium: GPT 6.1 on 0ed79db: a Python MCP server started with -S keeps the app folder on its search path, so a replaced signed module (json.py) runs during interpreter startup, before the shim checks digests (src/kiro_crew/apps/signed_first.py:40).
  • Medium: Opus 5.5 on 0ed79db: an unlisted lib/__init__.py (or lib.py) planted beside a listed namespace-package directory lib/ is not flagged by unlisted_package_files and wins the import (src/kiro_crew/apps/signed_first.py:136, :330).

GPT also repeated the listed case-insensitive Worker/ finding (signed_first.py:129). The two fenced findings from earlier rounds still wait for a maintainer ruling.

Backend Tests shard 3 is main's red #37243 (test_back_to_back_rounds_keep_a_spend_bound), not this PR.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebase only: head 50d3a81de0 on main 1dee6bb8ed, to clear a new conflict. Main added its own §42 to app-kit-platform.md, so this PR's section is now §43, and the two links to it in cli.md and security.md say §43. No code changed. The open list for the maintainer ruling is unchanged.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Two things on 50d3a81de0, both left for the next round:

  • It conflicts with main again, less than an hour after the rebase. I rebase each PR once per day, so the next rebase comes then.
  • Backend Tests (3.12, 6) is red in test_mcp_listing_import_budget.py: each of the four servers loads one kiro_crew module more than its ceiling (486 against 485 for mcp-core). feat(security): turn on the structured credential detectors, with owner engine and prompt-and-logs switches #29423 lowered the headroom on 11-14, and this PR's new apps modules most likely add the one. The fix is a +1 on the four ceilings with the reason, or moving the import behind the list. It waits with the open ruling, under the no-more-patches rule.

@CrysisDeu

CrysisDeu commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebase: head 6fa7457c4d on main 10e113c8d6, to clear a conflict in app-kit-platform.md, apps/backend.py and apps/routes.py. Main added its own §43 (memory providers), so this PR's section is now §44, and the links in cli.md and security.md point there. backend.py keeps main's refused_not_spawned_this_run adoption outcome (black-formatted, since this PR takes backend.py off the black baseline), and routes.py keeps main's bot-grant imports beside this PR's admission imports.

Import cap: the same commit raises each ceiling in test/test_mcp_listing_import_budget.py by 2 (mcp-core 490, mcp-cron 360, mcp-guide 354, mcp-mate 355), the counts CI measured on this rebase. The two modules are kiro_crew.apps.package_signature and kiro_crew.apps.signed_first. Every server primes the app config keys at startup (prime_extension_config_keys loads apps.manager, whose owner manager_install imports apps.admission). The admission gate imports both new modules at module level, and apps/manifest.py imports package_signature for FILES_KEY, which keeps the signed-file inventory out of app listings. Their other imports are already loaded by then.

The GPT 6.1 finding on the rebased head (-E lifecycle launches keep stock bytecode) is the one already listed under Known limitations and waits with the open ruling. Nothing else changed.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebase: head 7b28ad35322eacec594beb8c479f6f05939abddd on main 44769dba47, to clear a conflict in app-kit-platform.md, test/test_lifecycle_scripts_cov80.py and test/test_mcp_listing_import_budget.py. Main added its own §44 (app chat launch) and §45 (an app's own agent browses approved pages), so this PR's section is now §46, and the links in cli.md and security.md point there. test_lifecycle_scripts_cov80.py keeps main's import threading beside this PR's from pathlib import Path.

Import cap: main raised each ceiling in test/test_mcp_listing_import_budget.py by 2 on its own (the security.argv_floor_ssh_gate and security.argv_floor_ssh_bodies modules), so this PR's +2 now sits on top of main's: mcp-core 492, mcp-cron 362, mcp-guide 356, mcp-mate 357. The two modules this PR adds are unchanged: kiro_crew.apps.package_signature and kiro_crew.apps.signed_first, loaded through prime_extension_config_keys -> apps.manager -> manager_install -> apps.admission, and through apps/manifest.py for FILES_KEY. Both comments are kept.

No code changed. The open findings and the fenced rulings listed under Known limitations still wait as before.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Head af3d7ef28be476cd0a61bcf8579847e8470c91f7: fixes this PR's own red on 7b28ad3532. Fast Gate's backend-emoji gate (new on main) flagged the three messages this PR adds in _handle_app_sign (src/kiro_crew/cli_commands_app.py). They now start with plain words, as docs/system-specs/common/code-style.md asks: the two refusals read Error: ... and the success line reads Done: signed .... Streams and exit codes are unchanged, no test asserted the old text, and nothing else changed. Still one commit on main 44769dba47; signing rule unchanged since 7b28ad3532.

Under require_signature the app admission gate accepts only signature
scheme 2: an HMAC over the complete app.json object, which carries a
SHA-256 inventory of the packaged files. Install, update, the cloned
registry checkout, enable, boot and restart check the files, and
app_execution_denied applies the same check for every app root it is
given. Unlisted files stay allowed. The builtin exemption needs a
shipped package under the policy. kirocrew app sign writes the
signature. Without the policy nothing changes.

Refs #34319
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Head 6ff9df617f4b6b0b9e18bc81581805270a8c8471: fixes this PR's own process-cache ratchet red on af3d7ef28b. The two caches this PR adds in src/kiro_crew/apps/admission.py (_held_pycache_dirs, _pycache_reapers) hold per-test state, so test/conftest_resets.py now gives each test its own copy through a new autouse fixture, _isolate_app_pycache_holds, the same copy-and-undo as _isolate_context_store_caches. Test-only change: no production code, no baseline edit, no regex. Blind review: LOW-ONLY. Still one commit on main 44769dba47; signing rule unchanged since 7b28ad3532.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Status on head 6ff9df617f4b6b0b9e18bc81581805270a8c8471: not ready, and no new head is pushed.

  • CI red on this head, this PR's own: the new per-test reset _isolate_app_pycache_holds is defined in test/conftest_resets.py but not bound in test/conftest.py, so test_conftest_parts_reach fails on shard 8 (Linux and Windows) and the Coverage Gate fails with it. GPT 6.1 Review also blocks on four findings (live stdio registrations skipping the launch protections once enforcement is on, absolute paths getting the live-UI exemption, runpy resolving an app's own pkgutil.py, interpreter children cold-starting across workers).
  • A fix for all of that exists but is held locally, on branch crew/bug-resolve/34319-r4-held at 76aec7b1ed. It went through four blind review rounds. Round 4 still blocks on a Medium this PR adds: for a signed plain Python script the new direct runner sets runpy.run_path's globals (__file__ as given, __package__ = "", no __annotations__), while launching the script directly, as main does for these apps, gives an absolute __file__, __package__ = None and __annotations__. A signed app that reads those would see something different from main, so it is not pushed.
  • Main's runpy path for apps with provisioned dependencies is kept unchanged on that branch, by decision; an app with its own pkgutil.py next to its script still fails there the same way it does on main.

Next step for whoever picks this up: make the signed-first runner set the globals python script.py sets, re-review, then push the held branch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants