feat(security): seal tenant credentials at rest, never return them (#260)
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) Canceled after 6m28s

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
This commit is contained in:
Sharang ParnerkarandClaude Opus 5 committed 2026-09-21 18:03:00 +02:00
1 parent 85959907b7
commit b89f31e2d3
34 files changed
+1176 -262

No files matched your search

-1
View File
@@ -68,7 +68,6 @@ From the edit modal you can:
- Change the repository name, Git URL, or default branch
- Add, modify, or remove issue tracker configuration
- View the webhook URL and secret for this repository (see [Webhooks & PR Reviews](/guide/webhooks))
## Repository List
+1 -1
View File
@@ -30,7 +30,7 @@ Repositories are scanned automatically on a recurring schedule. By default, scan
### Webhook-Triggered Scans
When you configure a webhook in your Git hosting provider, scans are triggered automatically on push events. You can also get automated PR reviews. See [Webhooks & PR Reviews](/guide/webhooks) for setup instructions.
When you configure a webhook in your Git hosting provider, scans are triggered automatically on push events. You can also get automated PR reviews. Webhooks are not available in this release yet; see [Webhooks & PR Reviews](/guide/webhooks).
### When scans overlap
+9 -6
View File
@@ -7,14 +7,17 @@ Webhooks let Prüfwerk respond to events in your Git repositories automatically.
- **Automatic scans on push** -- every time code is pushed to your default branch, a scan is triggered automatically
- **PR security reviews** -- when a pull request is opened or updated, Prüfwerk scans the changes and posts a review comment summarizing any security findings in the diff
::: warning Not available yet
Prüfwerk does not issue webhook secrets yet, and it rejects every webhook
delivery for a repository that has no secret, so webhooks cannot be set up in
this release. Scans run on their schedule or when you start them. The setup
below applies once webhook secrets can be issued again.
:::
## Finding the Webhook URL and Secret
Each repository in Prüfwerk has its own webhook URL and secret:
1. Go to **Repositories**
2. Click **Edit** on the repository you want to configure
3. In the edit modal, you will find the **Webhook URL** and **Webhook Secret**
4. Copy both values -- you will need them when configuring your Git hosting provider
Each repository gets its own webhook URL and secret. Prüfwerk stores the
secret encrypted and never returns it from the API.
## Setting Up Webhooks