Skip to content
← All notes

Sample content — the scenarios and numbers below are constructed examples, kept here until real engagement data replaces them.

Security/2 Oct 2026/2 min read

Threat model first, code second

Ninety minutes, four trust boundaries, fourteen findings — and the four that changed the architecture before a line of code was written.

CRG Digital Engineering

We ran a threat model for a digital-asset custodian in week one: one whiteboard, 90 minutes, four people (two engineers, one ops, one security). Output was 14 findings. Four of them changed the architecture; the rest became review checklist items.

The four questions

  1. What are we protecting, in one sentence a non-engineer would recognise? Client assets, and the ability to prove who moved them.
  2. Who benefits from breaking it, and what do they gain? Insiders and external attackers; the gain is an irreversible transfer.
  3. Which trust boundaries does data cross, and who controls each side?
  4. What does an attacker get for free if one boundary fails?

Question 3 produced the useful diagram. Four boundaries: client browser → API, API → signing service, signing service → HSM, and internal network → backup storage.

The four findings that changed the design

Finding Boundary Fix Cost if found late
Admin API allowed key export for "support" API → signing Export path removed; the signing API has no key-export verb Key rotation ceremony per client
Webhook replay credited the same transfer twice; no nonce, no idempotency key API → signing Per-message nonce plus idempotency key on settlement writes 2–3 weeks of reconciliation
Nightly backup contained plaintext seed shares network → backup Split shares, encrypted with a key held outside the backup account 1 week
Report exporter fetched arbitrary URLs API → internal Allow-list of report origins, no redirects Days

The export path is the one worth dwelling on. It existed because support occasionally needed to move a key. Nobody had written down that "occasionally" was a permanent remote-code path to every client asset. Removing the verb cost two days; retrofitting it after launch would have meant a key rotation ceremony for every client.

The replay finding, in code

// before: webhook handler trusted the payload
await ledger.credit({ transferId: body.transferId, amount: body.amount });

// after: dedupe on nonce + idempotency key, then verify signature
const seen = await nonces.claim(body.nonce);        // INSERT ... ON CONFLICT DO NOTHING
if (!seen) return ack();                            // duplicate, already applied
if (!verifySignature(body, headers["x-signature"])) return reject(401);
await ledger.credit({
  transferId: body.transferId,
  amount: body.amount,
  idempotencyKey: body.nonce,
});

Two lines of deduplication removed an entire class of double-credit incidents. It is not exotic; it just requires someone to ask "what happens if this arrives twice" before the code is written.

Keeping it alive

The model is re-run at every architecture change, and the diff goes into the pull request. Findings get IDs (TM-07), an owner and a status. When a finding is accepted rather than fixed, the acceptance is written down with a name next to it — otherwise "accepted risk" quietly becomes "forgotten risk".

The 90 minutes cost less than the first code review of the affected service.

Scenario and figures are illustrative samples, not a published client record.

threat modellingcustodyaudit