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
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()
}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()
}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.
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
- Bound remote-declared sizes before they reach any allocator.
- Never let an allocation size come straight from a peer with no ceiling.
- Guard the allocation failure so it cannot crash the process.
- Test with a peripheral that reports the maximum possible size.