Skip to content

2.16 Phase 2 Security Review and Exit: Exit Evidence

Evidence · Step: 2.16 Phase 2 Security Review and Exit

Step 2.16 Phase 2 Security Review and Exit
Date 2026-11-18
Database PostgreSQL 18 (postgres:18-alpine), in Docker Desktop on Windows 11 and on GitHub-hosted runners
Decision ADR-0021
Result Review passed: no open high or critical finding, and every abuse case passes. The Phase 2 gate waits on one item, the offline simulator’s 14 clean nights (step 2.14), counted from 2026-11-18; the tag v0.2.0-functional follows it
Deliverable Where
ASVS report docs/security/asvs.md: every chapter of ASVS 5.0 at Level 2, met or not, with its evidence
Findings docs/security/findings.md: twelve, with severity and status
Abuse suite crates/api/tests/abuse.rs (AC-01 to AC-09) and the rounding property test in crates/engine/src/offline_receipts.rs (AC-08)
API fuzzer crates/api/tests/fuzz.rs; nightly at scale in .github/workflows/fuzz.yml
Dependency checks cargo-deny and cargo-audit in .github/workflows/deps.yml; .cargo/audit.toml
Threat model v1 threat-model.md: TM-03, TM-04, TM-05, TM-06 and TM-11 updated, three risks accepted
OWASP API review, checked owasp-review.md, Checked in step 2.16
Release tag v0.2.0-functional, after the 14th clean night (below)

The work arrived in pull requests #160 to #166, then the fix for the development key and this evidence.

Task Done
An ASVS L2 self-assessment in docs/security/asvs.md Yes
Abuse-case test suite Yes: nine cases, through the API, each ending with the ledger’s full verification
cargo audit and cargo deny in CI Yes: both on every push and pull request, and daily (#166). cargo-deny ran before only when dependencies changed, and weekly
Fix all high-severity findings Yes: the one high finding (F-01) is fixed, and so are the four medium ones
Update the threat model Yes: v1
Tag v0.2.0-functional Waiting for the Phase 2 gate (below)
Requirement Test Result
API fuzzing: random requests against the running service, no 5xx caused by input, and no invariant violation random_requests_never_get_a_5xx_or_break_an_invariant (crates/api/tests/fuzz.rs): the contract’s request examples mutated with hostile values, missing and extra fields, IDs the service returned, bodies that are not JSON, odd paths, queries, keys and tokens, eight at a time; every answer checked against the contract; then the full verification and the escrow check Eight seeds × 3,000 cases (24,000): no 5xx, no undocumented answer, no invariant broken. It found F-03 on its first run. Every change runs 1,500 cases; every night 50,000 with a new seed
Authorization matrix re-run every_role_gets_exactly_what_the_matrix_allows 63 operations × 6 roles, and without a token: each allowed exactly when the matrix grants it. The cases are generated from the contract, so the reconciliation, offline and audit operations added since step 2.08 are covered
Race abuse tests: refund, hold, voucher AC-04 (40 refunds at once against one payment), AC-06 (20 captures and releases at once on one hold, five times), AC-07 (10 vouchers at once for one device, 20 uploads of the same receipts at once), and AC-05 (50 transfers at once from one wallet) Each has exactly one correct outcome, every time; the per-account refund cap holds to the santim
Case Abuse Result
AC-01 33 malformed amounts: signs, exponents, other digits, too many places, numbers, wrong currencies, overflow All 400 or 422; no balance moves
AC-02 A balance at i64::MAX, then one santim more The maximum posts; more is refused; nothing wraps
AC-03 The same request ten times at once; the same key with another body or template; another client’s key One entry; 409 idempotency_key_reused; keys are per client
AC-04 Forty refunds of 5.00 at once against a 100.00 payment with a 2.00 fee; fee refunds larger than the fee The merchant gives back at most its 98.00, the fee at most its 2.00: exactly 100.00, never a santim more
AC-05 Fifty transfers of 10.00 at once from 100.00 Exactly ten; the wallet never goes below zero
AC-06 Twenty captures and releases at once on one hold Exactly one ends it
AC-07 Ten vouchers at once for one device; twenty uploads of the same receipts One voucher; each receipt pays once; escrows agree
AC-08 Splitting an offline payment to shave the fee At most a santim saved per split (accepted, F-07)
AC-09 Naming another client’s entry in a refund to learn whether it exists Answered as an entry that does not exist (F-03, fixed)
Criterion Result
No open high or critical findings Met. One high (F-01) and four medium (F-02 to F-05) found and fixed; two low accepted with reasons (F-06, F-07); three low and two deployment requirements open, each owned by a later step (findings.md)
Every abuse case passes Met: AC-01 to AC-09, on every change in CI
  • F-01, high: unauthenticated work was unbounded. Inventing a new credential ID for each token request passed the per-credential limit and cost an Argon2 hash each, and every refusal was a row in the append-only audit chain. The first fix checked the budget before the hash and counted the failure after; the test that sends 400 logins at once found that all 400 were hashed, because they all passed the check before the first one failed. Reserving first bounds it (ADR-0021).
  • F-03, medium: found by the fuzzer. A refund’s refunds entry was looked up without checking whose it was.
  • F-05, medium: the published development key. Nothing stopped the service from signing with deploy/signing.dev.hex.
  • The fuzzer’s own flaw. On CI, a small valid request failed to send: the fuzzer’s pooled client reused a connection the service had just closed after refusing an oversized body. The fuzzer now opens a new connection per case; the service’s behaviour is ordinary HTTP.
Gate Status
Every financial operation is booked through a template Met: only the operator’s maker-checker adjustment takes raw lines (only_the_adjustment_request_takes_raw_lines)
The API is secured with default deny Met: the matrix test above; ASVS V8
Audit chain verified Met: mezgeb-cli verify --chain (step 2.09); every API test ends with the full verification
Offline simulator clean for 14 nights Pending: the nightly workflow (nightly.yml) counts from 2026-11-18; the 14th night is 2026-12-01 at the earliest. The API fuzz runs in its own workflow so that it cannot reset this count
Reconciliation working Met (step 2.15)

When the 14th clean night is in, step 2.14’s evidence is closed and v0.2.0-functional is tagged on the commit that records it (milestone M2).

  • An external review. This is a self-assessment; the offline protocol still waits for its external review (step 2.10), and a penetration test belongs before release (phase 4).
  • The deployment. TLS, the network, hosts and keys in a key service are requirements written down here (F-11, F-12), checked at the readiness review (step 4.02).