Skip to content

Fix panic on malformed RadioTap packets#1227

Open
mohammadmseet-hue wants to merge 1 commit intogoogle:masterfrom
mohammadmseet-hue:fix-radiotap-panic
Open

Fix panic on malformed RadioTap packets#1227
mohammadmseet-hue wants to merge 1 commit intogoogle:masterfrom
mohammadmseet-hue:fix-radiotap-panic

Conversation

@mohammadmseet-hue
Copy link
Copy Markdown

Summary

Add bounds checking in RadioTap.DecodeFromBytes before each field read to prevent panics on malformed packets.

Root cause: After the initial 8-byte minimum check, the extended bitmap loop and all field reads (TSFT, Channel, MCS, AMPDU, VHT, etc.) access data[offset:offset+N] without verifying offset+N <= len(data). The payload extraction at data[m.Length:] trusts the header's Length field without validation.

Fix: Check remaining data length before each field read and before payload extraction. Return a descriptive error instead of panicking.

Panics fixed: 6 (extended bitmap loop, TSFT, Channel, MCS, VHT, payload length)

All existing tests pass.

Add bounds checking in RadioTap.DecodeFromBytes before each field read.
Malformed packets with truncated data or invalid Length fields caused
index out of range panics via the extended bitmap loop, individual field
reads (TSFT, Channel, MCS, AMPDU, VHT, etc.), and payload extraction.

Return an error instead of panicking when data is too short.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant