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

One BLE field away from an out-of-memory kill

A remote-supplied response size passed straight into an allocator can throw an out-of-memory error, and an uncaught one takes the whole process down with it.

peripheralreturns…value flows tothe allocatorallocationexceeds the heapuncaught errorkills the processATTACKER INPUTIMPACTresource exhausted
Attack path · peripheral returns a response size → value flows to the allocator → allocation exceeds the heap → uncaught error kills the process

A remote-supplied response size passed straight into an allocator can throw an out-of-memory error, and an uncaught one takes the whole process down with it.

What goes wrong

The size of an incoming transfer, and the maximum chunk size, come from the remote peripheral and land directly in the reassembly allocator. No upper bound sits between the wire and the allocation.

Push that number high enough and the allocation fails outright rather than merely running slow. In a runtime where an out-of-memory error is unchecked, nothing catches it. It unwinds past your transfer code and ends the process. A single crafted response from a peripheral in range becomes a remote kill switch for the app.

The pattern

Vulnerable
function onResponse(response) {
  const total = response.size      // remote value
  const chunk = response.maxChunk  // remote value
  const buffer = new TransferBuffer(total, chunk)  // may throw OOM, uncaught
  return buffer.begin()
}
Hardened
function onResponse(response) {
  const total = response.size
  const chunk = response.maxChunk
  if (total < 0 || total > MAX_RESPONSE) return reject('bad size')
  if (chunk <= 0 || chunk > MAX_CHUNK) return reject('bad chunk')
  const buffer = new TransferBuffer(total, chunk)
  return buffer.begin()
}
How the pipeline adjudicated itHELD
ABCDEFGH

Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.

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

Why it matters to you

An out-of-memory crash from unvalidated input is worse than a slow request, because it is total and it is abrupt. On a mobile or embedded target there is no load balancer to route around it and no supervisor to soften it. The user just watches the app die whenever an attacker in range decides. If the app guards something like an access credential or a payment, a reliable crash is a real problem on its own.

Check your own code