VYPR
Unrated severityNVD Advisory· Published Dec 7, 2018· Updated Aug 5, 2024

CVE-2018-18311

CVE-2018-18311

Description

Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Affected products

21

Patches

Vulnerability mechanics

Root cause

"The Perl_my_setenv() function did not properly handle potential integer overflows when calculating memory allocations for environment variables."

Attack vector

An attacker can trigger this vulnerability by providing a crafted regular expression to Perl. This crafted input leads to invalid write operations within the Perl interpreter, specifically during the handling of environment variables. The overflow occurs when calculating the size of memory to allocate for environment variables, potentially leading to a crash or other unintended behavior.

Affected code

The vulnerability resides in the Perl_my_setenv() function, specifically in the logic that calculates and allocates memory for environment variables. The patch modifies this function by replacing direct memory allocation calls with calls to the new S_env_alloc() helper function, which includes overflow checks.

What the fix does

The patch introduces a new helper function, S_env_alloc(), which is used by Perl_my_setenv(). This new function explicitly checks for integer overflows when calculating the total size of memory to allocate by summing up individual size components. If an overflow is detected during these calculations, it calls croak_memory_wrap() to prevent the invalid memory allocation and subsequent invalid write operations.

Generated on Jun 3, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

28

News mentions

0

No linked articles in our index yet.