XS::Parse::Infix versions from 0.40 through 0.49 for Perl treat a number as an array reference
XS::Parse::Infix versions from 0.40 through 0.49 for Perl treat a number as an array reference. The wrapper function XS::Parse::Infix generates for a list-associative infix operator checks whether arguments are array references, but it tests using SvRV() rather than SvROK(). SvRV() reads a union slot that only holds a referent once SvROK(sv) is true, so the guard never validates that it is a reference. For an IV or NV that slot holds the number itself, SvRV() returns the caller's value and SvTYPE() dereferences it at offset 12. This will generally result in a segmentation fault. An application that hands the wrapper a list built from decoded input (for example, from JSON) lets whoever supplies a number in that list choose the address that the interpreter dereferences. An ordinary string's byte 12 is rarely SVt_PVAV so the guard croaks by luck, but an attacker-crafted string carrying 0x0b there passes, and the buffer is then used as an AV head, with AvARRAY taken from bytes 16-23 and its entries pushed onto the Perl stack as live SVs. A simple proof-of-concept uses the zip operator: use Syntax::Operator::Zip 'zip'; my @args = ([1], 2); zip(@args);
Affected versions and mitigation
From the CVE record and the vendor's references.Affected
- >= 0.40, <= 0.49
Mitigation
Upgrade to XS-Parse-Keyword 0.50 or later.
Workaround
For deployments that cannot upgrade, ensure that correct arguments (only array references where they are expected) are passed to list-associative operators that are defined with XS::Parse::Infix, such as those in Syntax::Operator::Zip.
References
- Release notes metacpan.org/release/PEVANS/XS-Parse-Keyword-0.5…
Timeline
Days relative to CVE publicationNo public PoC found yet; not in CISA KEV.
PoC repositories
Found on GitHub.No PoC repositories found yet.