CyberSib
Field notesFN-004Nov 27, 202620 min read
Entry FN-004

Threat Modeling and Secure Design Review Before You Build

The cheapest bug to fix is the one in a requirements document. A practical guide to threat modeling and design review for product teams, with a worked example, lab-tested verification steps, and public bug reports that started as design gaps.

A product team can find many security flaws before writing code. This guide shows how to do it in a single working session, with a worked example, verification steps we ran in a lab, and four public bug reports that started as design gaps.

Threat modeling maps a system and its components: the attack surface, and the business impact if an attack works. Secure design analysis (a design review) does that work earlier. It reads the requirements and the design and lists the security requirements that are missing. The two run together. The design review asks what was never specified. The threat model asks what can go wrong with what was specified.

§ 1Four questions

Adam Shostack’s four-question framework is the simplest structure we know. The OWASP Threat Modeling Cheat Sheet uses the same four questions through the Threat Modeling Manifesto, where the last one reads “a good enough job”:

  1. What are we working on?
  2. What can go wrong?
  3. What are we going to do about it?
  4. Did we do a good job?

Each question produces an artifact: a diagram, a list of threats, a list of mitigations with owners, and a review date. If a session ends without all four, it was a discussion, not a threat model.

Four questions in a loop, each with an artifact: a diagram, a threat list, mitigations with owners, and a review date.
Four questions in a loop, each with an artifact: a diagram, a threat list, mitigations with owners, and a review date.

§ 2Step 1: Draw the system and its trust boundaries

Start with a data flow diagram. It needs only five element types: external entities, processes, data stores, data flows, and trust boundaries (Microsoft Learn: data flow diagram elements). The trust boundaries carry the most weight. A trust boundary is any line where data or control passes between components with different privilege or different owners.

Here is a fleet tracking platform invented for this post:

Fleet tracking data-flow diagram with trust boundaries; the telemetry path into the event queue is labeled no mutual auth.
Fleet tracking data-flow diagram with trust boundaries; the telemetry path into the event queue is labeled no mutual auth.

The mobile app reaches the API gateway over TLS, and the gateway calls the dispatch service. Vehicle units post to telemetry ingest, which publishes to the event queue with no mutual authentication. The queue feeds analytics and dispatch. The edge (TB-1) and internal (TB-2) zones are separate trust boundaries.

The assets are vehicle telemetry, driver personal data, and the dispatch API. The diagram shows a problem before anyone writes a threat: telemetry crosses from the internet into the internal queue, and the queue accepts it without authenticating the sender.

§ 3Step 2: Ask what can go wrong, one boundary at a time

STRIDE gives you six prompts: Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, and Elevation of privilege. Apply them to each flow that crosses a boundary.

For the ingest flow:

Field Entry
Threat A spoofed vehicle unit injects false positions
Impact Dispatch decisions run on false data
STRIDE Spoofing, Tampering
Mitigation Mutual TLS on ingest, with a unique key per vehicle unit
Owner A named engineer on the ingest team
Verify by Over unit A’s certificate, a payload naming unit B returns 403 and never reaches the queue. A connection with no client certificate, or one from a different CA, fails at the TLS layer

The “verify by” row is what makes the model testable. It turns a mitigation into something a penetration tester or a CI check can confirm later.

A full STRIDE pass on one flow

Flow: field units post telemetry to ingest, which publishes to a queue.

STRIDE Threat Mitigation CWE
S Copied unit ID Per-unit mTLS cert 287
T Replayed positions Per-unit counter, freshness window 294
R Disputed route Integrity-protected receipt log 778
I Read in transit TLS on every hop 319
D Queue flood Per-unit rate limit, bounded queue 770
E Sender issues dispatch command Broker ACL, separate command topic 862

This table treats the flow and its two endpoints as one interaction, so all six letters appear. Strict STRIDE-per-element rules, as in the MSDN Magazine STRIDE article (Figure 5), give a data flow only Tampering, Information disclosure, and Denial of service. The spoofing and elevation rows then belong to the ingest process that receives the flow. Either way works if every threat ends up with an owner.

Spoofing: mTLS authenticates the connection, not the payload’s unit_id. Ingest takes the unit identity from the verified client certificate: exactly one URI SAN (for example spiffe://fleet.example/unit/A) issued by a CA used only for vehicle units. It rejects any payload whose unit_id differs, and never reads identity from the Common Name or from a request header. If a proxy terminates TLS, it must strip any client-supplied identity header and set its own. The one-URI-SAN rule comes from the SPIFFE X.509-SVID specification, which requires validators to reject a certificate with more than one URI SAN. RFC 9525 says the Common Name must not identify a service because it is free-form text. That RFC covers server identity; applying the same rule to clients is our design choice.

Replay: atomically commit the shared per-unit high-water mark with a durable outbox entry, publish under a stable message ID, and deduplicate downstream. Certificate rotation must preserve replay state; counter resets require authenticated recovery.

Repudiation: audit events bind certificate identity, payload digest, counter, receipt time, and decision. Protect log integrity; a certificate fingerprint is not a device signature.

Test: over unit A’s certificate, send two schema-valid, fresh messages, each with a counter valid for the unit it names: one naming A, one naming B. Expect 202 for A’s and 403 for B’s. B’s message must not reach the queue, must not advance B’s counter high-water mark, and must be logged as an identity mismatch with the certificate unit, the claimed unit, and the counter. Also expect a connection with no client certificate, and one with a certificate from another CA that names unit A, to fail at the TLS layer with no HTTP status.

Running the identity test

We reproduced this test in a loopback lab with throwaway certificates (Python ingest, curl 8.14.1, OpenSSL 3.5.9). The certificate for unit A carries CN=unit-A and the URI SAN spiffe://fleet.example/unit/A:

bash
1openssl x509 -in pki/unitA.pem -noout -subject -ext subjectAltName,extendedKeyUsage2# subject=CN=unit-A / URI:spiffe://fleet.example/unit/A / TLS Web Client Authentication34curl -sS --cacert pki/fleetca.pem --resolve localhost:$PORT:127.0.0.1 \5  --cert pki/unitA.pem --key pki/unitA.key -H 'Content-Type: application/json' \6  -d '{"unit_id":"B","counter":9}' -w ' [HTTP %{http_code}]' https://localhost:$PORT/ingest7# {"error":"forbidden"} [HTTP 403]

We ran the same cases against two builds of the ingest: one that reads identity from the URI SAN, and one that reads the Common Name. The “CN trap” is a certificate from the fleet CA whose CN says unit-B while its SAN says unit A.

Case SAN-bound ingest CN-reading ingest
A’s certificate, payload names A 202 202
A’s certificate, payload names B 403, not queued 403, not queued
A’s certificate, repeated counter 409 409
CN trap certificate, payload names B 403 202, queued as B
No client certificate curl exit 55, no HTTP status curl exit 56, no HTTP status
Certificate from another CA naming A curl exit 56 (unknown ca), no HTTP status same

Under TLS 1.3 the client can finish its side of the handshake before the server rejects the certificate, so the failure can surface on the first read (curl exit 55 or 56). Assert “no HTTP status and a nonzero curl exit,” not “the handshake failed immediately.”

More cases to add to the same suite:

  • A certificate with two URI SANs is rejected.
  • Expired certificates, revoked certificates (or short-lived certificates in place of revocation), and certificates with only the serverAuth extended key usage are rejected.
  • Behind a TLS-terminating proxy, a forged client-certificate header sent by the client is ignored.
  • After certificate rotation, the new certificate inherits the old counter state.

We reproduced the first table. The extra cases are reasoned from the specifications and were not run.

§ 4Step 3: Review the requirements for what they leave out

Design review works on the requirements list, not the diagram. Here is a requirements set for a B2B workspace product, written for this post:

text
1REQ-01  Users sign in with SSO (SAML 2.0)2REQ-02  Sessions expire after 12 hours of inactivity3REQ-03  Admins can invite and remove team members4REQ-04  Audit log of permission changes5REQ-05  Data exports limited to workspace owners6REQ-06  not specified: revoke sessions when a user is removed7REQ-07  API tokens scoped per workspace8REQ-08  Rate limits on authentication endpoints

Read pairs of requirements together. REQ-03 lets an admin remove a member. REQ-02 says sessions expire after 12 hours of inactivity. Nothing says removal ends the session. A removed employee who keeps a browser tab active keeps access, possibly indefinitely. That is the missing REQ-06.

REQ-02 and REQ-03 read together leave REQ-06 unspecified; after a user is removed at T, an active tab can keep access.
REQ-02 and REQ-03 read together leave REQ-06 unspecified; after a user is removed at T, an active tab can keep access.

Two more gaps appear the same way:

  • REQ-05 limits exports to owners but doesn’t define how ownership transfers when the owner leaves. Teams often patch this with a support process that becomes a social engineering target.
  • REQ-07 scopes tokens per workspace but defines no rotation or revocation policy.

None of these gaps needs a line of code to find. Each one is cheaper to fix in the requirements document than after the feature ships.

Writing the missing requirement so it can be tested

text
1REQ-06  From 60 seconds after a member's removal from a workspace2        (UI, API, or SCIM) is committed, that member cannot read3        or change its data with any credential (session cookie,4        access or refresh token, API token), whether issued or5        refreshed before or after removal. The removed member's6        workspace-scoped API tokens are revoked. The member's7        other workspaces are not affected. Denied requests return8        403; revoked API tokens return 401 with a WWW-Authenticate9        header.

The 60 seconds is this post’s budget, not a number from any standard. Service credentials inheriting the member’s authority need their own transfer-or-revoke requirement.

The 401/403 split follows RFC 9110: a 401 means the request lacks valid credentials, and the server must send a WWW-Authenticate header with it. A removed member still has a valid login for their other workspaces, so 403 fits the session case. Use 404, not 403, if workspace existence is hidden.

Measure from commit, or from an API response documented to return after it. Check response bodies as well as status codes.

Credential (200 before) T+60s
Session cookie, ws_42 403
API token, ws_42 401
Refresh, then call ws_42 Refresh succeeds for a user-level refresh token and the new access token has no ws_42; the call returns 403. A workspace-bound refresh token returns 400 invalid_grant
Session cookie, ws_77 (member) 200

The invalid_grant error is the one RFC 6749 defines for a refresh token that is invalid, expired, or revoked.

A 12-hour self-contained token carrying membership cannot meet this alone.

  • Per-request membership check or deny list: bound commit-to-validator propagation across replicas and caches, including refills from stale replicas.
  • Locally validated tokens: revoking a refresh token (RFC 7009) only says the server SHOULD also invalidate access tokens from the same grant. A self-contained access token stays valid until it expires unless you add a deny list or introspection. Propagation delay, token lifetime, and clock-skew allowance, across every issuance path (refresh, re-login, token exchange), must stay within 60 seconds.

What the gap looks like in a lab

We built a small workspace API with both behaviors and ran the REQ-06 table against it. The lab scales the 60-second budget down to 5 seconds and models authorization only (one process, in-memory database). A user, dana, is a member of ws_42 and ws_77; the owner removes dana from ws_42 at time T.

Request after removal Vulnerable build Fixed build
Session cookie, ws_42 200 (membership read at login) 403 {"error":"forbidden"}
API token, ws_42 200 (never revoked) 401 with WWW-Authenticate: Bearer error="invalid_token"
Access token issued before removal, ws_42 200, still 200 at T+6.4s 200 until its 3-second lifetime ran out, then 401 at T+3.2s
Refresh, then new token, ws_42 403 403
Session cookie, ws_77 200 200

In this lab, refresh re-reads membership in both builds, so that row is 403 either way. The stale window in the vulnerable build comes from the access token minted before removal: with a 12-hour lifetime, it lasts up to 12 hours. The 3-second token lifetime in the fixed build stands in for “lifetime plus skew fits inside the budget.”

More REQ-06 cases worth adding (reasoned, not run):

  • Removal through each path (UI, API, SCIM) satisfies the same table.
  • WebSocket and server-sent event connections, presigned URLs, and background jobs started before removal stop or fail within the budget.
  • A token minted in the same instant as the removal commit carries stale membership; the deny list or short lifetime must cover it.
  • Re-adding the member does not quietly revive old sessions.
  • A cache keyed without the user does not serve ws_42 data to the removed member.
  • A role downgrade (admin to member) takes the same path and budget as removal.

Standards that help implement REQ-06

No single standard delivers REQ-06, so the requirement has to name the mechanisms:

  • SCIM deprovisioning does not end sessions by itself. RFC 7643 and RFC 7644 define how to deactivate or delete a user, and neither requires the service provider to end existing sessions or revoke tokens. Your handler for that call has to do it.
  • Refresh token protection. The OAuth security best current practice, RFC 9700, says refresh tokens for public clients MUST be sender-constrained or use refresh token rotation. That limits a stolen refresh token. Removal still has to revoke the grant on the server.
  • Logout signals from the identity provider. OpenID Connect Back-Channel Logout 1.0 (Final) lets the provider post a logout token to your application. It covers sessions established through that provider, not API tokens or sessions your application issued on its own.
  • Pushing revocation to other services. The OpenID Continuous Access Evaluation Profile 1.0, published as Final in August 2025, defines a session-revoked event type that a transmitter can send to cooperating receivers over the Shared Signals Framework.

§ 5Public examples of design-level gaps

The following publicly disclosed bug bounty reports describe bugs whose root cause reads as a missing or unclear requirement. We describe them by bug class.

Lifecycle not specified for deletion. A researcher deleted their account on a platform and kept receiving mail sent to the platform-provided email alias tied to that account. The requirement “delete the account” did not extend to every resource the account owned. A design review asks, for every create operation, what the matching delete must remove.

Ownership not enforced across accounts. According to the program’s summary of one report, a business account owner on a payments platform could assign secondary users from other business accounts. The invariant “a secondary user belongs to exactly one business account, and only that account’s owner manages it” needs to be written down, or the implementation won’t enforce it.

State transitions not defined for a third-party flow. In another program’s public summary, an issue in the handling of an external payment provider’s transaction states let a user withdraw money without the funds being deducted from their account. Any design that relies on an external payment state needs an explicit state machine: every state, every allowed transition, and what happens on failure or timeout.

A feature that reaches more than it should. A marketplace feature took screenshots of a store’s page on the server, and the store owner controlled that page. The researcher made the store page navigate, with JavaScript, to the legacy /computeMetadata/v1beta1/ path of the Google Cloud metadata endpoint, which did not require the Metadata-Flavor: Google header, and the screenshot captured the response. The program’s summary says the chain reached root access to containers in one infrastructure subset, which did not include the core platform. Google Cloud’s current metadata documentation requires that header and rejects requests that carry X-Forwarded-For. The design question that catches this early: “this component renders content the customer controls; what can it reach on the network?”

Designing out the metadata SSRF

A renderer that follows a redirect to a cloud metadata endpoint is a server-side request forgery (SSRF). Checking only the submitted URL fails, because the page can redirect afterward. Disable redirects or validate every destination before connecting, including page subrequests. In a headless browser, “disable redirects” does not stop JavaScript or meta-refresh navigation (the report above used window.location), so intercept every navigation and subresource request, or route the renderer through an egress proxy that applies the same address checks. Check all A and AAAA answers and bind each connection to an approved address; do not let the connector resolve the hostname again after validation (OWASP SSRF Prevention Cheat Sheet). Then enforce egress at the network as a separate boundary.

This NetworkPolicy allows web ports outside the listed IPv4 ranges, plus cluster DNS. It does not exclude Azure’s platform endpoint 168.63.129.16, or any Pod or Service CIDR outside the listed ranges; add them to except where they apply. Microsoft describes 168.63.129.16 as a virtual public IP address that carries communication to Azure platform resources.

yaml
1apiVersion: networking.k8s.io/v12kind: NetworkPolicy3metadata:4  name: renderer-egress5  namespace: render6spec:7  podSelector:8    matchLabels:9      app: screenshot-renderer10  policyTypes: ["Egress"]11  egress:12    - to:13        - ipBlock:14            cidr: 0.0.0.0/015            except: [169.254.0.0/16, 10.0.0.0/8, 100.64.0.0/10,16                     172.16.0.0/12, 192.168.0.0/16]17      ports:18        - {protocol: TCP, port: 80}19        - {protocol: TCP, port: 443}20    - to:21        - namespaceSelector:22            matchLabels:23              kubernetes.io/metadata.name: kube-system24          podSelector:25            matchLabels:26              k8s-app: kube-dns27      ports:28        - {protocol: UDP, port: 53}29        - {protocol: TCP, port: 53}

Limits from the NetworkPolicy documentation:

  • It needs a network plugin that enforces NetworkPolicy.
  • Policies are additive: another policy selecting these pods can widen egress.
  • Traffic to and from the pod’s own node is always allowed.
  • Whether ipBlock matches before or after address rewriting depends on plugin and cloud provider.

The ipBlock rule is IPv4-only, so it grants no IPv6 web egress; the additive-policy and node exceptions still apply to IPv6. Because node traffic is always allowed, block the node address and kubelet port with a host firewall or require kubelet authentication.

Confirm your cluster’s DNS pod labels, then test from the renderer pod: node address, internal service, metadata address, public site.

On EC2, requiring IMDSv2 is defense in depth, not egress isolation: a redirected GET cannot send the token PUT, but SSRF with method and header control can (AWS documentation). AWS also rejects token PUTs that carry X-Forwarded-For, and the PUT response has a hop limit of 1 by default. Check what your nodes actually use: Amazon Linux 2023 instances default to IMDSv2-only with a hop limit of 2 to support containers, so a pod on those nodes can get a token. Set the hop limit to 1 on nodes that run untrusted renderer pods.

We checked the IMDSv2 rules against a loopback mock that imitates the documented behavior: a plain GET and a GET reached through a 302 both got 401, a PUT without the TTL header got 400, a PUT with X-Forwarded-For got 403, and a client with method and header control got 200. A mock shows how the probe reads; it proves nothing about AWS itself.

§ 6Step 4: Decide, assign, and verify

A threat model that produces no decisions is a diagram with notes on it. For each threat, record one of four decisions:

  • Mitigate, with a named owner and a verification test
  • Eliminate, by removing the feature or data flow
  • Transfer, for example to a provider with a contract that covers it
  • Accept, with a named person who signs off and a review date

For each threat: mitigate with an owner and a test, eliminate, transfer, or accept with sign-off and a review date.
For each threat: mitigate with an owner and a test, eliminate, transfer, or accept with sign-off and a review date.

Then answer the fourth question: did we do a good job? Re-run the model when the architecture changes, when a new trust boundary appears (a new third party, a new public endpoint, a new AI integration), or after an incident.

Keep the register in the repository

yaml
1- id: TM-0142  flow: screenshot renderer -> internet3  threat: Rendered page redirects to the cloud metadata endpoint4  cwe: CWE-9185  decision: mitigate6  owner: platform-security7  verify:8    - checkov -d infra/ --check CKV_AWS_79 (expect PASSED for aws_launch_template.render_nodes)9    - checkov -d infra/ --check CKV_AWS_34110    - metadata probe from one renderer pod per node pool11    - CNI deny verdict matching each probe12  review_by: 2027-05-27

CKV_AWS_79 flags IMDSv1 only in scanned IaC, not drift or runtime reachability. CKV_AWS_341 flags a metadata response hop limit greater than 1. Skipped checks or zero evaluated renderer node resources verify nothing.

Live probe, ignoring proxy variables:

bash
1kubectl -n render exec "$POD" -c renderer -- curl -sS -m 3 \2  --noproxy '*' -o /dev/null \3  -w '%{http_code} %{remote_ip} %{time_connect}\n' \4  http://169.254.169.254/latest/meta-data/

Any HTTP response fails isolation. Nonzero time_connect means something accepted TCP: fail or explain it. Timeouts and connection failures prove nothing without a matching deny verdict (CNI flow log drop). Record pod, node, exit code, stderr, and verdict per node pool. Where the instance is Nitro-based, in a subnet with IPv6, and has the IPv6 metadata endpoint enabled (--http-protocol-ipv6 enabled), repeat with 'http://[fd00:ec2::254]/latest/meta-data/'; verify proxy paths separately. If the renderer image has no curl, run the probe from an ephemeral debug container, which shares the pod’s network namespace.

These are the output shapes we captured with the same flags against loopback stand-ins:

text
1401 127.0.0.1 0.000090     exit 0    something answered over HTTP: isolation failed2000  0.000000              exit 7    connection refused: needs a matching deny verdict3000 127.0.0.1 0.000075     exit 28   TCP accepted, no HTTP answer: isolation failed

The third line is the trap: a timeout with a nonzero time_connect still means something on that path accepted the connection.

More register entries from this post

The same eight keys cover the other worked examples:

yaml
1- id: TM-0152  flow: vehicle unit -> telemetry ingest3  threat: A unit presents its own valid certificate but claims another unit's unit_id4  cwe: CWE-2875  decision: mitigate6  owner: ingest-team7  verify:8    - over unit A certificate, message naming B returns 403 and zero queue entries9    - B high-water mark unchanged after the rejected message10    - audit event identity_mismatch with cert_unit, claimed_unit, counter, payload_sha25611    - handshake with no client certificate or a certificate from another CA fails at TLS12    - certificate with two URI SANs is rejected13  review_by: 2027-05-2714- id: TM-01615  flow: admin removes member -> workspace API16  threat: Removed member keeps reading workspace data with an old session, token, or refresh17  cwe: CWE-86318  decision: mitigate19  owner: identity-team20  verify:21    - session cookie for the removed workspace returns 403 within 60 seconds of commit22    - revoked workspace API token returns 401 with a WWW-Authenticate header23    - refresh then call returns 403, or refresh returns 400 invalid_grant24    - same user still gets 200 on another workspace25    - polling an access token issued before removal is denied within 60 seconds26    - WebSocket and SSE connections for the removed workspace close within 60 seconds27  review_by: 2027-05-2728- id: TM-01729  flow: agent gateway -> export_workspace tool30  threat: A consumed or foreign confirmation_id is replayed, alone or concurrently, to start extra exports31  cwe: CWE-36732  decision: mitigate33  owner: platform-security34  verify:35    - no confirmation_id returns 403 and zero export jobs36    - consumed id returns 403 and zero extra jobs37    - 20 concurrent requests with one fresh id yield exactly one 200 and one job38    - expired id returns 40339    - id presented with a different recipient or workspace returns 40340    - non-owner presenting the owner id returns 403 and the owner id remains usable41  review_by: 2027-05-27

Log the decisions so you can see controls fail

Each control above should emit one structured event per decision, with a request ID. Never log credentials, token values, or full confirmation IDs; log a SHA-256 prefix instead.

Control Event and fields Alert on
mTLS ingest ingest.decision: decision, reason (accept, identity_mismatch, replay), cert_unit, claimed_unit, cert_serial, counter, payload_sha256, src_ip Any identity_mismatch; one certificate seen from more than one source network in a short window (possible cloned key); a counter going backward
Session revocation membership.removed (workspace, target, actor, committed_at); authz.decision (user, workspace, credential type, token ID, allow or deny) Any allow for a removed user after committed_at plus 60 seconds; a burst of denies for a removed user
Export confirmation.consumed, confirmation.rejected (replayed, expired, actor_mismatch, args_mismatch), export.started (confirmation hash) An export with no consumed confirmation; more than one export per confirmation
SSRF renderer CNI flow logs with verdicts; renderer DNS log Any flow to 169.254.169.254, 168.63.129.16, fd00:ec2::254, private ranges, or node addresses; on AWS, the MetadataNoToken metric above zero

Two of the alerts as generic SQL over an events table. Adapt them to your log store; we have not run these queries against a production log pipeline:

sql
1-- Access after the revocation budget (should return zero rows)2SELECT a.ts, a.user_id, a.workspace, a.credential_type, a.token_id3FROM events a JOIN events r4  ON r.event = 'membership.removed' AND r.target = a.user_id AND r.workspace = a.workspace5WHERE a.event = 'authz.decision' AND a.decision = 'allow'6  AND a.ts > r.committed_at + INTERVAL '60 seconds';78-- Exports without a consumed confirmation, or more than one per confirmation9SELECT e.confirmation_hash, count(*) AS exports10FROM events e LEFT JOIN events c11  ON c.event = 'confirmation.consumed' AND c.confirmation_hash = e.confirmation_hash12WHERE e.event = 'export.started'13GROUP BY e.confirmation_hash14HAVING count(*) > 1 OR count(c.confirmation_hash) = 0;

§ 7Fitting this into a sprint

You don’t need a two-week process. A single working session for a feature usually covers it:

  1. The feature owner brings the requirements and a rough diagram.
  2. The group marks trust boundaries and walks STRIDE across each flow that crosses one.
  3. The group reads the requirements in pairs and lists what is missing.
  4. Each threat gets a decision, an owner, and a verification step, recorded where the team tracks other work.

This matches the intent of the NIST Secure Software Development Framework (SP 800-218), which includes designing software to meet security requirements and mitigate security risks as a core practice, and CISA’s Secure by Design guidance. Version 1.1 is still the final SSDF; a Rev. 1 draft (SSDF 1.2) was published for comment in December 2025.

Extra prompts when the feature includes an LLM or agent

Maps to the OWASP Top 10 for LLM Applications 2026: LLM03:2026 Excessive Agency and LLM04:2026 Supply Chain.

Tool authorization. The gateway, not the model, enforces user permissions and validates a confirmation bound to the authenticated actor, operation, and exact arguments, short-lived and atomically consumed. As the ws_42 owner, omit only the confirmation:

http
1POST /tools/export_workspace HTTP/1.12Host: agent.example.internal3Cookie: session=ws42-owner-session4Content-Type: application/json5Content-Length: 5567{"workspace":"ws_42","recipient":"[email protected]"}
http
1HTTP/1.1 403 Forbidden2Content-Type: application/json3Content-Length: 3345{"error":"confirmation_required"}

Assert zero export jobs and outbound deliveries (job queue, mail logs) as well as the 403. Controls: with a valid confirmation_id, the owner gets 200 and one export. Replaying the consumed id returns 403 and no second export, including when 20 copies of the request race with one fresh id: exactly one returns 200 and exactly one export job exists. An id used after its expiry, or presented with a different recipient or workspace, returns 403 and no job. Exports are owner-only: a non-owner ws_42 member who presents the owner’s unused confirmation_id gets 403 and zero jobs, and the owner’s id remains usable afterward.

The race case matters because a gateway that checks the id in one statement and marks it used in a later one passes every sequential test. We ran both designs in a loopback lab with a 2-second confirmation lifetime. The check-then-consume gateway had a 50 ms gap between check and use to make the race reliable; real gaps are smaller but exist whenever check and consume are separate statements.

Step Check, then consume One atomic update
Owner, no id 403, 0 jobs 403, 0 jobs
Owner, valid id 200, 1 job 200, 1 job
Replay the consumed id 403 403
Id used after 2.3 seconds 403 403
Owner’s id, different recipient 403 403
Member presents owner’s unused id 403 owner_only 403 owner_only
Owner uses that id afterward 200 200
20 concurrent requests, one fresh id 14 × 200, 14 export jobs 1 × 200, 19 × 403, 1 job

The exact count in the check-then-consume race varies from run to run; any count above one is a failure. The fix is a single conditional update that binds every property at once, after the owner check, and starts the job only if exactly one row changed:

sql
1UPDATE conf SET used = 12WHERE id = ? AND actor = ? AND op = 'export_workspace'3  AND args_hash = ? AND exp > ? AND used = 0;4-- proceed only if rowcount == 1

More export cases (reasoned, not run):

  • Expiry boundary: the id works one second before its lifetime ends and fails one second after.
  • Binding: changing the workspace, the recipient, or only the JSON key order or whitespace gives the expected result; hash canonical JSON.
  • A rejected request (wrong actor, wrong arguments) does not consume the id.
  • The id has at least 128 bits of entropy, is stored hashed, and never appears in full in logs.
  • The model or agent cannot call the endpoint that mints an id; minting needs a human-facing step and is rate limited.
  • If job creation fails after the id is consumed, the user must confirm again. State that fail-closed choice in the requirement.

MCP servers. Pin the server artifact. Block changes to tool descriptions, schemas, or permissions until re-approved.

§ 8When to bring in an outside reviewer

Teams model their own systems well once they have practiced. An outside reviewer adds value when:

  • The system crosses several organizations or vendors, and nobody owns the whole picture
  • The design handles money, identity, health, or other regulated data
  • You want the threat model to drive a later penetration test, so findings map to designed controls

§ 9Next step

If you have a design in progress and want a second set of eyes before build, our threat modeling and secure design analysis work starts with your requirements and diagrams.

Request a scoping call

Further reading.

Related service

Threat Modeling

We map the attack surface of a system and the business impact of the attacks that surface allows.

Request a scoping call
Next up
§ 02 — Next step

Who should we prepare your report for?

Type your company name to see it on the report cover and the scoping worksheet underneath. Hover over the cover to lift it.Tap the cover to lift it.

CyberSib
Security Assessment Report
Prepared for
Your company
ScopeDefined at kickoff
Light box · auditor view · press X to exit