Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-11012

CVE-2025-11012: BehaviorTree Stack Buffer Overflow Vulnerability

CVE-2025-11012 is a stack-based buffer overflow in BehaviorTree up to 4.7.0 affecting the ParseScript function. Attackers with local access can exploit this flaw. This article covers technical details, affected versions, impact analysis, and mitigation strategies.

Published:

CVE-2025-11012 Overview

CVE-2025-11012 is a stack-based buffer overflow [CWE-119] in BehaviorTree.CPP versions up to 4.7.0. The flaw resides in the ParseScript function of /src/script_parser.cpp, part of the Diagnostic Message Handler component. Manipulation of the error_msgs_buffer argument can overflow a fixed 2048-byte stack buffer used to hold parser error output. Exploitation requires local access with low privileges, and no user interaction is needed. The maintainers merged the fix under commit cb6c7514efa628adb8180b58b4c9ccdebbe096e3, which replaces the fixed-size buffer with a dynamically growing std::string.

Critical Impact

A local attacker with low privileges can trigger memory corruption in applications embedding BehaviorTree.CPP, potentially destabilizing robotics and AI decision-making workloads that rely on the library.

Affected Products

  • BehaviorTree.CPP versions up to and including 4.7.0
  • Robotics and AI applications embedding the BehaviorTree.CPP library
  • Downstream ROS-based systems using the vulnerable script parser

Discovery Timeline

  • 2025-09-26 - CVE-2025-11012 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-11012

Vulnerability Analysis

BehaviorTree.CPP is a C++ library that implements behavior trees, widely used in robotics and autonomous systems. The ParseScript function parses embedded scripting statements used inside behavior tree nodes. The parser reports syntax and semantic errors to a caller-supplied buffer via ErrorReport().to(...).

Before the patch, ParseScript allocated a fixed 2048-byte character buffer on the stack for error output. When the parser encountered input that produced error messages longer than 2048 bytes, the lexy ErrorReport sink wrote past the buffer boundary. This corrupts adjacent stack memory, including saved return addresses and frame pointers. The bug is triggered by supplying a crafted script string that intentionally produces oversized diagnostic output.

Root Cause

The root cause is unbounded writes into a fixed-size stack buffer. The original implementation used char error_msgs_buffer[2048] and passed a raw pointer sink to the lexy parser. The sink has no knowledge of the buffer capacity and does not enforce bounds checks. Any parse path that emits more than 2048 bytes of error text overflows the stack frame of ParseScript.

Attack Vector

Exploitation requires local access and the ability to supply script input to an application that calls ParseScript. The attacker submits a crafted script designed to produce large error diagnostics. A public proof-of-concept has been disclosed in GitHub Issue #1006 and an attached PoC archive.

cpp
// Patch from src/script_parser.cpp (commit cb6c7514)
Expected<ScriptFunction> ParseScript(const std::string& script)
{
-  char error_msgs_buffer[2048];
+  std::string error_msgs_buffer;  // dynamically growing error buffer

   auto input = lexy::string_input<lexy::utf8_encoding>(script);
-  auto result =
-      lexy::parse<BT::Grammar::stmt>(input, ErrorReport().to(error_msgs_buffer));
+
+  auto reporter = ErrorReport().to(std::back_inserter(error_msgs_buffer));
+  auto result = lexy::parse<BT::Grammar::stmt>(input, reporter);
   if(result.has_value() && result.error_count() == 0)
   {
     try

Source: BehaviorTree.CPP commit cb6c7514. The fix replaces the fixed stack array with a std::string and a std::back_inserter sink, letting the buffer grow to accommodate any error output.

Detection Methods for CVE-2025-11012

Indicators of Compromise

  • Crashes or abnormal termination of processes linking BehaviorTree.CPP when parsing user-supplied scripts
  • Core dumps showing stack corruption within ParseScript or lexy ErrorReport sink frames
  • Unusually large behavior-tree script inputs sourced from untrusted or user-writable locations

Detection Strategies

  • Inventory binaries and containers that statically or dynamically link BehaviorTree.CPP at version 4.7.0 or earlier using software composition analysis (SCA)
  • Enable stack canaries, -fstack-protector-strong, and AddressSanitizer builds in test environments to catch overflow attempts in ParseScript
  • Review application logs for repeated parse failures preceding crashes, which may indicate probing for the overflow condition

Monitoring Recommendations

  • Monitor host telemetry for unexpected termination signals (SIGSEGV, SIGABRT) in robotics or autonomy processes
  • Alert on file writes to script directories consumed by BehaviorTree-based services from unprivileged users
  • Track library versions via package inventory and flag any host still running behaviortree.cpp <= 4.7.0

How to Mitigate CVE-2025-11012

Immediate Actions Required

  • Upgrade BehaviorTree.CPP to a build that includes commit cb6c7514efa628adb8180b58b4c9ccdebbe096e3 and rebuild all dependent applications
  • Restrict local access to hosts running BehaviorTree-based services and audit which accounts can supply script input
  • Validate and size-limit any behavior-tree scripts loaded from disk or received over IPC before invoking ParseScript

Patch Information

The upstream fix is available in commit cb6c7514, merged via Pull Request #1007. Rebuild all downstream binaries and container images after updating the library, since BehaviorTree.CPP is often statically linked.

Workarounds

  • Enforce input size limits on scripts passed to ParseScript at the application layer to keep error output well below 2048 bytes
  • Run BehaviorTree-consuming processes under least-privilege service accounts with seccomp or AppArmor confinement
  • Compile downstream applications with stack protection and position-independent executables to raise the cost of exploitation
bash
# Verify the installed BehaviorTree.CPP version and rebuild after patching
git -C BehaviorTree.CPP log --oneline | grep cb6c7514
cmake -S BehaviorTree.CPP -B build -DCMAKE_CXX_FLAGS="-fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2"
cmake --build build --target install

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.