CVE-2021-40812
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack...
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- Required
What an attacker can affect
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Exploit likelihood
What each source reports
NVD Score used
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
CVE-2021-40812- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - CVSS 2.0
- 4.3 Medium
AV:N/AC:M/Au:N/C:N/I:N/A:P - Weakness
- CWE-125
- Updated
- 2026-11-02
CVE List
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
CVE-2021-40812- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-125
- Updated
- 2026-11-02
EUVDEUVD-2021-27976
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
EUVD-2021-27976- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-03
GitHub AdvisoriesGHSA-53w9-wg73-ghrw
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack...
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
GHSA-53w9-wg73-ghrw- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-125
- Updated
- 2026-11-02
OSVAZL-6433
6.5
CVE-2021-40812 affecting package gd for versions less than 2.3.3-1
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
AZL-6433- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSV
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
CVE-2021-40812- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
Show 12 moreShow less
OSVDEBIAN-CVE-2021-40812
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
DEBIAN-CVE-2021-40812- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVJLSEC-2026-361
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
JLSEC-2026-361- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - CVSS 2.0
- 4.3 Medium
AV:N/AC:M/Au:N/C:N/I:N/A:P - Updated
- 2026-11-02
OSVOESA-2021-1353
6.5
gd security update
The gd graphics library allows your code to quickly draw images complete with lines, arcs, text, multiple colors, cut and paste from other images, and flood fills, and to write out the result as a PNG or JPEG file. The most common applications of GD involve website development, although it can be used with any standalone application!
Security Fix(es):
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.(CVE-2021-40812)
- Record
OESA-2021-1353- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVUBUNTU-CVE-2021-40812
6.5
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks.
- Record
UBUNTU-CVE-2021-40812- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVCLSA-2021-1635459219 No score
Fix CVE(s): CVE-2021-40812, CVE-2021-40145, CVE-2021-38115, CVE-2017-6363
- SECURITY UPDATE: unhandled memory allocation error in gdImageGd2Ptr
- debian/patches/CVE-2021-40145.patch: check for non-zero return code from _gdImageGd2
- CVE-2021-40145
- SECURITY UPDATE: unhandled value returned from gdPutBuf
- debian/patches/CVE-2021-40812.patch: handle possible gdPutBuf error in _gdImageBmpCtx and _gdImageWebpCtx CVE-2021-40812
- SECURITY UPDATE: unhandled value returned from gdGetBuf
- debian/patches/CVE-2021-38115.patch: handle possible gdGetBuf error in read_header_tga CVE-2021-38115
- SECURITY UPDATE: handle possible heap buffer overread
- debian/patches/CVE-2017-6363.patch: make sure transparent index is within bounds of the palette CVE-2017-6363
- Record
CLSA-2021-1635459219- Updated
- 2026-11-02
OSVCLSA-2023-1689009763 No score
Fix CVE(s): CVE-2021-40812
- SECURITY UPDATE: Out of bounds read due to a lack of return value checks
- debian/patches/CVE-2021-40812.patch: Added return value checks following calls to gdPutBuf in src/gd_webp.c and src/gd_bmp.c
- CVE-2021-40812
- Record
CLSA-2023-1689009763- Updated
- 2026-11-02
OSVCLSA-2026-1779823719 No score
gd: Fix of CVE-2021-40812
- CVE-2021-40812: out-of-bounds read in BMP/WebP output due to unchecked gdPutBuf return values
- Record
CLSA-2026-1779823719- Updated
- 2026-11-02
OSVMGASA-2021-0449 No score
Updated libgd packages fix security vulnerability
The updated packages fix a security vulnerability:
The GD Graphics Library (aka LibGD) through 2.3.2 has an out-of-bounds read because of the lack of certain gdGetBuf and gdPutBuf return value checks (CVE-2021-40812).
- Record
MGASA-2021-0449- Updated
- 2026-11-02
OSVopenSUSE-SU-2021:3236-1 No score
Security update for gd
This update for gd fixes the following issues:
- CVE-2021-40812: Fixed out-of-bounds read caused by the lack of certain gdGetBuf and gdPutBuf return value checks (bsc#1190400).
- Record
openSUSE-SU-2021:3236-1- Updated
- 2026-11-02
OSVSUSE-SU-2021:3214-1 No score
Security update for gd
This update for gd fixes the following issues:
- CVE-2021-40812: Fixed out-of-bounds read caused by the lack of certain gdGetBuf and gdPutBuf return value checks (bsc#1190400).
- Record
SUSE-SU-2021:3214-1- Updated
- 2026-11-02
OSVSUSE-SU-2021:3236-1 No score
Security update for gd
This update for gd fixes the following issues:
- CVE-2021-40812: Fixed out-of-bounds read caused by the lack of certain gdGetBuf and gdPutBuf return value checks (bsc#1190400).
- Record
SUSE-SU-2021:3236-1- Updated
- 2026-11-02
OSVUSN-7112-1 No score
libgd2 vulnerability
It was discovered that the GD Graphics Library did not perform proper bounds checking while handling BMP and WebP files. If a user were tricked into opening a specially crafted file, an attacker could possibly use this issue to cause a denial of service (application crash).
- Record
USN-7112-1- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
gdAzure Linux:2 |
before 2.3.3-1 | 2.3.3-1 |
libgd-devTuxCare:Ubuntu:16.04 From an advisory covering 4 CVEs |
before 2.1.1-4ubuntu0.16.04.13 | 2.1.1-4ubuntu0.16.04.13 |
libgd-toolsTuxCare:Ubuntu:16.04 From an advisory covering 4 CVEs |
before 2.1.1-4ubuntu0.16.04.13 | 2.1.1-4ubuntu0.16.04.13 |
libgd3TuxCare:Ubuntu:16.04 From an advisory covering 4 CVEs |
before 2.1.1-4ubuntu0.16.04.13 | 2.1.1-4ubuntu0.16.04.13 |
libgd-devTuxCare:Ubuntu:18.04 |
before 2.2.5-4ubuntu0.5+tuxcare.els1 | 2.2.5-4ubuntu0.5+tuxcare.els1 |
libgd-toolsTuxCare:Ubuntu:18.04 |
before 2.2.5-4ubuntu0.5+tuxcare.els1 | 2.2.5-4ubuntu0.5+tuxcare.els1 |
libgd3TuxCare:Ubuntu:18.04 |
before 2.2.5-4ubuntu0.5+tuxcare.els1 | 2.2.5-4ubuntu0.5+tuxcare.els1 |
gdTuxCare:AlmaLinux:9.2 |
before 2.3.2-3.el9_2.tuxcare.els3 | 2.3.2-3.el9_2.tuxcare.els3 |
gd-develTuxCare:AlmaLinux:9.2 |
before 2.3.2-3.el9_2.tuxcare.els3 | 2.3.2-3.el9_2.tuxcare.els3 |
gd-progsTuxCare:AlmaLinux:9.2 |
before 2.3.2-3.el9_2.tuxcare.els3 | 2.3.2-3.el9_2.tuxcare.els3 |
Show 25 moreShow less
| Package | Affected | Fixed |
|---|---|---|
libgd2Debian:12 |
before 2.3.3-1 | 2.3.3-1 |
libgd2Debian:13 |
before 2.3.3-1 | 2.3.3-1 |
libgd2Debian:14 |
before 2.3.3-1 | 2.3.3-1 |
libgd2Debian:10 From an advisory covering 3 CVEs |
before 2.2.5-5.2+deb10u1, plus listed versions 2.2.5-5.2 |
2.2.5-5.2+deb10u1 |
libgd2Debian:11 From an advisory covering 3 CVEs |
before 2.3.0-2+deb11u1, plus listed versions 2.3.0-2 |
2.3.0-2+deb11u1 |
LibGD_jllJulia |
before 2.3.3+0 | 2.3.3+0 |
libgdMageia:8 |
before 2.3.1-1.3.mga8 | 2.3.1-1.3.mga8 |
gdopenEuler:20.03-LTS-SP1 |
before 2.3.0-3.oe1 | 2.3.0-3.oe1 |
gdopenEuler:20.03-LTS-SP2 |
before 2.3.0-3.oe1 | 2.3.0-3.oe1 |
gdSUSE:Linux Enterprise Software Development Kit 12 SP5 |
before 2.1.0-24.20.1 | 2.1.0-24.20.1 |
gdSUSE:Linux Enterprise Server 12 SP5 |
before 2.1.0-24.20.1 | 2.1.0-24.20.1 |
gdSUSE:Linux Enterprise Server for SAP Applications 12 SP5 |
before 2.1.0-24.20.1 | 2.1.0-24.20.1 |
gdSUSE:Linux Enterprise Workstation Extension 12 SP5 |
before 2.1.0-24.20.1 | 2.1.0-24.20.1 |
gdSUSE:Linux Enterprise Module for Basesystem 15 SP2 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
gdSUSE:Linux Enterprise Module for Basesystem 15 SP3 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
gdSUSE:Linux Enterprise Module for Desktop Applications 15 SP2 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
gdSUSE:Linux Enterprise Module for Desktop Applications 15 SP3 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
gdSUSE:Linux Enterprise Module for Package Hub 15 SP2 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
gdSUSE:Linux Enterprise Module for Package Hub 15 SP3 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
libgd2Ubuntu:Pro:14.04:LTS |
All versions, plus listed versions 2.1.0-22.1.0-32.1.0-3ubuntu0.12.1.0-3ubuntu0.22.1.0-3ubuntu0.3 Show 8 moreShow less2.1.0-3ubuntu0.52.1.0-3ubuntu0.62.1.0-3ubuntu0.72.1.0-3ubuntu0.82.1.0-3ubuntu0.102.1.0-3ubuntu0.112.1.0-3ubuntu0.11+esm12.1.0-3ubuntu0.11+esm2 |
None known |
libgd2Ubuntu:Pro:16.04:LTS |
before 2.1.1-4ubuntu0.16.04.12+esm4, plus listed versions 2.1.1-4build12.1.1-4build22.1.1-4ubuntu0.16.04.12.1.1-4ubuntu0.16.04.22.1.1-4ubuntu0.16.04.3 Show 8 moreShow less2.1.1-4ubuntu0.16.04.52.1.1-4ubuntu0.16.04.62.1.1-4ubuntu0.16.04.72.1.1-4ubuntu0.16.04.82.1.1-4ubuntu0.16.04.102.1.1-4ubuntu0.16.04.112.1.1-4ubuntu0.16.04.122.1.1-4ubuntu0.16.04.12+esm1 |
2.1.1-4ubuntu0.16.04.12+esm4 |
libgd2Ubuntu:Pro:18.04:LTS |
before 2.2.5-4ubuntu0.5+esm3, plus listed versions 2.2.5-32.2.5-42.2.5-4ubuntu0.22.2.5-4ubuntu0.32.2.5-4ubuntu0.42.2.5-4ubuntu0.5 |
2.2.5-4ubuntu0.5+esm3 |
libgd2Ubuntu:20.04:LTS |
before 2.2.5-5.2ubuntu2.4, plus listed versions 2.2.5-5.22.2.5-5.2ubuntu22.2.5-5.2ubuntu2.1 |
2.2.5-5.2ubuntu2.4 |
libgd2Ubuntu:22.04:LTS |
before 2.3.0-2ubuntu2.3, plus listed versions 2.3.0-2ubuntu12.3.0-2ubuntu2 |
2.3.0-2ubuntu2.3 |
gdopenSUSE:Leap 15.3 |
before 2.2.5-11.3.1 | 2.2.5-11.3.1 |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected, facts | ||
| aliases | EUVD | |
| first indexed | CVE List, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2021-40812 is a medium vulnerability (CVSS 6.5) in Libgd, published September 8, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.66%, the 76th percentile. Fixed in gd 2.3.3-1.
References
github.com/libgd/libgd/commit/6f5136821be86e7068fcdf651ae9420b5d42e9a9
github.com/libgd/libgd/issues/750
lists.debian.org/debian-lts-announce/2024/04/msg00003.html
nvd.nist.gov/vuln/detail/CVE-2021-40812
github.com/advisories/GHSA-53w9-wg73-ghrw
errata.cloudlinux.com/ubuntu16_04/CLSA-2021-1635459219
Show 14 moreShow less
errata.cloudlinux.com/ubuntu18_04-els/CLSA-2023-1689009763
errata.tuxcare.com/els_os/almalinux9.2esu/CLSA-2026-1779823719.html
security-tracker.debian.org/tracker/CVE-2021-40812
advisories.mageia.org/MGASA-2021-0449.html
bugs.mageia.org/show_bug.cgi?id=29486
lists.opensuse.org/archives/list/[email protected]/thread/FCVD7RYV2TSOLINPDAIY7P7Q4OSCOREN
openeuler.org/en/security/safety-bulletin/detail.html?id=openEuler-SA-2021-1353
suse.com/support/update/announcement/2021/suse-su-20213214-1
bugzilla.suse.com/1190400
suse.com/security/cve/CVE-2021-40812
suse.com/support/update/announcement/2021/suse-su-20213236-1
ubuntu.com/security/CVE-2021-40812
cve.org/CVERecord?id=CVE-2021-40812
ubuntu.com/security/notices/USN-7112-1