Blog / A01:2021 Broken Access Control
A01:2021 · Broken Access Control

One shared device field crosses your BLE peers

Every connection callback overwrites the same device reference. Two centrals at once, and notifications meant for the first can land on the second.

A peripheralkeeps one…Each connectioncallback…A second centralconnects…Laternotifications…Data meant forone peer…ATTACKER INPUTIMPACTwindow between check and use
Attack path · A peripheral keeps one device reference → Each connection callback overwrites that reference → A second central connects while the first is active → Later notifications target the last device stored → Data meant for one peer reaches another

Every connection callback overwrites the same device reference. Two centrals at once, and notifications meant for the first can land on the second.

What goes wrong

The peripheral holds a single field for the connected peer. Every time a connection callback fires, it writes the new device into that field, no questions asked. There is no check that a peer is already connected, and no binding between the connection and an authenticated session.

Now let two centrals connect close together. The second callback overwrites the reference while the first peer is still around expecting data. When the peripheral pushes a notification, it goes to whatever device sits in that field right now, which may be the wrong one. Application data intended for the first peer is delivered to the second.

Bluetooth makes concurrent and rapid reconnects normal, so this is not a corner case you have to squint to see. The bug is state that is global where it should be per-connection, mutated by a callback that assumes there is only ever one peer.

The pattern

Vulnerable
device = None   # one field for the whole peripheral

def onConnectionChange(peer, state):
    if state == CONNECTED:
        device = peer          # overwrites any prior peer

def notify(payload):
    device.write(CHAR, payload)   # goes to the latest peer
Hardened
sessions = {}   # keyed per connection

def onConnectionChange(peer, state):
    if state == CONNECTED:
        if activeSessionFor(peer) is None:
            sessions[peer.id] = newSession(peer)

def notify(peerId, payload):
    s = sessions.get(peerId)
    if s and s.isAuthenticated():
        s.peer.write(CHAR, payload)   # only that peer
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

Anywhere a callback stashes 'the current thing' in a shared field, a second event can move it under your feet. On BLE that shared field decides who receives your data. The exposure is bounded by what those notifications carry and by radio range, which keeps this at a medium rather than a fire drill, but proximity attacks are cheap and the data path is real.

Model each connection as its own session with its own state, and address notifications to a specific peer rather than to whoever happens to be current.

Check your own code