Files
pruefwerk/docs/guide/scanning.md
T
Sharang ParnerkarandClaude Opus 5 ea70777c89
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 6m38s
feat(security): refuse scans aimed at our own network (#256)
Scans are aimed by the customer — a git URL, a live URL, a DAST base URL, a
pentest app URL, a PLC endpoint — and nothing checked where those resolve to.
A tenant could point a scan at `pruefwerk-mongo:27017`, at
`169.254.169.254`, or at `file:///data/compliance-scanner/ssh/id_ed25519`,
and read the result back as findings. Server-side request forgery with a UI
in front of it, and on the blob path a straight local-file read.

New `compliance_core::net_guard`, dependency-free so every crate can use it:

- `check_url` / `check_git_url` — scheme and host rules. http(s) for fetches;
  git additionally allows ssh but never `file://`, `git://` or a bare path
  (including scp-style `git@host:org/repo`).
- `check_ip` — refuses loopback, private, carrier-NAT, link-local (with the
  cloud-metadata address), documentation, benchmarking and reserved ranges,
  in v4, v6 and v4-mapped-v6 form.
- `check_resolved` — resolves a name and requires *every* answer to pass, so
  a host that returns one public and one private address is refused.
- Internal names are refused by shape: single-label hosts (`mongo`,
  `compliance-agent`), `localhost`, `.internal`, `.local`, `.home.arpa`.

Wired in at each place a tenant decides where we connect: git and live-URL
ingest, DAST target creation, DAST scan start (re-resolved at use, not only at
registration), the pentest wizard's app URL, and the ICS probe, which opens
raw TCP connections.

Blob artifacts (firmware, archives, PLC projects, mobile packages) now require
an uploaded `stored_path`. `source_ref` used to be read as a filesystem path
when no upload existed, so an API caller could name any file the agent can
read and ingest it as their own artifact.

On-premise runners legitimately scan private ranges — a Werkbank runner inside
a plant network is aimed at 10.x PLCs on purpose — so `PW_ALLOW_PRIVATE_TARGETS=1`
relaxes the policy. A hardened deployment ignores it: the cloud agent shares a
network with the platform's own services.

Stacked on #254 (`feat/fail-closed-config`) for `AppEnv`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
2026-09-20 23:37:17 +02:00

5.3 KiB

Running Scans

Scans are the primary workflow in Prüfwerk. Each scan analyzes a repository for security vulnerabilities, dependency risks, and code structure.

What Happens During a Scan

When a scan is triggered, Prüfwerk runs through these phases in order:

  1. Clone -- pulls the latest code from the Git remote (or clones it for the first time)
  2. SAST -- runs static analysis using Semgrep with rules covering OWASP, GDPR, OAuth, secrets, and general security patterns
  3. SBOM -- extracts all dependencies using Syft, identifying packages, versions, licenses, and known vulnerabilities via OSV.dev + NVD
  4. CVE Check -- cross-references dependencies against the NVD database for known CVEs
  5. Graph Build -- parses the codebase to construct a code knowledge graph of functions, classes, and their relationships
  6. AI Triage -- new findings are reviewed by an LLM that assesses severity, considers blast radius using the code graph, and generates remediation guidance
  7. Issue Sync -- creates or updates issues in connected trackers (GitHub, GitLab, Gitea, Jira) for new findings

Each phase produces results that are visible in the dashboard as soon as they complete.

How Scans Are Triggered

Manual Scan

  1. Go to Repositories
  2. Click Scan on the repository you want to scan
  3. The scan starts immediately in the background

Scheduled Scans

Repositories are scanned automatically on a recurring schedule. By default, scans run every 6 hours and CVE monitoring runs daily. Your administrator controls these schedules.

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 for setup instructions.

Scan Phases and Statuses

Each scan progresses through these statuses:

Status Meaning
Queued Scan is waiting to start
Running Currently executing scan phases
Completed All phases finished successfully
Failed Stopped due to an error

You can monitor scan progress on the Overview page, which shows the most recent scan runs across all repositories, including the current phase, finding count, and duration.

Scan Types

A full scan runs multiple analysis engines, each producing different types of findings:

Scan Type What It Detects Scanner
SAST Code-level vulnerabilities (injection, XSS, insecure crypto, etc.) Semgrep
SBOM Dependency inventory, outdated packages, known vulnerabilities Syft + OSV.dev/NVD
CVE Known CVEs in dependencies cross-referenced against NVD NVD API
GDPR Personal data handling issues, consent violations Custom rules
OAuth OAuth/OIDC misconfigurations, insecure token handling Custom rules
Secrets Hardcoded credentials, API keys, tokens in source code Custom rules
Code Review Architecture and security patterns reviewed by AI LLM-powered

Where a scan may connect

Git URLs, live URLs, DAST base URLs, pentest app URLs and PLC endpoints all say where the scanner should connect, so they decide what the agent talks to. A cloud deployment therefore accepts publicly routable addresses only, and refuses:

  • loopback, private (10/8, 172.16/12, 192.168/16), carrier-NAT and link-local addresses, including the cloud-metadata address 169.254.169.254;
  • names that only resolve inside a private network — single-label hosts such as mongo, anything ending in .internal or .local, and localhost;
  • file://, git:// and bare filesystem paths as a git remote;
  • blob artifacts that point at a server path instead of an uploaded file.

Hostnames are re-checked and resolved when the scan actually runs, not only when the target is saved, and a name that resolves to both a public and a private address is refused.

On-premise runners are different. A Werkbank runner inside a plant network is aimed at 10.x PLCs on purpose, so it sets PW_ALLOW_PRIVATE_TARGETS=1. A hardened cloud deployment ignores that variable — it shares a network with the platform's own services.

Deduplication and Fingerprinting

Findings are deduplicated using a fingerprint hash based on the scanner, file path, line number, and vulnerability type. This means:

  • Repeated scans will not create duplicate findings for the same issue
  • Tracker issues are only created once per unique finding
  • Resolved findings that reappear in a new scan are flagged for re-review

The fingerprint is also used to match findings to existing tracker issues, preventing duplicate issues from being created in GitHub, GitLab, Gitea, or Jira.

Interpreting Results

After a scan completes, you can explore results in several ways:

  • Findings -- browse all discovered vulnerabilities with filters for severity, type, and status. See Understanding Findings.
  • SBOM -- review your dependency inventory, check for vulnerable packages, and audit license compliance. See SBOM & Licenses.
  • Overview -- check the dashboard for a high-level summary of your security posture across all repositories.
  • Issues -- see which findings have been pushed to your issue tracker. See Issues & Tracking.