CVE-2020-12723
Description
regcomp.c in Perl before 5.30.3 allows a buffer overflow via a crafted regular expression because of recursive S_study_chunk calls.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected products
29- Perl/Perldescription
- Range: <=5.30.2
- osv-coords27 versionspkg:rpm/opensuse/perl&distro=openSUSE%20Leap%2015.1pkg:rpm/opensuse/perl&distro=openSUSE%20Tumbleweedpkg:rpm/suse/perl&distro=HPE%20Helion%20OpenStack%208pkg:rpm/suse/perl&distro=SUSE%20Enterprise%20Storage%205pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-ESPOSpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-LTSSpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP1pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP2pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Development%20Tools%2015%20SP1pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Development%20Tools%2015%20SP2pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Package%20Hub%2015%20SP1pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Package%20Hub%2015%20SP2pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP2-BCLpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP2-LTSSpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP3-BCLpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP3-LTSSpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP4pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP5pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%2015-LTSSpkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP2pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP3pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP4pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP5pkg:rpm/suse/perl&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015pkg:rpm/suse/perl&distro=SUSE%20OpenStack%20Cloud%207pkg:rpm/suse/perl&distro=SUSE%20OpenStack%20Cloud%208pkg:rpm/suse/perl&distro=SUSE%20OpenStack%20Cloud%20Crowbar%208
< 5.26.1-lp151.9.6.1+ 26 more
- (no CPE)range: < 5.26.1-lp151.9.6.1
- (no CPE)range: < 5.34.0-1.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.26.1-7.12.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
- (no CPE)range: < 5.18.2-12.23.1
Patches
Vulnerability mechanics
Root cause
"Recursive S_study_chunk calls via GOSUB mutate the regexp program nodes, causing a buffer overflow when the outer frame processes the already-mutated nodes."
Attack vector
An attacker supplies a specially crafted regular expression that triggers recursive `S_study_chunk` calls via GOSUB. During recursion, the function mutates regexp program nodes (e.g., via `JOIN_EXACT` or trie optimization) that are still needed by the outer frame. When the outer frame later processes the already-mutated nodes, it can read or write past allocated buffer boundaries [ref_id=1]. The attack requires no special privileges—only the ability to compile a user-supplied regex pattern, which is common in Perl applications that accept regex input.
Affected code
The vulnerability resides in `S_study_chunk()` within `regcomp.c`. The function performs peephole optimizations on the regexp program, including `JOIN_EXACT`, trie construction, and node-type mutations (e.g., `EXACTFU_S_EDGE` to `EXACTFU`, `CURLYX` to `CURLYN`/`CURLYM`). These mutations are unsafe when performed inside a GOSUB recursion frame because the same program nodes may be visited again at the outer level, leading to a buffer overflow via a crafted regular expression [ref_id=1].
What the fix does
The patch introduces a `mutate_ok` boolean parameter to `S_study_chunk()` and a `in_gosub` flag on the scan frame. The top-level call passes `was_mutate_ok=TRUE` [ref_id=1]. Inside any frame where `in_gosub` is set (either directly on a GOSUB node or inherited from an outer frame), `mutate_ok` becomes false, suppressing all node-mutating optimizations (`JOIN_EXACT`, trie building, `CURLYX`→`CURLYN`/`CURLYM` conversion, `EXACTFU_S_EDGE` folding, and case-fold optimizations) [ref_id=1]. This prevents double-mutation of the regexp program and eliminates the buffer overflow.
Preconditions
- inputAttacker must be able to supply a crafted regular expression to Perl's regex compiler.
- inputThe crafted regex must contain a GOSUB construct that triggers recursive study_chunk calls.
Generated on May 31, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
16- lists.opensuse.org/opensuse-security-announce/2020-06/msg00044.htmlmitrevendor-advisoryx_refsource_SUSE
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IN3TTBO5KSGWE5IRIKDJ5JSQRH7ANNXE/mitrevendor-advisoryx_refsource_FEDORA
- security.gentoo.org/glsa/202006-03mitrevendor-advisoryx_refsource_GENTOO
- github.com/Perl/perl5/blob/blead/pod/perl5303delta.podmitrex_refsource_CONFIRM
- github.com/Perl/perl5/compare/v5.30.2...v5.30.3mitrex_refsource_CONFIRM
- github.com/Perl/perl5/issues/16947mitrex_refsource_MISC
- github.com/Perl/perl5/issues/17743mitrex_refsource_MISC
- github.com/perl/perl5/commit/66bbb51b93253a3f87d11c2695cfb7bdb782184amitrex_refsource_CONFIRM
- security.netapp.com/advisory/ntap-20200611-0001/mitrex_refsource_CONFIRM
- www.oracle.com//security-alerts/cpujul2021.htmlmitrex_refsource_MISC
- www.oracle.com/security-alerts/cpuApr2021.htmlmitrex_refsource_MISC
- www.oracle.com/security-alerts/cpuapr2022.htmlmitrex_refsource_MISC
- www.oracle.com/security-alerts/cpujan2021.htmlmitrex_refsource_MISC
- www.oracle.com/security-alerts/cpujan2022.htmlmitrex_refsource_MISC
- www.oracle.com/security-alerts/cpuoct2020.htmlmitrex_refsource_MISC
- www.oracle.com/security-alerts/cpuoct2021.htmlmitrex_refsource_MISC
News mentions
0No linked articles in our index yet.