Skip to content

Validate SRS voice packet framing in decoder - #721

Merged
dharmab merged 1 commit into
mainfrom
fix/voice-decode-framing-validation
Jul 26, 2026
Merged

Validate SRS voice packet framing in decoder#721
dharmab merged 1 commit into
mainfrom
fix/voice-decode-framing-validation

Conversation

@dharmab

@dharmab dharmab commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Context

Split off from #712. voice.Decode trusted the packet-length header over the datagram: it read packetLength from the first two bytes and then worked backwards from that offset without ever checking that the offset was consistent with the actual datagram or with the declared segment lengths.

A corrupt or truncated packet whose header still happened to point within bounds could decode into a plausible-looking Packet with a garbage OriginGUID. A receiver consuming that packet would treat it as a real transmitter capable of holding a frequency.

Change

Decode now rejects a packet if:

  • the length header doesn't match the actual datagram length
  • the header + audio + frequencies + fixed segment lengths don't sum to the declared packet length
  • the frequencies segment length isn't a whole multiple of a single frequency's encoded length

Verified against a live server

Cross-checked the new validation against a packet captured on eu.limakilo.net (receive only, never transmitted) carrying four frequencies: header 6 + audio 31 + frequencies 40 + fixed 58 = 135 bytes, matching the datagram size. TestDecodeMatchesObservedFraming pins this.

Testing

make test && make lint vet fix format && go mod tidy   # all pass, no further changes

New tests: round-trip encode/decode across single/multiple/encrypted/no-audio frequency sets, the observed-framing regression above, and rejection of truncated datagrams, mismatched length headers, and inconsistent segment lengths.

🤖 Generated with Claude Code

Decode trusted the packet-length header over the datagram, so a
corrupt or truncated packet whose header still pointed within bounds
could decode into a plausible-looking packet with a garbage
OriginGUID. A downstream receiver would then treat it as a real
transmitter capable of holding a frequency.

Cross-checked against a packet captured on a live SRS server
(eu.limakilo.net) to confirm the new validation doesn't reject real
traffic.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dharmab
dharmab force-pushed the fix/voice-decode-framing-validation branch from c7c0469 to c35096b Compare July 26, 2026 20:30
@dharmab dharmab changed the title Validate SRS voice packet framing in Decode Validate SRS voice packet framing in decoder Jul 26, 2026
@dharmab
dharmab enabled auto-merge (rebase) July 26, 2026 20:31
@dharmab
dharmab merged commit 9467cf7 into main Jul 26, 2026
9 checks passed
@dharmab
dharmab deleted the fix/voice-decode-framing-validation branch July 26, 2026 20:38
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