CVE-2022-31630: OOB read due to insufficient input validation in imageloadfont()
Fixed bug : OOB read due to insufficient input validation in imageloadfont(). (CVE-2022-31630)
Other sources
In PHP versions prior to 7.4.33, 8.0.25 and 8.1.12, when using imageloadfont() function in gd extension, it is possible to supply a specially crafted font file, such as if the loaded font is used with imagechar() function, the read outside allocated buffer will be used. This can lead to crashes or disclosure of confidential information.
— Launchpad
In PHP versions prior to 7.4.33, 8.0.25 and 8.2.12, when using imageloadfont() function in gd extension, it is possible to supply a specially crafted font file, such as if the loaded font is used with imagechar() function, the read outside allocated buffer will be used. This can lead to crashes or disclosure of confidential information.
It is possible to construct font files supposed to be loaded by imageloadfont() which trigger OOB reads if the fonts are actually accessed (e.g. by imagechar()). The given test scripts exploits that by triggering the assignment of a zero byte memory allocation to gdFont.data (which is happily accepted by imageloadfont()), and to read beyond this "buffer" when calling imagechar(). So if an application allows to upload arbitrary font files and working with these, it is likely vulnerable.
References: https://www.php.net/ChangeLog-8.php#8.0.25 https://bugs.php.net/bug.php?id=81739
— Red Hat
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 8.0.25 - Upgrade
Upgrade
alpine/php7to a version that resolves this vulnerability.Fixed in 7.4.33-r0 - Upgrade
Upgrade
alpine/php8to a version that resolves this vulnerability.Fixed in 8.0.25-r0 - Upgrade
Upgrade
alpine/php81to a version that resolves this vulnerability.Fixed in 8.1.12-r0 - Upgrade
Upgrade
alpine/php82to a version that resolves this vulnerability.Fixed in 8.2.0_rc5-r0 - Upgrade
Upgrade
redhat/phpto a version that resolves this vulnerability.Fixed in 7.4.33 - Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 7.4.33 - Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 8.1.12 - Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 8.2.12
Event History
Frequently Asked Questions
What is the vulnerability ID?
The vulnerability ID is CVE-2022-31630.
What is the title of the vulnerability?
The title of the vulnerability is Fixed bug: OOB read due to insufficient input validation in imageloadfont(). (CVE-2022-31630).
What is the severity of CVE-2022-31630?
The severity of CVE-2022-31630 is not specified.
How does CVE-2022-31630 affect PHP?
CVE-2022-31630 affects PHP versions prior to 7.4.33, 8.0.25, and 8.2.12.
How can I fix CVE-2022-31630?
To fix CVE-2022-31630, upgrade to PHP version 7.4.33 or apply the recommended patches.