Part 1 of #260 (MVP-0.7), agent side. The dashboard part (session key, Secure cookie, Mongo session store, open redirect, webhook proxy) follows in a separate PR.
⚠️Deploy order: merge and deploy platform/orca-platform#25 (sets SECRETS_ENCRYPTION_KEY on stage) first. With APP_ENV=staging the agent refuses to start without the key.
Problem
Git tokens, tracker tokens, webhook secrets and pentest passwords were stored in plain text.
The API returned them on GET /targets/{id}, the target list, DAST targets and pentest sessions.
The MCP pentest tools handed session auth to LLM clients.
pentest/crypto.rs silently stored plain text when no key was set.
Pentest sessions were inserted in plain text and encrypted afterwards.
A target without a webhook secret accepted unsigned webhook deliveries.
Change
secrets::SecretBox (AES-256-GCM, key SECRETS_ENCRYPTION_KEY, sealed values stored as enc:v1:…).
With no key, seal fails; nothing is ever stored in plain text.
The key is required when APP_ENV is staging or production. A malformed key stops startup in every environment.
It replaces pentest/crypto.rs (renamed from PENTEST_ENCRYPTION_KEY, which staging never set).
compliance_core::models::Credentials lists each record's credential fields once:
artifact auth secret and auth headers
tracker token
webhook secret
pentest password and IMAP password
DAST auth
The same list drives sealing before writes and redaction in every target, DAST-target and pentest-session response, including the MCP list/get_pentest_session tools.
PATCH /targets/{id}: a credential left out keeps its stored value, "" clears it, and a new value is sealed. The API never returns credentials, so a client echoing a record back cannot erase them.
Reading for use: credentials are opened where they're needed: the git clone (RepoView, ingest), tracker calls, webhook verification, and the pentest prompt (open_in_place). A value that can't be opened is logged and treated as absent. It is never sent as a wrong credential.
Startup: plain-text credentials already stored are sealed once, streamed per tenant.
Webhooks fail closed: no secret, or one that can't be opened, gives 401. GitLab tokens are compared in constant time (subtle). New targets no longer get a webhook secret at creation.
Decisions
Asked Jev, with a neutral description and no code:
Question
Pick
Probability
Webhooks: fix end to end now, or remove and restore later
Remove
0.97 (confidence 0.94)
Reject deliveries for targets with no secret
Yes
0.93
How users get a secret later
Shown once when issued, rather than a rotate endpoint
0.70 vs 0.29
I left secret delivery out of this PR: webhooks aren't reachable after the dashboard PR removes the broken proxy, so it belongs with the webhook restore. I'll file it.
Not in this PR
The platform export still dumps raw collections. Credentials in it are now ciphertext only; stripping them belongs to the planned export rework (MVP-1 lifecycle).
PentestConfig.custom_headers is left as is. Pentest is off in production.
Found while mapping this (not fixed here):
No API path lets a user enter a git token for a private repo; ArtifactInput has no auth. The pilot needs one.
PATCH with artifacts rebuilds them and drops any stored artifact auth.
The dashboard's enable_target_scans PATCHes scan_config with only enabled_scans, which removes the tracker config.
I'll file all three.
Verification
cargo fmt --check, clippy -D warnings on all CI targets, and cargo audit pass.
SecretBox: round trip, fresh nonce, no key fails closed, malformed keys, wrong key or tampered value, legacy plain text, the update carry-over rules.
Credentials: every field listed; the redacted JSON contains no secret.
New Mongo integration test tests/credentials.rs:
A tracker token set through PATCH is stored sealed, is absent from the PATCH, GET and list responses (plain text and ciphertext alike), survives a PATCH that leaves it out, and is cleared by "".
The startup pass seals legacy plain-text values that still open, and a second run is a no-op.
The GitHub webhook gives 401 for a target without a secret and 401 for a bad signature, and accepts a correct signature.
With a target seeded the way older releases stored it, startup logged sealed stored credentials targets=1. Mongo then held enc:v1: values, and GET /targets returned token: null and no webhook_secret.
SECRETS_ENCRYPTION_KEY=nothex stops startup with SECRETS_ENCRYPTION_KEY must be 64 hex characters.
Part 1 of #260 (MVP-0.7), agent side. The dashboard part (session key, Secure cookie, Mongo session store, open redirect, webhook proxy) follows in a separate PR.
> ⚠️ **Deploy order:** merge and deploy **platform/orca-platform#25** (sets `SECRETS_ENCRYPTION_KEY` on stage) first. With `APP_ENV=staging` the agent refuses to start without the key.
## Problem
- Git tokens, tracker tokens, webhook secrets and pentest passwords were stored in plain text.
- The API returned them on `GET /targets/{id}`, the target list, DAST targets and pentest sessions.
- The MCP pentest tools handed session auth to LLM clients.
- `pentest/crypto.rs` silently stored plain text when no key was set.
- Pentest sessions were inserted in plain text and encrypted afterwards.
- A target without a webhook secret accepted **unsigned** webhook deliveries.
## Change
- **`secrets::SecretBox`** (AES-256-GCM, key `SECRETS_ENCRYPTION_KEY`, sealed values stored as `enc:v1:…`).
- With no key, `seal` fails; nothing is ever stored in plain text.
- The key is required when `APP_ENV` is staging or production. A malformed key stops startup in every environment.
- It replaces `pentest/crypto.rs` (renamed from `PENTEST_ENCRYPTION_KEY`, which staging never set).
- **`compliance_core::models::Credentials`** lists each record's credential fields once:
- artifact auth secret and auth headers
- tracker token
- webhook secret
- pentest password and IMAP password
- DAST auth
The same list drives sealing before writes and redaction in every target, DAST-target and pentest-session response, including the MCP `list/get_pentest_session` tools.
- **PATCH `/targets/{id}`:** a credential left out keeps its stored value, `""` clears it, and a new value is sealed. The API never returns credentials, so a client echoing a record back cannot erase them.
- **Reading for use:** credentials are opened where they're needed: the git clone (`RepoView`, ingest), tracker calls, webhook verification, and the pentest prompt (`open_in_place`). A value that can't be opened is logged and treated as absent. It is never sent as a wrong credential.
- **Startup:** plain-text credentials already stored are sealed once, streamed per tenant.
- **Webhooks fail closed:** no secret, or one that can't be opened, gives 401. GitLab tokens are compared in constant time (`subtle`). New targets no longer get a webhook secret at creation.
## Decisions
Asked Jev, with a neutral description and no code:
| Question | Pick | Probability |
|---|---|---|
| Webhooks: fix end to end now, or remove and restore later | **Remove** | 0.97 (confidence 0.94) |
| Reject deliveries for targets with no secret | **Yes** | 0.93 |
| How users get a secret later | Shown once when issued, rather than a rotate endpoint | 0.70 vs 0.29 |
I left secret delivery out of this PR: webhooks aren't reachable after the dashboard PR removes the broken proxy, so it belongs with the webhook restore. I'll file it.
## Not in this PR
- The platform `export` still dumps raw collections. Credentials in it are now ciphertext only; stripping them belongs to the planned export rework (MVP-1 lifecycle).
- `PentestConfig.custom_headers` is left as is. Pentest is off in production.
- **Found while mapping this (not fixed here):**
- No API path lets a user enter a git token for a private repo; `ArtifactInput` has no auth. The pilot needs one.
- `PATCH` with `artifacts` rebuilds them and drops any stored artifact auth.
- The dashboard's `enable_target_scans` PATCHes `scan_config` with only `enabled_scans`, which removes the tracker config.
I'll file all three.
## Verification
- `cargo fmt --check`, clippy `-D warnings` on all CI targets, and `cargo audit` pass.
- Lib tests pass: core 77, agent 363, werkbank-exec 9, control-map 28, dashboard 21, MCP 34.
- New unit tests:
- `SecretBox`: round trip, fresh nonce, no key fails closed, malformed keys, wrong key or tampered value, legacy plain text, the update carry-over rules.
- `Credentials`: every field listed; the redacted JSON contains no secret.
- New Mongo integration test `tests/credentials.rs`:
- A tracker token set through `PATCH` is stored sealed, is absent from the PATCH, GET and list responses (plain text and ciphertext alike), survives a PATCH that leaves it out, and is cleared by `""`.
- The startup pass seals legacy plain-text values that still open, and a second run is a no-op.
- The GitHub webhook gives 401 for a target without a secret and 401 for a bad signature, and accepts a correct signature.
- Existing Mongo suites pass: `lifecycle`, `werkbank_queue`, `werkbank_api`, `tenant_isolation`, `demo_seed`, `tenant_status_middleware`.
- Real binary:
- With a target seeded the way older releases stored it, startup logged `sealed stored credentials targets=1`. Mongo then held `enc:v1:` values, and `GET /targets` returned `token: null` and no `webhook_secret`.
- `SECRETS_ENCRYPTION_KEY=nothex` stops startup with `SECRETS_ENCRYPTION_KEY must be 64 hex characters`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Git tokens, tracker tokens, webhook secrets and pentest passwords were stored
in plain text and returned by the API. The old crypto helper fell back to
plain text when no key was set.
- `secrets::SecretBox`: AES-256-GCM under `SECRETS_ENCRYPTION_KEY`, with sealed
values stored as `enc:v1:…`. With no key it refuses to seal instead of
storing plain text. The key is required when APP_ENV is hardened, and a
malformed key stops startup in every environment. It replaces
`pentest/crypto.rs`.
- `compliance_core::models::Credentials` lists each record's credential fields
once. The agent seals them before a write and redacts them from every target,
DAST target and pentest-session response, including the MCP pentest tools.
- `PATCH /targets/{id}`: a credential left out keeps its stored value, an
empty string clears it, and a new one is sealed. A client echoing a redacted
record back therefore cannot erase a token.
- Pentest sessions are sealed before the first insert. Previously they were
inserted in plain text and encrypted afterwards.
- On startup the agent seals credentials that were stored in plain text.
- Webhook receivers fail closed: a target without a usable secret gets 401
instead of unsigned acceptance. GitLab tokens are compared in constant time.
New targets no longer get a webhook secret at creation; issuing one comes
back with the webhook work.
Part 1 of #260 (agent). Dashboard session hardening, the open redirect and
the webhook proxy follow in a separate PR.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
The dashboard seals its session records with the same scheme, so the crypto
moves to `compliance_core::secret_box` behind a `secrets` feature. The agent's
`secrets` module keeps the startup sealing pass and re-exports the type.
`from_key` takes raw key bytes, and `has_key` replaces the private field check.
The agent no longer depends on aes-gcm directly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part 1 of #260 (MVP-0.7), agent side. The dashboard part (session key, Secure cookie, Mongo session store, open redirect, webhook proxy) follows in a separate PR.
Problem
GET /targets/{id}, the target list, DAST targets and pentest sessions.pentest/crypto.rssilently stored plain text when no key was set.Change
secrets::SecretBox(AES-256-GCM, keySECRETS_ENCRYPTION_KEY, sealed values stored asenc:v1:…).sealfails; nothing is ever stored in plain text.APP_ENVis staging or production. A malformed key stops startup in every environment.pentest/crypto.rs(renamed fromPENTEST_ENCRYPTION_KEY, which staging never set).compliance_core::models::Credentialslists each record's credential fields once:The same list drives sealing before writes and redaction in every target, DAST-target and pentest-session response, including the MCP
list/get_pentest_sessiontools.PATCH
/targets/{id}: a credential left out keeps its stored value,""clears it, and a new value is sealed. The API never returns credentials, so a client echoing a record back cannot erase them.Reading for use: credentials are opened where they're needed: the git clone (
RepoView, ingest), tracker calls, webhook verification, and the pentest prompt (open_in_place). A value that can't be opened is logged and treated as absent. It is never sent as a wrong credential.Startup: plain-text credentials already stored are sealed once, streamed per tenant.
Webhooks fail closed: no secret, or one that can't be opened, gives 401. GitLab tokens are compared in constant time (
subtle). New targets no longer get a webhook secret at creation.Decisions
Asked Jev, with a neutral description and no code:
I left secret delivery out of this PR: webhooks aren't reachable after the dashboard PR removes the broken proxy, so it belongs with the webhook restore. I'll file it.
Not in this PR
The platform
exportstill dumps raw collections. Credentials in it are now ciphertext only; stripping them belongs to the planned export rework (MVP-1 lifecycle).PentestConfig.custom_headersis left as is. Pentest is off in production.Found while mapping this (not fixed here):
ArtifactInputhas no auth. The pilot needs one.PATCHwithartifactsrebuilds them and drops any stored artifact auth.enable_target_scansPATCHesscan_configwith onlyenabled_scans, which removes the tracker config.I'll file all three.
Verification
cargo fmt --check, clippy-D warningson all CI targets, andcargo auditpass.SecretBox: round trip, fresh nonce, no key fails closed, malformed keys, wrong key or tampered value, legacy plain text, the update carry-over rules.Credentials: every field listed; the redacted JSON contains no secret.tests/credentials.rs:PATCHis stored sealed, is absent from the PATCH, GET and list responses (plain text and ciphertext alike), survives a PATCH that leaves it out, and is cleared by"".lifecycle,werkbank_queue,werkbank_api,tenant_isolation,demo_seed,tenant_status_middleware.sealed stored credentials targets=1. Mongo then heldenc:v1:values, andGET /targetsreturnedtoken: nulland nowebhook_secret.SECRETS_ENCRYPTION_KEY=nothexstops startup withSECRETS_ENCRYPTION_KEY must be 64 hex characters.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Git tokens, tracker tokens, webhook secrets and pentest passwords were stored in plain text and returned by the API. The old crypto helper fell back to plain text when no key was set. - `secrets::SecretBox`: AES-256-GCM under `SECRETS_ENCRYPTION_KEY`, with sealed values stored as `enc:v1:…`. With no key it refuses to seal instead of storing plain text. The key is required when APP_ENV is hardened, and a malformed key stops startup in every environment. It replaces `pentest/crypto.rs`. - `compliance_core::models::Credentials` lists each record's credential fields once. The agent seals them before a write and redacts them from every target, DAST target and pentest-session response, including the MCP pentest tools. - `PATCH /targets/{id}`: a credential left out keeps its stored value, an empty string clears it, and a new one is sealed. A client echoing a redacted record back therefore cannot erase a token. - Pentest sessions are sealed before the first insert. Previously they were inserted in plain text and encrypted afterwards. - On startup the agent seals credentials that were stored in plain text. - Webhook receivers fail closed: a target without a usable secret gets 401 instead of unsigned acceptance. GitLab tokens are compared in constant time. New targets no longer get a webhook secret at creation; issuing one comes back with the webhook work. Part 1 of #260 (agent). Dashboard session hardening, the open redirect and the webhook proxy follow in a separate PR. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p