Perl versions before 5.40.5-RC1, from 5.41.0 before 5.42.3-RC1, from 5.43.0 before 5.43.11 have an integer overflow in S_measure_struct leading to an out-of-bounds heap read in pack and unpack
perl
perl
| Product | Affected | Fixed in |
|---|---|---|
| perl |
| No fix yet |
Perl versions before 5.40.5-RC1, from 5.41.0 before 5.42.3-RC1, from 5.43.0 before 5.43.11 have an integer overflow in S_measure_struct leading to an out-of-bounds heap read in pack and unpack.
S_measure_struct adds each item's size times its repeat count to a running total with no overflow check, so a large repeat count in a pack or unpack template wraps the signed SSize_t total negative. The @, X, and x position codes then guard their moves with a signed length comparison that passes when the length is negative, advancing the buffer pointer out of bounds.
A template derived from untrusted input can read heap memory past the buffer and return it to the caller.
From the CVE record · CPANSec
An integer overflow in Perl's S_measure_struct can cause pack and unpack to read beyond a heap buffer. This can happen when an application processes a template derived from untrusted input with a large repeat count; the read data can be returned to the caller. The input does not specify whether authentication or user interaction is required.
Engineers running Perl before 5.40.5-RC1, versions from 5.41.0 before 5.42.3-RC1, or versions from 5.43.0 before 5.43.11 should check their deployments.