CVE-2021-40812 in Libgd
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.
Affects 1 product from 1 vendor. Facts below cite their sources.
Remotely exploitable over the network, low complexity, no authentication required, requires user interaction, impact contained to the vulnerable component, no confidentiality impact, no integrity impact, full availability impact.
Affected products and versions
| Vendor | Product | Affected versions |
|---|---|---|
| Libgd | Libgd | ≤ 2.3.2 |
A product listed here is affected only at the versions shown. Use the free check to test the exact version you run.
Fix and vendor advisory
No official vendor advisory link on record. See the CVE record.
Exploitation
| CISA known-exploited | Not in the CISA KEV catalog |
|---|---|
| Public exploit | Not confirmed |
Official description
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.
Source: NIST NVD / MITRE CVE.
Record details
| CVE ID | CVE-2021-40812 |
|---|---|
| BreachSpider ID | BS-2021-GLOBAL-307559-M |
| CVSS vector | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H |
| Published | 2021-09-08 |
| Last modified | 2026-06-17 |
| Weakness (CWE) | |
| Source | NVD |
Weakness definitions
CWE-125: Out-of-Bounds Read
Software reads data past the boundary of an allocated buffer, leaking sensitive information or causing crashes.
Related attack patterns (CAPEC)
CAPEC-540 Overread Buffers via CWE-125
Mapping is CWE to CAPEC per MITRE CAPEC 3.9.
Analysis AI-written, not human-reviewed
The GD Graphics Library (LibGD) through version 2.3.2 contains an out-of-bounds read vulnerability due to insufficient checks on the return values of gdGetBuf and gdPutBuf functions.
An attacker could exploit this vulnerability by providing a specially crafted image file to a program that uses the affected version of LibGD. This could lead to information disclosure or potentially more severe issues, depending on the context in which the library is used.
Questions
What is CVE-2021-40812?
The GD Graphics Library (LibGD) through version 2.3.2 contains an out-of-bounds read vulnerability due to insufficient checks on the return values of gdGetBuf and gdPutBuf functions.
What is the CVSS score for CVE-2021-40812?
CVE-2021-40812 has CVSS 6.5 (Medium). Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H. EPSS: 1.4%.
Is CVE-2021-40812 actively exploited?
No confirmed active exploitation of CVE-2021-40812 as of 2026-09-25.
How do I remediate CVE-2021-40812?
Priority: MEDIUM.
What systems are affected by CVE-2021-40812?
CVE-2021-40812 affects Libgd Libgd.
For developers and AI agents
Run this check from your own code or agent
REST API
curl -s https://breachspider.com/api/v1/assets/correlate-cves \
-H "Authorization: Bearer $BREACHSPIDER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"assets":[{"asset_id":"dev-1","vendor":"Libgd","product":"Libgd","version":"1.0"}]}'
MCP for AI agents
# hosted: add as a connector
https://mcp.breachspider.com/mcp
# local
pipx install breachspider-mcp
Free trial: 14 days, 750 device checks, no card.
Page facts from NVD, MITRE, CISA and vendor advisories, record last modified 2026-06-17.