Repository navigation
GPS: stop MicroNMEA reading past the NMEA buffer - #3819
Merged
Merged
Conversation
Add a 16-byte zeroed tail behind the 100-byte NMEA buffer. MicroNMEA's fixed-width field skips can read a few bytes past the end of a malformed sentence; with the tail those reads land on NUL bytes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Collaborator
|
Thanks for the addition ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The NMEA buffer gets 16 extra zero bytes after its 100. The parser is still told the length is 100. 7 lines added in
MicroNMEALocationProvider.h.Why
MicroNMEA 2.0.6 skips a fixed number of characters in some fields. On a malformed sentence whose checksum still passes, it can read a few bytes past the end of the buffer, into the members that follow it. It only reads, it never writes. With the zero tail those reads hit NUL bytes and the parser stops.
Found in a security review of the GPS code. Low severity, but a bad or spoofed GPS sentence can make the parser use bytes that are not part of the sentence. This was the first part of #3624, as you asked, without the test bench. I checked that #3753 did not change the buffer, so the problem is still there.
What I checked
dev.Heltec_t114_repeater(nRF52): builds, 410 KB flash.Not checked
devhas no GPS test setup. The fuzz harness is available if you want it as a separate PR.🤖 Generated with Claude Code