CVE-2026-107373 in ExtUtils::Typemaps::STL::Stringinfo

Summary

by MITRE • 10/10/2026

ExtUtils::Typemaps::STL::String versions before 1.06 for Perl T_STD_STRING typemap may read the SV length before stringifying the argument.

The typemap uses

$var = std::string( SvPV_nolen($arg), SvCUR($arg) )

However, evaluation order for C++ arguments is not specified, and some compilers may produce code that evalutes SvCUR($arg) first.

When $arg is not a string (for example, an interger, number or a reference) then SvCUR will return an invalid value, and the program may abort or segfault.

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 10/10/2026

The vulnerability identified in ExtUtils::Typemaps::STL versions prior to 1.06 represents a critical flaw within the Perl T_STD_STRING typemap implementation for C++ bindings. This issue stems from an incorrect assumption regarding argument evaluation order when constructing std::string objects from Perl scalar values. The specific code construct utilizes SvPV_nolen($arg) and SvCUR($arg) as arguments to the std::string constructor, intending to extract the pointer to the string data and its length respectively. However, in C++, the order of evaluation for function or constructor arguments is unspecified by the language standard unless explicitly defined by sequence points. This ambiguity allows compilers to evaluate these expressions in any order they deem optimal for performance optimization.

When a compiler chooses to evaluate SvCUR($arg) before SvPV_nolen($arg), significant risks arise if $arg does not contain a valid string value. The SvCUR macro retrieves the current length of the scalar, but its behavior is undefined or returns invalid data when applied to non-string types such as integers, numbers, references, or undef values. In contrast, SvPV_nolen typically handles type coercion and validation more robustly by ensuring the argument is treated as a string before accessing its content. If SvCUR executes first on an integer or reference, it may return garbage memory addresses or incorrect length metrics that do not correspond to actual allocated buffer sizes.

This misalignment between the retrieved length and the actual data structure leads directly to out-of-bounds memory access when the std::string constructor attempts to copy data using the invalid length value. The operational impact of this flaw is severe, manifesting as application crashes, segmentation faults, or program aborts during runtime execution. In more complex scenarios involving crafted inputs, such memory corruption could potentially be leveraged for denial-of-service attacks against services relying on these Perl-C++ bindings. While immediate code exploitation for arbitrary code execution may require specific conditions regarding heap layout and compiler behavior, the instability introduced poses a substantial reliability risk to any system depending on this module for data serialization or inter-process communication via C++ libraries.

From a vulnerability classification perspective, this issue aligns with CWE-675, which denotes operations on multiple resources without sufficient synchronization, specifically relating to unspecified evaluation order leading to inconsistent state access. It also relates closely to CWE-120, Buffer Copy without Checking Size of Input, as the invalid length parameter causes buffer over-read or corruption during string construction. In terms of attack vectors, this falls under ATT&CK technique T1496, Resource Hijacking, where an attacker could potentially cause denial of service by triggering these crashes through malformed inputs in environments that expose Perl interfaces to external users.

Mitigation strategies must prioritize updating the ExtUtils::Typemaps::STL module to version 1.06 or later, which corrects this evaluation order dependency. For systems unable to update immediately, developers should implement defensive coding practices by explicitly separating the extraction of string data and length into distinct statements with intermediate variables. This ensures that SvPV_nolen is evaluated first, guaranteeing type coercion and validity checks occur before attempting to retrieve the scalar's current length. Additionally, input validation layers should be enforced at the Perl interface boundary to reject non-string types for parameters explicitly typed as T_STD_STRING, thereby preventing invalid scalars from reaching the vulnerable C++ binding code entirely.

Responsible

CPANSec

Reservation

10/07/2026

Disclosure

10/10/2026

Moderation

accepted

EPSS

0.00000

KEV

no

Activities

medium

Sources

Do you know our Splunk app?

Download it now for free!