Blog / A04:2021 Insecure Design
A04:2021 · Insecure Design

One telemetry event can freeze your whole batch

Hashing a caller-supplied event to dedupe it means serializing whatever they send. A deep or cyclic object stalls the sync or throws and drops every event with it.

client emits anevent objectevent queued intothe batchsync serializesthe batch to…large or cyclicinput stalls…ATTACKER INPUTIMPACTresource exhausted
Attack path · client emits an event object → event queued into the batch → sync serializes the batch to hash it → large or cyclic input stalls or throws

Hashing a caller-supplied event to dedupe it means serializing whatever they send. A deep or cyclic object stalls the sync or throws and drops every event with it.

What goes wrong

The event API takes an arbitrary object and stores it. Nothing checks its size or depth, and nothing checks whether it loops back on itself. That cost gets deferred to sync time, out of sight of the code that accepted it.

When the batch flushes, it serializes the whole thing to compute a hash id. A megabyte of nested arrays turns into a CPU spike. A cyclic reference is worse: serialization throws, the flush aborts, and the batch that could not be hashed never leaves the device. Your telemetry goes quiet exactly when something interesting is happening.

The pattern

Vulnerable
function recordEvent(payload) {
  batch.push(payload)        // no size, depth, or cycle check
}

function flush() {
  const id = md5(serialize(batch))  // throws on cycles, slow on giants
  send(id, batch)
}
Hardened
function recordEvent(payload) {
  if (byteSize(payload) > MAX_EVENT) return drop(payload)
  batch.push(payload)
}

function flush() {
  const id = md5(serialize(batch, { maxDepth: 32, safeCycles: true }))
  send(id, batch)
}
How the pipeline adjudicated itPROVEN
ABCDEFGH

Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

Telemetry code runs on someone else's device or in a shared worker, and it is rarely load tested against hostile input. A single client sending a self-referential object can silently kill reporting for that session, which hides the very failures you built telemetry to catch. On a server, the same pattern gives an unauthenticated caller a cheap way to burn CPU.

Treat anything you serialize as untrusted by default, especially when the output feeds a hash you compute on a hot path.

Check your own code