A security audit found five ways one tenant could reach another tenant's
data or act on its behalf. All five are closed here.
1. Clone directories were shared. Every producer and consumer resolved a
checkout to `<git_clone_base>/<sanitized-name>`, so two tenants that
onboarded a target with the same name got one directory: the second one
to scan fetched the first one's `origin` instead of cloning its own, and
then scanned it. Checkouts are now `<base>/<tenant>/<name>` through a
single helper, `pipeline::git::clone_dir`, which every call site uses —
the orchestrator, PR review, ingest, the graph build, the chat embedding
build and the file-content reader. Both segments collapse to one safe
path component, and the tenant segment additionally carries a digest
whenever collapsing was lossy, so two distinct tenant ids can never map
to one directory.
2. One SSH deploy key authenticated every tenant's clone. A tenant that
added the agent's key to a repository made that repository readable by
any other tenant that named its URL. Per-tenant key management is R1, so
at MVP the key is gone entirely: `RepoCredentials` is HTTPS-token only,
an `ssh://`/`git@` URL is rejected with a message pointing at the HTTPS
URL and a token, and `SSH_KEY_PATH`, the generator, the
`/api/v1/settings/ssh-public-key` endpoint, the dashboard panel that
advertised the key and the onboarding docs are all removed.
3. `serve_artifact` had no tenant check. Runner blobs are addressed by
content hash and the hash is in the job record, so any valid runner key
could fetch any tenant's control-logic source. The blob store is now per
tenant (`<base>/tenants/<tenant>/blobs/…`) and the read is bound to the
tenant the key is bound to; another tenant's digest is simply not there.
4. The runner scope check accepted the `werkbank:runner` scope *or* any key
whose product was `pruefwerk`, which made every product API key a runner
key able to lease and complete other tenants' jobs. The scope is now
required.
5. Webhooks created databases before authenticating. A POST with any
`tenant_id` reached `for_tenant_id`, whose index-ensure materializes
`<prefix>_<tenant_id>` — an unauthenticated write primitive. The target
lookup now goes through `DatabasePool::for_existing_tenant_id`, which
creates nothing; an unknown tenant or target is a 404.
Also: the static `WERKBANK_RUNNER_TOKEN` names no tenant, so a holder acts
for all of them. It is still accepted in dev, where it is the only option
before the platform is wired up, and refused when `app_env.is_hardened()`.
URL-scheme and SSRF validation (file://, local paths, server-side
`source_ref`) is deliberately untouched — that is #256.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Demonstration plan, phase D3: on staging `BREAKPILOT_BASE_URL` points at `api-dev.breakpilot.ai`, which answers 401 until the dsms migration (M-MIG-9, parked). Control mapping was gated on that URL, so demo scans produce findings with **no control references** — the one thing a CRA prospect looks for.
The catalog loader already snapshotted the bytes it fetched and fell back to them when the backend was down. This promotes the snapshot to a real source:
- `OscalControlsProvider` takes `Option<String>` for the base URL; with `None` it serves snapshots only, and `has_snapshots()` decides whether control triage runs at all.
- The agent image ships `compliance-agent/controls/snapshot/oscal-catalog-cra.json` — CRA Annex I, 8 groups / 40 controls, generated by breakpilot-compliance's own `build_cra_catalog()`, so it is byte-identical to what `?framework=cra` serves. The entrypoint copies it into `BREAKPILOT_SNAPSHOT_DIR` only if that file is absent, so a snapshot fetched from a live backend (or a mounted volume) always wins.
- `scripts/refresh-oscal-snapshot.sh` regenerates the committed snapshots from a backend when one is reachable.
- A test asserts the shipped file parses and still carries 40 controls, so a bad refresh cannot silently disable mapping.
`master-controls` is DB-derived (~3k controls) and is not shipped, so the semantic pass stays a no-op offline; staging should set `BREAKPILOT_SEMANTIC_MAPPING=false` and drop `BREAKPILOT_BASE_URL` (separate orca-platform change). Deterministic LUT triage and the grounded surface checks then run against the CRA catalog and findings carry `control_refs`.
Verified locally: `cargo fmt --all --check`, `cargo clippy -p compliance-agent -- -D warnings`, `cargo test -p compliance-agent --lib` (314 passed).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #250
The PR `check` job authenticates the private tramiton-core git fetch, but the main-branch **`deploy-agent`** job builds `Dockerfile.agent` where cargo also fetches tramiton-core — inside the image build, with no credentials — so **agent image builds on main fail**.
Fix: inject the PAT as a **BuildKit secret** (never baked into an image layer).
- `Dockerfile.agent`: `RUN --mount=type=secret,id=tramiton_token …` applies the same `https`-insteadOf rewrite + `CARGO_NET_GIT_FETCH_WITH_CLI=true` before `cargo build`.
- `deploy-agent`: `DOCKER_BUILDKIT=1 docker build --secret id=tramiton_token,env=TRAMITON_FETCH_TOKEN …`, reusing the existing `TRAMITON_FETCH_TOKEN` secret.
Only the agent image depends on tramiton-core (dashboard/mcp/docs unaffected). **Self-tests on merge** — changing `Dockerfile.agent` makes `detect-changes` run `deploy-agent`.
Note: couldn't fully run the image build locally (no PAT value on hand + no `.dockerignore` so the context is large), but this mirrors the working PR-stage auth and uses standard BuildKit secret injection. Assumes the deploy runner's Docker daemon supports BuildKit (docker:27-cli → yes).
---------
Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: https://gitea.meghsakha.com/sharang/compliance-scanner-agent/pulls/143
- Fetch SSH public key every time auth section opens (was only fetching
once and caching failures)
- Add mkdir for SSH key directory in Dockerfile.agent
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>