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

22 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
redhat/php<7.4.33
7.4.33
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
debian/php7.3
debian/php7.4
7.4.33-1+deb11u1
debian/php8.1
8.1.12-1
debian/php7.4<7.4.33-1+deb11u1
7.4.33-1+deb11u1

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 redhat/php to a version that resolves this vulnerability.

    Fixed in 7.4.33
  3. Upgrade

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

    Fixed in 7.4.33-r0
  4. Upgrade

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

    Fixed in 8.0.25-r0
  5. Upgrade

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

    Fixed in 8.1.12-r0
  6. Upgrade

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

    Fixed in 8.2.0_rc5-r0
  7. Upgrade

    Upgrade debian/php7.4 to a version that resolves this vulnerability.

    Fixed in 7.4.33-1+deb11u1
  8. Upgrade

    Upgrade debian/php8.1 to a version that resolves this vulnerability.

    Fixed in 8.1.12-1
  9. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 7.4.33
  10. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.1.12
  11. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 8.2.12

Event History

Oct 27, 2022
Updated
12:00 AM
Affected Software
Oct 31, 2022
CVE Published
12:00 AM
Data Sourced
12:00 AM
RemedyDescriptionSeverityAffected Software
Updated
via Ubuntu·12:00 AM
Description
Updated
via Ubuntu·12:00 AM
DescriptionAffected Software
Nov 2, 2022
Data Sourced
via Red Hat·04:51 AM
DescriptionSeverityAffected Software
Nov 3, 2022
Data Sourced
via PHP·12:00 AM
DescriptionAffected Software
Updated
12:00 AM
Affected Software
Nov 14, 2022
CVE Published
via MITRE·06:53 AM
Data Sourced
via MITRE·06:53 AM
DescriptionSeverityWeakness
Data Sourced
via OSV·07:15 AM
DescriptionSeverityAffected Software
Dec 8, 2022
Updated
12:00 AM
Affected Software
Dec 23, 2022
Data Sourced
05:05 PM
Weakness
Nov 7, 2023
Data Sourced
via NVD·03:47 AM
RemedyDescriptionSeverityWeaknessAffected Software
Updated
via NVD·03:47 AM
Affected Software
Apr 2, 2024
Updated
via NVD·03:15 AM
DescriptionAffected Software
Nov 21, 2024
Updated
via NVD·07:04 AM
RemedyAffected Software
Mar 14, 2026
Exploit Published
via GitHub·02:33 PM
Jun 17, 2026
Updated
via NVD·04:45 AM
Affected Software
Nov 24, 2026
Withdrawn
via OSV·04:29 AM

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