Skip to content

fix(gps): bound GSV satellite records - #232

Merged
dakejahl merged 2 commits into
PX4:mainfrom
timothyanderson096-ocdealcheck:fix/nmea-gsv-bounds
Aug 31, 2026
Merged

dakejahl merged 2 commits into
PX4:mainfrom
timothyanderson096-ocdealcheck:fix/nmea-gsv-bounds

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown
Contributor

Summary

Harden the standard NMEA and Ashtech GSV parsers against receiver-controlled satellite counts and page metadata.

A checksummed sentence such as $GPGSV,1,1,200*4B previously drove the parsers past their four-record local sat arrays. Large page numbers could also address beyond the satellite_info_s arrays. The same pattern existed in both parsers.

This change:

  • parses only complete satellite records actually present in the sentence;
  • caps each GSV page at four records;
  • rejects negative or internally impossible page metadata;
  • bounds destination indices to SAT_INFO_MAX_SATELLITES; and
  • clamps the published NMEA satellite count.

Fixes PX4/PX4-Autopilot#28348.

Verification

  • Reproduced current PX4 SITL under AddressSanitizer using a pseudo-serial NMEA GPS with GPS_SAT_INFO=1.
  • Baseline: stack-buffer-overflow in GPSDriverNMEA::handleMessage() at nmea.cpp:748; PX4 aborted.
  • Independently reproduced the same class in GPSDriverAshtech::handleMessage() at ashtech.cpp:570.
  • Patched ASan SITL survived the original malformed payload in both protocol paths.
  • Valid four-satellite GSV preserved IDs 1,2,3,4 and SNR values 30,31,32,33.
  • Page 11/11 with 44 satellites did not write beyond the 40-slot telemetry arrays.
  • make px4_sitl_default (RelWithDebInfo): pass.
  • make px4_sitl_default PX4_CMAKE_BUILD_TYPE=AddressSanitizer: pass.
  • make check_format: pass.
  • GPSDrivers CTest: 1/1 pass.

AI assistance and independent validation

OpenAI Codex assisted with this implementation. GDN operated as a separate, coding-platform-independent validation layer above the coding system: it reproduced the fault in both protocol paths and assessed the patch through sanitizer, build, formatting, and protocol-behavior evidence. The same GDN process can validate work produced using any AI coding platform.

Assisted-by: OpenAI:Codex

Reject impossible GSV metadata and constrain parser reads and telemetry writes to sentence and array bounds.

Fixes PX4/PX4-Autopilot#28348

Assisted-by: OpenAI:Codex
Apply the same sentence-record and telemetry-array bounds to Ashtech GSV parsing.

Assisted-by: OpenAI:Codex

@dakejahl dakejahl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on hardware?

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown
Contributor Author

Not on physical hardware—I don’t currently have a compatible receiver available. Verification was performed in PX4 SITL using a pseudo-serial NMEA GPS under AddressSanitizer. The malformed payload reproduced the baseline overflows in both the NMEA and Ashtech paths; the patched builds survived the same cases while preserving valid GSV behaviour.

The normal and AddressSanitizer SITL builds, formatting check, and GPSDrivers CTest all passed.

@dakejahl
dakejahl merged commit cf1356c into PX4:main Aug 31, 2026
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.

GPS NMEA GSV parser: unclamped satellite count causes stack/heap out-of-bounds writes (single sentence crashes px4)

2 participants