The peripheral tracks one peer in one field, replaced on every connect. An attacker who connects at the right moment becomes the destination for someone else's notifications.
What goes wrong
Same shape as the classic single-peer bug, dialed up. The peripheral keeps one device field and replaces it on every connection callback, with no authentication of the remote and no per-peer bookkeeping. Whatever connected most recently is where the next notification goes.
An attacker in range can turn that into a hijack. Connect at the right moment, or interleave a callback with the legitimate peer's, and your device becomes the stored target. The peripheral then streams its outbound notifications to you, including whatever the real peer was supposed to receive. No pairing check stands in the way because the code never binds the data channel to an identity.
The reason this rates higher than a simple mix-up is intent. A confused-peer race is bad luck. A mutable target with no authentication is an invitation, and the attacker controls the timing.
The pattern
currentPeer = None
def onConnectionChange(peer, state):
if state == CONNECTED:
currentPeer = peer # no auth, no prior-peer check
def pushUpdate(data):
currentPeer.notify(CHAR, data) # whoever is currentdef onConnectionChange(peer, state):
if state != CONNECTED:
return
if not peer.isBonded(): # require pairing/auth
peer.disconnect()
return
sessions[peer.id] = bind(peer) # per-peer, authenticated
def pushUpdate(peerId, data):
s = sessions.get(peerId)
if s: s.peer.notify(CHAR, data) # named target onlyEvery 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
If those notifications carry anything the peer treats as private or as a command, an attacker with a cheap radio gets to read or receive it by winning a timing window you never defended. Physical proximity is the only cost, and for a device that ships in volume, proximity is not much of a barrier.
Treat a BLE data channel like any other session. Require pairing or bonding before you send anything sensitive, keep state per peer, and send each notification to a named, authenticated target instead of to a field anyone in range can overwrite.
Check your own code
- Require bonding or pairing before sending sensitive notifications
- Replace the single peer field with per-connection session state
- Disconnect or quarantine unexpected concurrent peers
- Send each notification to a named peer id, never to 'current'