Most of the pipeline reads customer code. Four stages ran it — inside the
agent container, as root, with the Mongo URI, the Keycloak and registry client
secrets and the LLM key in the environment, and a database user that reaches
every tenant:
- `cargo clippy` compiles the repo, so its `build.rs` and proc macros run;
- ESLint is executed from the repo's own `node_modules/.bin`, and its config
files are JavaScript;
- `pip-compile` builds source distributions to read metadata, running `setup.py`;
- the firmware reproducible build shells out to Nix with `sandbox = false`.
Scanning hostile code is the job, so new `compliance_core::ExecPolicy` gates
all four. It is off by default and a hardened deployment ignores the
`PW_ALLOW_UNTRUSTED_CODE_EXEC` opt-out, which stays for single-tenant and
sandboxed deployments. Dependency resolution is unaffected: npm already runs
`--package-lock-only --ignore-scripts`, and `cargo generate-lockfile` and
`cargo metadata` resolve without compiling. A complete firmware SBOM comes from
an imported Firmwerk bundle (#280) instead of a build here.
Every external tool now spawns through `pipeline::tool_cmd`:
- an empty environment plus a named allowlist (PATH, HOME, TMPDIR, LANG, and a
tool's own cache variables), so semgrep, syft, gitleaks, ruff, cargo and npm
no longer inherit the agent's credentials;
- `kill_on_drop`, because a tokio child outlives its timeout otherwise — the
comment claiming a timed-out scanner was SIGKILLed was wrong;
- a bounded run for the lockfile and metadata commands, which had no timeout.
Part of #253 · MVP-0 safety baseline.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p