feat(platform): isolate tenants on disk, in the runner API and on webhooks (#255)
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
This commit is contained in:
1 parent
eef3ccdf43
commit
c7fc7af249
31 files changed
+729
-349
No files matched your search
@@ -20,7 +20,7 @@ Click **New Pentest** on the dashboard to open the 4-step onboarding wizard:
|
||||
### Step 1 — Target & Scope
|
||||
|
||||
- **App URL** — enter manually or select from existing DAST targets (dropdown)
|
||||
- **Git Repository URL** — enter manually or select from tracked repositories (dropdown). If an SSH URL is selected, the deploy key is displayed for easy copy
|
||||
- **Git Repository URL** — enter manually or select from tracked repositories (dropdown). HTTPS URLs only; an SSH URL prompts you to use the HTTPS one with a read-only token instead
|
||||
- **Branch / Commit** — auto-populated when you click **Lookup** for a tracked repo
|
||||
- **App Type** and **Rate Limit**
|
||||
|
||||
|
||||
+13
-11
@@ -8,7 +8,7 @@ Repositories are the core resource in Prüfwerk. Each tracked repository is scan
|
||||
2. Click **Add Repository**
|
||||
3. Fill in the form:
|
||||
- **Name** -- a display name for the repository
|
||||
- **Git URL** -- the clone URL (HTTPS or SSH), e.g. `https://github.com/org/repo.git` or `git@github.com:org/repo.git`
|
||||
- **Git URL** -- the HTTPS clone URL, e.g. `https://github.com/org/repo.git`
|
||||
- **Default Branch** -- the branch to scan, e.g. `main` or `master`
|
||||
4. Click **Add**
|
||||
|
||||
@@ -20,21 +20,23 @@ The repository appears in the list immediately. It will not be scanned until you
|
||||
|
||||
**Public repositories** can be cloned using an HTTPS URL with no additional setup.
|
||||
|
||||
**Private repositories** require SSH access. When you add a repository with an SSH URL (e.g. `git@github.com:org/repo.git`), Prüfwerk uses an SSH deploy key to authenticate.
|
||||
**Private repositories** are cloned over HTTPS with a token you supply. Add the repository's HTTPS URL and, in the credentials section, a read-only access token for it.
|
||||
|
||||
### Getting the SSH Public Key
|
||||
### Creating a Token
|
||||
|
||||
To grant Prüfwerk access to a private repository:
|
||||
1. Create a read-only token in your Git hosting provider, scoped to the repository you are onboarding:
|
||||
- **GitHub**: Settings > Developer settings > Personal access tokens (fine-grained), repository access limited to that repository, *Contents: Read-only*
|
||||
- **GitLab**: Repository Settings > Repository > Deploy tokens, scope `read_repository`
|
||||
- **Gitea**: Settings > Applications > Access tokens, scope `read:repository`
|
||||
2. Add the repository in Prüfwerk with its **HTTPS** URL
|
||||
3. Paste the token into the repository's credentials
|
||||
|
||||
1. Go to the **Repositories** page
|
||||
2. The platform's SSH public key is available for copying
|
||||
3. Add this key as a **deploy key** in your Git hosting provider:
|
||||
- **GitHub**: Repository Settings > Deploy keys > Add deploy key
|
||||
- **GitLab**: Repository Settings > Repository > Deploy keys
|
||||
- **Gitea**: Repository Settings > Deploy Keys > Add Deploy Key
|
||||
::: warning SSH URLs are not supported
|
||||
`ssh://…` and `git@host:org/repo.git` URLs are rejected. Each tenant's token belongs to that tenant only; there is no shared platform deploy key, and adding one would mean every tenant's clones authenticating as the same identity. Per-tenant SSH keys are planned for a later release.
|
||||
:::
|
||||
|
||||
::: tip
|
||||
Deploy keys are scoped to a single repository and are read-only by default. This is the recommended approach for granting Prüfwerk access to private code.
|
||||
Scope the token to a single repository and to read-only access. That is the smallest credential that lets Prüfwerk clone your code.
|
||||
:::
|
||||
|
||||
## Configuring an Issue Tracker
|
||||
|
||||
Reference in new issue
Block a user