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
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)
}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)
}Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
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
- Bound the size and depth of an object before you accept it into a queue.
- Use a serializer that survives cyclic references, or reject cycles at intake.
- Cap the total batch size that a single sync will hash.
- Load test the sync path with a deeply nested payload rather than only realistic data.