diff --git a/docs/design/active-testing-in-production.md b/docs/design/active-testing-in-production.md index a8f2951..be96761 100644 --- a/docs/design/active-testing-in-production.md +++ b/docs/design/active-testing-in-production.md @@ -1,7 +1,7 @@ -# Active testing: a throwaway copy first, the live system as an add-on +# Active testing: a throwaway copy first, the live system later -**Status:** proposed design for the user to decide (t83) · 2026-11-06. Nothing is enabled -by this note. +**Status:** proposed design for the user to decide (t83) · 2026-11-06, revised +2026-11-07 after the registry review. Nothing is enabled by this note. **Not published:** `docs/design/` is excluded from the documentation site. ## Summary @@ -14,19 +14,20 @@ Production can import results from a test someone else ran (#337, #349). **The proposal: active tests run against a throwaway copy by default.** 1. **The Prüfumgebung (default).** We build the customer's application from the repository - Prüfwerk already has. It is started in a short-lived, isolated sandbox, with an - internal network only and no outbound traffic while testing. DAST and the automated - pentest run against that copy only. Then everything is thrown away. We never send - traffic to a customer's server. + Prüfwerk already has. It is built and started in a short-lived, isolated sandbox. While + building, the only way out is a package mirror; while testing, the network is internal + only. DAST and the automated pentest run against that copy only. Then everything is + thrown away. We never send traffic to a customer's server. 2. **The code graph steers the test.** Routes taken from the code say what to test, instead of a crawl guessing. A static finding that an entry point reaches is tried against the copy. It is then reported as *confirmed exploitable* or *possible*. -3. **Live testing is an optional add-on**, off by default and switched on per tenant. - It is for what only the live system shows: TLS, headers, exposed ports, WAF, cloud - configuration. It needs written authorisation, our source IPs, rate limits and - complaint handling. -4. **Price per run**, in a Testtag unit like the Prüftag. A run costs a build plus a - sandbox, so it can't be unlimited. +3. **Live testing is not part of phase 1.** It would cover what only the live system + shows: TLS, headers, exposed ports, WAF, cloud configuration. It needs written + authorisation, our source IPs, rate limits and complaint handling, and that load is + out of proportion for now. The analysis below (L1–L7) stays so it can be decided later. +4. **Price per Testtag**, a unit like the Prüftag: up to 3 runs of one target on one day. + A run costs a build plus a sandbox, so it can't be unlimited. The customer books a + Testtag only by starting a run, and can cap them per month. **Why the copy first:** @@ -73,7 +74,7 @@ All of this was checked against `origin/main` (168cbe9). | Gap | Today | Needed | | --- | --- | --- | -| Network isolation | The container joins **the agent's own network** (`--network cfg.network`), so it can reach the agent, Mongo and the internet. | A fresh `docker network create --internal` per run, holding only the copy, its dependencies and the test tools. Nothing else is reachable, and nothing leaves. | +| Network isolation | The container joins **the agent's own network** (`--network cfg.network`), so it can reach the agent, Mongo and the internet. | Building: outbound only through a package mirror (below). Testing: a fresh `docker network create --internal` per run, holding only the copy, its dependencies and the test tools. Nothing else is reachable, and nothing leaves. | | Building | It runs a ready-made OpenPLC image. | Build the customer's image from their Dockerfile or Compose file (below). | | Several containers | one | A Compose project: the app plus a database, cache and so on. | | Readiness | A fixed Modbus/WebVisu port. | A health URL from the Prüfprofil, with a deadline. | @@ -143,6 +144,56 @@ file in the repository (`.breakpilot/pruefprofil.yml`) or a form on the target p - The detailed runner and isolation design is a follow-up, written and reviewed with infra before any code. +### The build needs the network + +Building a Dockerfile already runs customer code: every `RUN` step is a command from the +repository. It also downloads packages (npm, NuGet, pip, Maven, apt). So the build is as +untrusted as the test and gets the same protection: + +- **The same VM sandbox** as the test, on the same runner, never on a platform node. +- **Outbound traffic only through a package mirror.** The build network reaches a + pull-through proxy for the public registries (npm, NuGet, PyPI, Maven Central, Debian + and Alpine mirrors, Docker Hub through Harbor) and nothing else. No other egress: no + DNS to the outside, no Git clones from arbitrary hosts, no `curl` to the internet. A + build that needs anything else fails, and the build log says which host it tried. +- **The test phase stays internal-only.** The built images move to a fresh internal + network without the mirror; the test tools join it there. +- **Base images** come through the same Harbor proxy, so they are cached and logged. + +**Private package feeds** need real credentials, and the Prüfprofil forbids those. Two +options: + +1. **Not supported in phase 1** (recommended). A build that needs a private feed fails + as the customer's input, and the Probelauf shows it for free. The customer can vendor + the packages into the repository or publish a build image to us instead. +2. **Later: a feed token stored separately.** It is stored in the tenant's secret store, + not in the Prüfprofil; write-only from the portal, so nobody reads it back after + saving; scoped read-only to that one feed; and injected only into the build step as a + BuildKit secret, never into the image, the test phase or a log. The mirror allowlist + then gets that feed's host for this tenant only. + +### Where the data lives and when it is deleted + +The runner host is a new place where customer code is processed, so: + +- **Location:** in Germany. If it is not our own hardware, the provider goes on the AVV's + subprocessor list before the first customer run. +- **TOM:** the runner (VM isolation, egress only through the mirror, deletion after each + run, access only for the platform team) is added to the technical and organisational + measures. +- **During a run:** the checkout, images, containers, volumes and networks exist only on + the runner, on the run's own disk, and are removed at the end of the run, with a reaper + for leftovers. Nothing is pushed to a registry. +- **After a run, on the platform** (in the tenant's database, like scan results): + - the findings; + - the build log and the start log, capped in size and passed through the secret + scanner before storing. + + They are deleted with the target or the tenant, or after a retention period to be set + (proposed: logs 90 days, findings like other findings). +- **The runner keeps no customer data** after a run. Its own logs carry run ids and + counts, never code, paths or repository names. + ### What qualifies and what doesn't | Target | Prüfumgebung | Notes | @@ -163,11 +214,19 @@ customer find this out before paying (see the next section). ### When the build fails -| Cause | Example | Charged | +The Testtag is what is billed, not the run. A **successful run** is one that built, +started and finished its test (a run stopped at its time limit, with what it found, +counts as finished). + +| Cause | Example | Counts toward the 3 runs | | --- | --- | --- | -| Ours | The runner fails, our time limit is hit through our own load, a toolchain we claim to support is missing | **no**; the run is retried or refunded | +| Ours | The runner fails, our time limit is hit through our own load, a toolchain we claim to support is missing | **no**; the customer can start another run | | The customer's input | The Dockerfile doesn't build, the health URL never answers, the Prüfprofil is missing or wrong | **yes**, as with t72's "failures on the customer's input count" | -| Probelauf | Only build and start, then a health check, with no test | **never charged**, so the customer can fix their profile for free | +| Probelauf | Only build and start, then a health check, with no test | **no**, and it books no Testtag, so the customer can fix their profile for free | + +**A Testtag with no successful run is not charged**, whatever the cause. A customer whose +three runs all fail on their own Dockerfile has used up the day but pays nothing; the +Probelauf should have caught it first. The run's page shows which of these it was, with the build log, so the customer can fix their side. @@ -195,10 +254,17 @@ their side. The benefit: fewer false alarms in front of the customer, and a smaller LLM budget, because the pentest starts from known routes and known suspects instead of exploring. -### 3. Live testing (optional add-on) +### 3. Live testing (not in phase 1) Live testing covers what a copy can't show: TLS, security headers, exposed ports, WAF -behaviour and cloud configuration. Off by default; switched on per tenant. +behaviour and cloud configuration. + +**Recommendation: leave it out of phase 1 entirely** and decide later. The legal work +(authorisation clause, ownership proof), the complaint handling and the operations +(published IPs, abuse contact, kill switches) are a fixed load that a small add-on +price doesn't carry: the earlier suggestion of 29 € a month with 5 runs is too low for it. +The analysis stays here so the decision can be made on it later. If it comes, it is off +by default and switched on per tenant. **Conditions:** - **Written authorisation:** the customer owns the target or is authorised in writing by @@ -246,15 +312,26 @@ decides per tenant, as in t72: - The entitlement check already takes an `addon` parameter that every caller passes as `None` (`registry.rs:369`). -- The add-on names: `pruefumgebung` and `live_testing`. +- The add-on name: `pruefumgebung` (and `live_testing`, only if that is decided later). - The dashboard reads features only from the global `/version` handshake. It needs a tenant-scoped answer: add the add-ons to the usage response of t72 (`GET /api/v1/metering/usage`). +- **Booking:** a Testtag is booked only when the customer starts a run by hand, on the + first run of that target on that day. Never automatically, never from a schedule or + a scan, and a Probelauf never books one. +- **A monthly cap set by the customer** in the portal, like `prueftag_cap`: at most N + Testtage per calendar month, none by default. At the cap, starting a run that would + book a new Testtag is refused with a message; runs on a Testtag already booked that day + still work. - Usage events, counts only, never names: - - `testtag.booked`, key `testtag:{tenant}:{target}:{YYYY-MM-DD}`; - - `live_test.run`. + - `testtag.booked`, key `testtag:{tenant}:{target}:{YYYY-MM-DD}`, with the number of + successful runs at the end of the day (0 means not charged); + - `probelauf.run`, a count only, with no ERP item. - Recommendation: an active run does **not** count against the t72 Prüfung quota. It is metered on its own. +- **Testtage in the plans** (a decision for the user). Suggestion: none included in + Standard and Business in phase 1, until we have measured the cost per run on stage; + Enterprise by arrangement. A later option is N per month in Business (for example 2). ### 5. Cost and price @@ -277,12 +354,20 @@ decides per tenant, as in t72: **Price suggestion**, set against the 9,99 € Prüftag and the 5,99 € extra target: -| SKU | Contents | Suggestion | +ERP item codes follow the ERP scheme: + +| Item | Contents | Suggestion | | --- | --- | --- | -| `pruefwerk-testtag` | The Prüfumgebung for one target on one Berlin day, with up to 3 runs (DAST or automated pentest), so a customer can fix and test again the same day | 24,99 € per Testtag | -| `pruefwerk-probelauf` | Build and start only, no test | free | -| `pruefwerk-live` (add-on) | Live testing of verified targets, on request, including 5 runs per month | 29,00 € per month per tenant | -| `pruefwerk-live-run` | Each live run beyond the included 5 | 4,99 € per run | +| `CRA-CSA-CLD-TST` (Testtag) | The Prüfumgebung for one target on one Berlin day, with up to 3 runs (DAST or automated pentest), so a customer can fix and test again the same day; charged only with at least one successful run | 24,99 € per Testtag | +| Probelauf | Build and start only, no test | free; no ERP item, counted by `probelauf.run` | + +Only if live testing is decided later (codes reserved, prices to be set then; the earlier +29 € a month with 5 runs is too low for the fixed load): + +| Item | Contents | +| --- | --- | +| `CRA-CSA-CLD-LIV` | Live add-on, monthly, per tenant | +| `CRA-CSA-CLD-LRN` | An extra live run beyond those included | A Testtag mirrors the Prüftag that customers already know. It caps our cost per booking, and it fits how fixes really go: test, fix, test again. @@ -305,63 +390,88 @@ and it fits how fixes really go: test, fix, test again. a run; a second run of the same tenant waits. 7. **Entitlement and metering:** - a tenant without the add-on is refused; - - a Testtag is booked once and allows 3 runs; + - a Testtag is booked once, by the first run started by hand, and allows 3 runs; + - a run that fails on our side doesn't use one of the 3; a Testtag with no + successful run is reported with 0 and not charged; + - at the monthly cap, a run that would book a new Testtag is refused; - the usage events carry counts only. 8. **Measure** minutes, CPU, memory and LLM tokens per run, for the price. -9. **Live add-on:** only after the user decides on it. It runs against pw-target under - a public stage name, reachable only from stage's own address, and covers the ownership - check, the time window, the rate limits and the kill switches. +9. **Build network:** a build that fetches from the package mirror passes; one that + tries any other host fails, and its log names the host. +10. **Live add-on:** not in phase 1; only after the user decides on it. It would run + against pw-target under a public stage name, reachable only from stage's own + address, and cover the ownership check, the time window, the rate limits and the + kill switches. Production stays on `source_only` until the user gives the go. ## Decisions for the user -1. **The Prüfumgebung as the default** for active tests, with live testing as an - optional add-on. Recommended. -2. **Phase 1 scope:** web apps and APIs with a Dockerfile or Compose file plus a +1. **The Prüfumgebung as the default** for active tests. Recommended. +2. **Live testing out of phase 1** entirely, to be decided later on the L1–L7 analysis. + Recommended. +3. **Phase 1 scope:** web apps and APIs with a Dockerfile or Compose file plus a Prüfprofil; PLC through the existing OpenPLC path; firmware later. -3. **Charging:** customer-side build failures count, ours never do, and the Probelauf is - free. -4. **Price:** the Testtag at 24,99 €; whether the live add-on is offered at all, and at - what price. -5. **Order:** - 1. `compliance-dast` into CI, the role check and the caps (L3, L7); - 2. the runner and isolation design with infra; - 3. the Prüfprofil; - 4. routes from code (after t82); - 5. the exploitability status; - 6. the stage test plan; - 7. the live add-on last, if wanted. +4. **Private package feeds:** not supported in phase 1 (recommended), or a separately + stored, write-only feed token used only during the build. +5. **Charging:** billed per Testtag; failures on our side don't use one of the 3 runs, + failures on the customer's input do; a Testtag with no successful run is not charged; + the Probelauf is free and books nothing. +6. **Price:** the Testtag (`CRA-CSA-CLD-TST`) at 24,99 €. +7. **Testtage in the plans:** none in Standard and Business in phase 1, Enterprise by + arrangement (suggestion); or N per month in Business. +8. **Retention:** build and start logs 90 days (proposed), findings like other findings. +9. **The runner host:** in Germany; own hardware or a provider that goes on the AVV's + subprocessor list. With infra. +10. **Order:** + 1. `compliance-dast` into CI, the role check and the caps (L3, L7); + 2. the runner, build-network and isolation design with infra, plus the AVV and TOM + entries; + 3. the Prüfprofil; + 4. routes from code (after t82); + 5. the exploitability status; + 6. the stage test plan. ## Needed from the registry, ERP and LB side **For the registry and ERP:** -- The add-ons `pruefumgebung` and `live_testing`. -- The SKUs `pruefwerk-testtag`, `pruefwerk-probelauf` (price 0, for counting), - `pruefwerk-live` and `pruefwerk-live-run`. -- The usage events `testtag.booked` and `live_test.run`, counts only. +- The add-on `pruefumgebung` (`live_testing` only if decided later). +- The ERP item `CRA-CSA-CLD-TST` (Testtag). `CRA-CSA-CLD-LIV` and `CRA-CSA-CLD-LRN` are + reserved for a later live add-on. The Probelauf has no ERP item. +- A customer-set monthly Testtag cap in the portal, like `prueftag_cap`, none by default. +- The usage events `testtag.booked` (with the number of successful runs) and + `probelauf.run`, counts only. + +**For the AVV and TOM:** the runner host as a place of processing (Germany), and its +provider as a subprocessor if it is not our own hardware. **LB wording** for the version that ships phase 1. It replaces the exclusion in §4 Abs. 3 for tenants who booked the add-on: > **Prüfumgebung (Zusatzleistung).** Für gebuchte Mandanten baut Prüfwerk die Anwendung > des Kunden aus dem bereitgestellten Quellcode in einer abgeschotteten, nur für diese -> Prüfung erzeugten Umgebung auf und prüft sie dort aktiv auf Schwachstellen, unter -> anderem SQL-Injection, Cross-Site-Scripting, Umgehung der Zugriffskontrolle und -> Server-Side Request Forgery. Systeme des Kunden oder Dritter werden dabei nicht -> angesprochen. Voraussetzung ist ein lauffähiges Dockerfile oder eine Compose-Datei -> sowie ein Prüfprofil mit Testdaten; produktive Daten oder Zugangsdaten dürfen nicht -> enthalten sein. Die Umgebung wird nach jeder Prüfung vollständig gelöscht. Ein -> Prüftag der Prüfumgebung („Testtag“) umfasst bis zu drei Prüfläufe eines Prüfobjekts -> an einem Kalendertag (Europe/Berlin). Ein Probelauf (nur Aufbau und Start) ist -> kostenfrei. Schlägt der Aufbau aus Gründen fehl, die Breakpilot zu vertreten hat, wird -> der Prüflauf nicht berechnet. Die Prüfung ist automatisiert und ersetzt keinen -> manuellen Penetrationstest. +> Prüfung erzeugten Umgebung in Deutschland auf und prüft sie dort aktiv auf +> Schwachstellen, unter anderem SQL-Injection, Cross-Site-Scripting, Umgehung der +> Zugriffskontrolle und Server-Side Request Forgery. Systeme des Kunden oder Dritter +> werden dabei nicht angesprochen; beim Aufbau werden Pakete ausschließlich über einen +> Paket-Spiegel aus öffentlichen Quellen bezogen. Voraussetzung ist ein lauffähiges +> Dockerfile oder eine Compose-Datei sowie ein Prüfprofil mit Testdaten; produktive +> Daten oder Zugangsdaten dürfen nicht enthalten sein. Die Umgebung wird nach jeder +> Prüfung vollständig gelöscht. +> +> Abgerechnet wird je **Testtag**. Ein Testtag umfasst bis zu drei Prüfläufe eines +> Prüfobjekts an einem Kalendertag (Europe/Berlin) und wird nur gebucht, wenn der Kunde +> einen Prüflauf startet, nie automatisch. Ein Prüflauf, der aus Gründen fehlschlägt, +> die Breakpilot zu vertreten hat, wird nicht auf die drei Prüfläufe angerechnet. Ein +> Testtag ohne erfolgreichen Prüflauf wird nicht berechnet. Der Kunde kann im Portal +> eine monatliche Höchstzahl an Testtagen festlegen. Ein Probelauf (nur Aufbau und +> Start) ist kostenfrei. Die Prüfung ist automatisiert und ersetzt keinen manuellen +> Penetrationstest. -**For the live add-on** (only if decided), add: +**For a later live add-on** (only if decided), a starting point: > **Live-Prüfung (Zusatzleistung).** Auf gesonderte Beauftragung prüft Prüfwerk ein vom > Kunden benanntes, erreichbares System, dessen Inhaberschaft der Kunde nachgewiesen > hat, im vereinbarten Zeitfenster von den unten genannten Quell-IP-Adressen aus mit > nicht-destruktiven Prüfungen (u. a. TLS, Sicherheits-Header, offene Dienste). -> Steuerungen und industrielle Protokolle werden nicht aus dem Rechenzentrum geprüft. \ No newline at end of file +> Steuerungen und industrielle Protokolle werden nicht aus dem Rechenzentrum geprüft.