The code decides a message was delivered by reading one field on an incoming report. No freshness, no origin check. Replay yesterday's receipt and it counts again.
What goes wrong
This handler decides a response was delivered by looking at one thing: the report's type says success. It does not check the protocol state, it does not check where the report came from, and it does not tie the report to the transfer it supposedly confirms. A single field carries the whole decision.
That makes the receipt trivial to forge and just as easy to replay. Capture one legitimate success report and you can send it again later to make the code believe a fresh delivery happened. A hostile peer can manufacture one from nothing. Either way the completion path runs when nothing was delivered.
The fix is not more parsing. It is binding the report to what an attacker cannot reproduce. Tie it to the current state and the active transfer's id, and confirm the sender is the peer you established the session with. A receipt without those is a guess.
The pattern
function onReport(report) {
if (report.type == SUCCESS) {
markDelivered()
onResponseSent() // one field decides it
}
}function onReport(report) {
if (report.type != SUCCESS) return
if (state != AWAITING_ACK) return
if (report.transferId != activeTransfer) return
if (!freshNonceSeen(report.nonce)) return // block replay
markDelivered()
onResponseSent()
}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
When 'delivered' or 'confirmed' can be asserted by a replayed message, your audit trail lies. You will show a delivery that never landed, or a confirmation an attacker faked. Anything downstream that leans on that signal, whether billing or non-repudiation, inherits the forgery. Freshness and origin binding are cheap. Reconstructing what actually happened after the fact is not.
Check your own code
- Find decisions made from a single field on an untrusted message.
- Add a nonce or sequence check so a captured report cannot be replayed.
- Verify the report matches the transfer currently in flight, by id.
- Confirm the sender is the bonded peer before trusting any acknowledgement.