CVE-2007-5116: Buffer Overflow
Buffer overflow in the polymorphic opcode support in the Regular Expression Engine (regcomp.c) in Perl 5.8 allows context-dependent attackers to execute arbitrary code by switching from byte to Unicode (UTF) characters in a regular expression.
Other sources
Tavis Ormandy and Will Drewry have discovered a flaw in the way perl calculates the space needed to process a regular expression. It is possible to cause the two passes to mismatch. To quote their mail:
The compile phase uses multiple passes (similar to older pcre releases), once to determine space requirements and another to actually compile the expression, however it's very simple to cause the two passes to mismatch. From the perl documentation:
> The regular expression compiler produces polymorphic opcodes.That is, > the pattern adapts to the data and automatically switches to the Unicode > character scheme when presented with Unicode data--or instead uses a > traditional byte scheme when presented with byte data.
This unfortunately means that you can cause the mode to switch at an arbitrary point, and then subsequent passes of any of the expression prior to this point switch will be passed differently, and thus potentially have their space requirements miscalculated.
Acknowledgements:
Red Hat would like to thank Tavis Ormandy and Will Drewry for properly disclosing this issue.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2007-5116?
CVE-2007-5116 is classified as a critical vulnerability due to its potential to allow arbitrary code execution through a buffer overflow.
How do I fix CVE-2007-5116?
To remediate CVE-2007-5116, upgrade to a patched version of Perl that addresses this issue.
Which versions of Perl are affected by CVE-2007-5116?
CVE-2007-5116 affects Perl versions 5.8.0 through 5.8.4.5.
Can CVE-2007-5116 be exploited remotely?
Yes, CVE-2007-5116 can be exploited by context-dependent attackers remotely through crafted regular expressions.
What impact does CVE-2007-5116 have on applications using Perl?
Applications using vulnerable versions of Perl may be subject to arbitrary code execution, leading to potential data breaches or system compromise.