Fastify (Node.js) · CWE-362
Fastify: TOCTOU & Concurrency Race Conditions
Stop concurrent requests from double-spending balances, reusing single-use coupons, or bypassing step quotas. Applied specifically to Fastify: Bind JSON Schema validation and preHandler role checks on every route group.
Coverage ledger tracking key
surface:fastify::boundary:race-condition-toctou::principal:request.user.sub
Parallel HTTP/2 burst verification comparing invariant balance/quota conservation
Risk boundary
// Unverified Fastify path (CWE-362)
// Handler accepts client input without validating request.user.sub or boundary invariants before sink.Hardened guard
// Hardened Fastify pattern (CWE-362)
// 1. Bind JSON Schema validation and preHandler role checks on every route group
// 2. Move balance/quota assertions into atomic database conditional UPDATE predicates or row-level locks.Verification steps
- 01Seed coverage-ledger.json for every Fastify route handling this boundary.
- 02Inspect the code trace from request input down to the persistence or egress sink.
- 03Confirm with paired User A vs User B requests (or staging baseline-vs-payload replay) via owasp-api-graphql-audit.