CVE-2022-31630: OOB read due to insufficient input validation in imageloadfont()

Published Oct 27, 2022
·
Updated

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

20 affected componentsFixes available
PHP PHP>=7.4.0<7.4.33
PHP PHP>=8.0.0<8.0.25
PHP PHP>=8.1.0<8.1.12
PHP PHP<8.0.25
8.0.25
debian/php7.3
debian/php8.1
alpine/php7<7.4.33-r0
7.4.33-r0
alpine/php7<7.4.33-r0
7.4.33-r0
alpine/php8<8.0.25-r0
8.0.25-r0
alpine/php8<8.0.25-r0
8.0.25-r0
alpine/php81<8.1.12-r0
8.1.12-r0
alpine/php81<8.1.12-r0
8.1.12-r0
alpine/php81<8.1.12-r0
8.1.12-r0
alpine/php81<8.1.12-r0
8.1.12-r0
alpine/php82<8.2.0_rc5-r0
8.2.0_rc5-r0
alpine/php82<8.2.0_rc5-r0
8.2.0_rc5-r0
alpine/php82<8.2.0_rc5-r0
8.2.0_rc5-r0
alpine/php82<8.2.0_rc5-r0
8.2.0_rc5-r0
alpine/php82<8.2.0_rc5-r0
8.2.0_rc5-r0
redhat/php<7.4.33
7.4.33

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.0.25
  2. Upgrade

    Upgrade alpine/php7 to a version that resolves this vulnerability.

    Fixed in 7.4.33-r0
  3. Upgrade

    Upgrade alpine/php8 to a version that resolves this vulnerability.

    Fixed in 8.0.25-r0
  4. Upgrade

    Upgrade alpine/php81 to a version that resolves this vulnerability.

    Fixed in 8.1.12-r0
  5. Upgrade

    Upgrade alpine/php82 to a version that resolves this vulnerability.

    Fixed in 8.2.0_rc5-r0
  6. Upgrade

    Upgrade redhat/php to a version that resolves this vulnerability.

    Fixed in 7.4.33
  7. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 7.4.33
  8. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.1.12
  9. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.2.12

Event History

Oct 27, 2022
CVE Published
via PHP·12:00 AM
Nov 2, 2022
Data Sourced
via Red Hat·04:51 AM
DescriptionSeverityAffected Software
Nov 14, 2022
CVE Published
via MITRE·06:53 AM
Data Sourced
via MITRE·06:53 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Data Sourced
via OSV·07:15 AM
DescriptionSeverityAffected Software
Mar 14, 2026
Exploit Published
via GitHub·02:33 PM

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is the vulnerability ID?

The vulnerability ID is CVE-2022-31630.

2

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).

3

What is the severity of CVE-2022-31630?

The severity of CVE-2022-31630 is not specified.

4

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.

5

How can I fix CVE-2022-31630?

To fix CVE-2022-31630, upgrade to PHP version 7.4.33 or apply the recommended patches.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203