Skip to content

MavlinkLogHandler sscanf stack buffer overflow via MAVLink log request

Moderate
mrpollo published GHSA-97c4-68r9-96p5 Mar 14, 2026

Package

PX4/PX4-Autopilot (Other)

Affected versions

<= 1.17.0-rc1

Patched versions

main

Description

Summary

Stack buffer overflow in MavlinkLogHandler triggered via MAVLink log request. The LogEntry.filepath buffer is 60 bytes, but sscanf parses paths from the log list file with no width specifier, allowing a path longer than 60 characters to overflow the buffer.

Details

In mavlink_log_handler.cpp, the log list file is parsed with:

sscanf(line, "%" PRIu32 " %" PRIu32 " %s",
       &entry.time_utc, &entry.size_bytes, entry.filepath);

entry.filepath is only 60 bytes. A log directory structure producing paths longer than 60 characters causes a stack buffer overflow when a GCS requests the log list via MAV_CMD_LOG_REQUEST_LIST.

An attacker with MAVLink link access can trigger this by first creating deeply nested directories via MAVLink FTP, then requesting the log list.

Impact

Denial of service. The flight controller MAVLink task crashes, losing telemetry and command capability.

Fix

  • Size LogEntry.filepath to PX4_MAX_FILEPATH (256 bytes)
  • Add sscanf width specifiers to prevent overflow
  • Add static_assert to enforce buffer size at compile time

Original Report Below

=================================================================
==66954==ERROR: AddressSanitizer: stack-overflow on address 0x7fc2b854ffd0 (pc 0x7fc2bbe447d9 bp 0x7fc2b8550820 sp 0x7fc2b854ffc0 T121)
    #0 0x7fc2bbe447d8 in __sanitizer::StackTrace::StackTrace(unsigned long const*, unsigned int) ../../../../src/libsanitizer/sanitizer_common/sanitizer_stacktrace.h:50
    #1 0x7fc2bbe447d8 in __sanitizer::BufferedStackTrace::BufferedStackTrace() ../../../../src/libsanitizer/sanitizer_common/sanitizer_stacktrace.h:95
    #2 0x7fc2bbe447d8 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #3 0x7fc2bb8a1f18 in __alloc_dir ../sysdeps/posix/opendir.c:118
    #4 0x7fc2bb8a1f18 in opendir_tail ../sysdeps/posix/opendir.c:69
    #5 0x7fc2bb8a1f18 in __opendir ../sysdeps/posix/opendir.c:92
    #6 0x7fc2bbd86342 in __interceptor_opendir ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:3101
    #7 0x560bb775d487 in MavlinkLogHandler::write_entries_to_file(_IO_FILE*, char const*) ../../src/modules/mavlink/mavlink_log_handler.cpp:429
    #8 0x560bb775dadc in MavlinkLogHandler::create_log_list_file() ../../src/modules/mavlink/mavlink_log_handler.cpp:410
    #9 0x560bb775dcf1 in MavlinkLogHandler::handle_log_request_list(__mavlink_message const*) ../../src/modules/mavlink/mavlink_log_handler.cpp:262
    #10 0x560bb77636c0 in MavlinkLogHandler::handle_message(__mavlink_message const*) ../../src/modules/mavlink/mavlink_log_handler.cpp:98
    #11 0x560bb7714cd1 in MavlinkReceiver::handle_message(__mavlink_message*) ../../src/modules/mavlink/mavlink_receiver.cpp:408
    #12 0x560bb771644a in MavlinkReceiver::run() ../../src/modules/mavlink/mavlink_receiver.cpp:3293
    #13 0x560bb771c11e in MavlinkReceiver::start_trampoline(void*) ../../src/modules/mavlink/mavlink_receiver.cpp:3575
    #14 0x7fc2bbd12608 in start_thread /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477
    #15 0x7fc2bb8e3352 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f352)

SUMMARY: AddressSanitizer: stack-overflow ../../../../src/libsanitizer/sanitizer_common/sanitizer_stacktrace.h:50 in __sanitizer::StackTrace::StackTrace(unsigned long const*, unsigned int)
Thread T121 (mavlink_rcv_if0) created by T120 (mavlink_if0) here:
    #0 0x7fc2bbd71815 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208
    #1 0x560bb7710915 in MavlinkReceiver::start() ../../src/modules/mavlink/mavlink_receiver.cpp:3560

Thread T120 (mavlink_if0) created by T119 here:
    #0 0x7fc2bbd71815 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208
    #1 0x560bb7ca4e8f in px4_task_spawn_cmd ../../platforms/posix/src/px4/common/tasks.cpp:246

Thread T119 created by T1 here:
    #0 0x7fc2bbd71815 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208
    #1 0x560bb7cbe7bc in px4_daemon::Server::_server_main() ../../platforms/posix/src/px4/common/px4_daemon/server.cpp:185

Thread T1 created by T0 (px4) here:
    #0 0x7fc2bbd71815 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cc:208
    #1 0x560bb7cba53c in px4_daemon::Server::start() ../../platforms/posix/src/px4/common/px4_daemon/server.cpp:106
    #2 0x7fc2bb9d26cf  (<unknown module>)

==66954==ABORTING

PoC

1、Use the following command to start px4
sudo make px4_sitl jmavsim PX4_ASAN=1
2、Use the python code to send the mavlink message to the px4

Impact

If we can create a MAVLINK message remotely and send it to PX4, a global buffer overflow vulnerability will be triggered, causing the drone to behave unexpectedly.

Error report
QQ图片20241223112515

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Adjacent
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

CVE ID

CVE-2026-32743

Weaknesses

Stack-based Buffer Overflow

A stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function). Learn more on MITRE.

Credits