feat(security): stop executing code from scanned repositories (#257) #296

Merged
sharang merged 1 commits from feat/no-untrusted-exec into main 2026-09-21 10:28:00 +00:00
1 Commits
Author SHA1 Message Date
Sharang ParnerkarandClaude Opus 5 bf89e57b58 feat(security): stop executing code from scanned repositories (#257)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 5m46s
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
2026-09-21 08:53:44 +02:00