A running queue of things to investigate. The first item is the current focus; add new ones at the bottom.
Two transactions each hold what the other needs, so neither can finish.
- Reproduce one. Two sessions, two rows, opposite order:
A → Bin one,B → Ain the other. - Detection. PostgreSQL waits
deadlock_timeout(1s by default), walks the wait graph, and aborts one transaction with40P01. InnoDB does the same and reports1213. The victim is chosen by cost, not by fairness. - Prevention. A consistent lock order, the smallest locked set, and the shortest transaction. All three reduce the chance that two wait graphs intersect.
- Recovery. Retry at the transaction boundary, with backoff, and only when the work is idempotent. A retry inside the same aborted transaction is not a retry.
- Diagnosis.
pg_locks,pg_blocking_pids(),log_lock_waits = on, and thedeadlock detectedline in the server log. - Adjacent failures worth separating. Deadlock (
40P01), lock timeout (55P03), and serialization failure (40001) are three different events with three different fixes. - Open question. How do you enforce a lock order when a repository or ORM loads rows in arbitrary order?
Related: SELECT ... FOR UPDATE and what a transaction guarantees.
Transport-layer client identity: the server proves itself to the client, and the client proves itself to the server.
- Already written up in TLS vs mutual TLS — review whether the explanation still holds.
- What is missing there: a runnable demo. A tiny CA, an HTTPS server with
requestCert/rejectUnauthorized, and a client that presents its certificate; one success and one rejection. - Certificate lifecycle: issuing, rotation, expiry, revocation (CRL/OCSP), and the trust-store strategy that makes it operable.
- Where TLS terminates: the application, a gateway, or a service mesh — and the identity-header trap when a proxy terminates it.
- The comparison: mTLS versus OAuth2 client credentials versus HMAC-signed requests. Each answers "who is calling?" at a different layer.
- The boundary: mTLS identifies the workload, not the human user behind it.
Three operations that get conflated because they all "scramble" data, and each answers a different question.
- Already covered in Hashing vs encryption vs encoding, with Base64, HMAC, and password hashing alongside it.
- The three questions: encoding is for transport (reversible, no key), encryption is for confidentiality (reversible, with a key), hashing is for integrity and comparison (one-way, no key).
- Where the confusion shows up: Base64 presented as security, a hash used where encryption is needed, a password hashed with SHA-256, JWT signing mistaken for encryption.
- What to add: one decision table that starts from the goal ("Do I need to get it back? Does someone need a key?") rather than from the algorithm.
A cookie carries a small piece of state; a session is what that state points at. The security lives in the attributes and in where the session record lives.
- Cookie mechanics:
Set-Cookieattributes (HttpOnly,Secure,SameSite,Path,Domain,Max-Age/Expires), and the__Host-/__Secure-prefixes that stop a subdomain from overwriting them. - The session shape: an opaque session ID in the cookie, with the record in Redis or the database. That gives revocation, logout everywhere, and idle versus absolute timeouts.
- Stateless alternative: a signed JWT in a cookie or header — no lookup, but revocation becomes a denylist or a short expiry. Compare it against server sessions rather than treating it as a replacement.
- The attacks to design against: session fixation (rotate the ID at login), CSRF (
SameSiteplus a token where it matters), XSS (HttpOnly), and theft over plain HTTP (Secure). - Node specifics:
cookie/cookie-parserfor parsing,express-sessionfor the store wiring,req.session.regenerate()on privilege change. - Related notes already in the repo: JWT, why JWT isn't JSON, and why JWT is fast.
- The boundary: a cookie is a transport for a token. Authentication is the decision made after reading it.
Serialization turns an object graph into bytes; deserialization turns bytes back into an object graph. The round trip is where types, trust, and compatibility get lost.
- The lossy round trip:
Date,Map/Set,BigInt,Buffer,undefined,NaN, class identity, and cyclic references all behave differently once they cross a format boundary. - JSON specifics:
undefineddisappears from objects and becomesnullin arrays,NaNbecomesnull,BigIntthrows,Dategoes throughtoJSON, and the prototype is gone on the way back. - Deserialization is a trust boundary.
JSON.parseis data;evaland object-graph deserializers are code execution. Validate the parsed shape (zod, JSON Schema) instead of casting it, and watch for__proto__and YAML/XML payload tricks. - Compatibility: unknown fields, renamed fields, defaults, and required-versus-optional. Protobuf field numbers and Avro schema registries exist because this is the hard part, not the encoding.
- Canonical form: anything signed must be signed over bytes, not objects — key order and number formatting differ between serializers. This is why JWT isn't JSON.
- Where it happens: HTTP bodies (DTOs), database rows to objects, cache values, queue messages, and logs. Each boundary has its own compatibility rule.
- Node specifics:
JSON.stringify/parsewith replacer and reviver,toJSON,v8.serializefor binary, andstructuredClonefor in-process copies.
A consensus awareness document about the most critical web-application risks. Useful as a coverage checklist and as a way to name a class of bug, not as a compliance standard.
- The current edition is 2025 (the site redirects from
/Top10/to/Top10/2025/): A01 Broken Access Control, A02 Security Misconfiguration, A03 Software Supply Chain Failures, A04 Cryptographic Failures, A05 Injection, A06 Insecure Design, A07 Authentication Failures, A08 Software or Data Integrity Failures, A09 Security Logging and Alerting Failures, A10 Mishandling of Exceptional Conditions. - What changed from 2021: two new entries (Software Supply Chain Failures, Mishandling of Exceptional Conditions), several categories reordered, SSRF no longer its own entry, and "Identification and Authentication Failures" renamed to Authentication Failures.
- How to use it: threat-model each category against this codebase, then turn the gaps into tests. The categories are symptoms; the fixes live in the Cheat Sheet Series and ASVS.
- Where the repo already touches it: mTLS and encryption vs hashing cover parts of A04; password hashing and JWT cover parts of A07; the injection and access-control categories have no notes yet.
- Node-specific angles: SQL/NoSQL injection and
eval-style sinks (A05), mass assignment and missing object-level authorization (A01), dependency and lockfile risk (A03), error responses leaking stack traces (A02/A10), and logs that record the event without the identity (A09). - The boundary: the Top 10 ranks risk. It does not tell you what to build, and passing it is not the same as being secure.
- Lock timeouts vs. deadlocks vs. serialization failures — when to retry, when to fail, and which error reaches the user.
- Phantom inserts — PostgreSQL has no gap locks; InnoDB does. What each engine actually protects.
- Retry budgets — backoff, jitter, caps, and how a hot row turns optimistic control into a retry storm.
- Fencing tokens — why a lease is not a lock, and how a monotonic token makes an expired lease safe.
- Isolation levels —
READ COMMITTED,REPEATABLE READ,SERIALIZABLE, and the anomalies each one still permits. - Connection pools under lock waits — how a blocked transaction consumes a connection, and what saturation looks like before it becomes an outage.