Skip to content
Memory corruption Disclosed report Advanced CVE-2020-7065

mb_strtolower (UTF-32LE): stack-buffer-overflow at php_unicode_tolower_full (CVE-2020-7065)

A call to the mb_strtolower function with UTF-32LE encoding could overwrite a stack-allocated buffer using an overflown array from read-only data. An attacker able to pass a specific invalid UTF character could crash the PHP interpreter, and the CVE entry notes potential memory corruption and code execution.

anatoliq Follow

Originally disclosed on HackerOne

  • Disclosed after 7 months

PHP bug report (made public by the maintainers at the time of writing): https://bugs.php.net/bug.php?id=79371 Mitre CVE page: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-7065 Link to the release notes: https://www.php.net/ChangeLog-7.php#7.4.4

Impact

One of impacts is that the issue allows an attacker to straightforwardly crash the PHP interpreter provided a specific UTF character can be passed to mb_strtolower function dealing with UTF-32LE encoding.

Original summary from the bug report:

A call to mb_strtolower allows overwriting of a stack-allocated buffer with an overflown array from .rodata.

Description as provided by CVE database entry:

In PHP versions 7.3.x below 7.3.16 and 7.4.x below 7.4.34, while using mb_strtolower() function with UTF-32LE encoding, certain invalid strings could cause PHP to overwrite stack-allocated buffer. This could lead to memory corruption, crashes and potentially code execution.

The original report as published on HackerOne, by anatoliq. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the lowercase conversion routine for UTF-32LE did not validate the input character properly, so a lookup into a read-only table went out of bounds and the result was written past a stack buffer.

Impact

An attacker who can pass a specific invalid UTF character to mb_strtolower with UTF-32LE encoding could crash the PHP interpreter, and the CVE entry says this could lead to memory corruption, crashes and potentially code execution.

What the attacker needed

Attacker can pass a crafted string to mb_strtolower; UTF-32LE encoding is used

The fix

The linked release notes are for PHP 7.4.4; the text does not state the fix versions.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

PHP has a function that converts text to lowercase, and it can be told the text is stored in a particular Unicode format. When given a malformed character in that format, the function wrote past the end of a small piece of memory reserved for temporary data. That kind of out-of-bounds write can crash the program and, in principle, let an attacker run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.