Skip to content

Fix MAVLink message bounds validation vulnerabilities (Stable_V5.0 backport)#14068

Merged
DonLakeFlyer merged 2 commits intoStable_V5.0from
fix/mavlink-message-bounds-validation-v5.0
Mar 6, 2026
Merged

Fix MAVLink message bounds validation vulnerabilities (Stable_V5.0 backport)#14068
DonLakeFlyer merged 2 commits intoStable_V5.0from
fix/mavlink-message-bounds-validation-v5.0

Conversation

@DonLakeFlyer
Copy link
Collaborator

Backport of #14067 to Stable_V5.0.

Harden MAVLink message handlers against malicious or malformed payloads that could trigger out-of-bounds memory access.

Fixes https://github.com/mavlink/qgroundcontrol/security/advisories/GHSA-v5rc-wh3c-c4cw

ImageProtocolManager (GHSA-v5rc-wh3c-c4cw)

  • Validate DATA_TRANSMISSION_HANDSHAKE fields (size, payload, packets) before allocating the image buffer
  • Enforce 1 MB upper bound on image size
  • Reject payload values exceeding ENCAPSULATED_DATA data[253] array size
  • Pre-allocate image buffer to declared size instead of growing via unchecked indexed writes
  • Replace byte-by-byte copy loop with bounds-clamped memcpy
  • Cast seqnr to uint32_t before multiplication to prevent overflow

Vehicle (LOG_DATA)

  • Add bounds check on log.count against sizeof(log.data) before emitting the signal, preventing downstream consumers from reading past the 90-byte data array

FTPManager (FILE_TRANSFER_PROTOCOL)

  • Validate hdr.size against sizeof(request->data) at the single message entry point, protecting all downstream handlers (burst read, list directory, fill missing blocks) from reading past the 239-byte data array

Harden MAVLink message handlers against malicious or malformed payloads
that could trigger out-of-bounds memory access.

ImageProtocolManager (GHSA-v5rc-wh3c-c4cw):
- Validate DATA_TRANSMISSION_HANDSHAKE fields (size, payload, packets)
  before allocating the image buffer
- Enforce 1 MB upper bound on image size
- Reject payload values exceeding ENCAPSULATED_DATA data[253] array size
- Pre-allocate image buffer to declared size instead of growing via
  unchecked indexed writes
- Replace byte-by-byte copy loop with bounds-clamped memcpy
- Cast seqnr to uint32_t before multiplication to prevent overflow

Vehicle (LOG_DATA):
- Add bounds check on log.count against sizeof(log.data) before emitting
  the signal, preventing downstream consumers from reading past the
  90-byte data array

FTPManager (FILE_TRANSFER_PROTOCOL):
- Validate hdr.size against sizeof(request->data) at the single message
  entry point, protecting all downstream handlers (burst read, list
  directory, fill missing blocks) from reading past the 239-byte data
  array

Fixes: GHSA-v5rc-wh3c-c4cw
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Build Results

Platform Status

Platform Status Details
Linux Passed View
Windows Passed View
MacOS Passed View
Android Pending -

Some builds still in progress.

Pre-commit

Check Status Details
pre-commit Passed View

Updated: 2026-03-06 04:41:50 UTC • Triggered by: MacOS

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@DonLakeFlyer DonLakeFlyer requested a review from Copilot March 5, 2026 19:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@DonLakeFlyer DonLakeFlyer merged commit a231527 into Stable_V5.0 Mar 6, 2026
20 checks passed
@DonLakeFlyer DonLakeFlyer deleted the fix/mavlink-message-bounds-validation-v5.0 branch March 6, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants