CVE-2026-56412: libexpat Use-After-Free in CDATA Handler Depth Tracking
libexpat, a widely-used XML parsing library, contains a use-after-free vulnerability in its CDATA section handling. The issue stems from incomplete depth tracking when handlers are invoked during XML processing, allowing memory already freed by one operation to be accessed by another. This affects versions before 2.8.2. While the immediate trigger requires specific XML policy violations and local system access, the underlying condition can lead to crashes or potentially arbitrary code execution if an attacker controls the malicious XML input.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 4.9 MEDIUM · CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L
- Weaknesses (CWE)
- CWE-416
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-21 / 2026-06-23
NVD description (verbatim)
libexpat before 2.8.2 does not consider XML_TOK_DATA_CHARS in doCdataSection and thus lacks handler call depth tracking for various calls from within handlers in cases of a policy violation. Thus, a use-after-free can occur. NOTE: this issue exists because of an incomplete fix for CVE-2026-50219.
1 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
CVE-2026-56412 is a use-after-free (CWE-416) vulnerability in libexpat's CDATA section processing. The root cause lies in the doCdataSection function's failure to properly track XML_TOK_DATA_CHARS tokens when managing handler call depth. This incomplete remediation of CVE-2026-50219 leaves a gap where certain policy-violating handler invocations can free memory that subsequent operations attempt to reference. The vulnerability manifests when handlers trigger recursive or nested calls during CDATA processing on a local system, though the exact conditions depend on the XML schema and handler configuration in use.
Business impact
Organizations using libexpat in XML parsing pipelines—including document processors, configuration management tools, and API gateways—face potential service disruption or data corruption if untrusted XML reaches vulnerable parsers. Because exploitability requires local access and specific handler conditions, the risk is highest in server environments processing user-supplied XML or in supply-chain scenarios where XML validation is part of a critical workflow. Patches are straightforward, making this a moderate priority that should not delay other security work but should be addressed in the next routine update cycle.
Affected systems
Any application or service using libexpat versions prior to 2.8.2 is affected, particularly those that parse XML from untrusted sources or run on systems where local users can supply XML input. Common use cases include web servers, document converters, configuration parsers, and embedded systems. Organizations should inventory libexpat dependencies via package managers (apt, yum, brew, pip, npm, etc.) and linked binaries. The vulnerability does not affect systems running 2.8.2 or later.
Exploitability
Exploitation requires local or authenticated access to invoke the vulnerable parsing path with malicious XML that violates the parser's internal policy constraints. The CVSS score of 4.9 (Medium, Local/High Complexity) reflects this friction: an attacker cannot trivially exploit this remotely or without specific conditions. However, applications that accept XML uploads, process untrusted documents, or expose XML parsing to network services should treat this as urgent. The incomplete fix for the predecessor CVE-2026-50219 suggests the developers may still be refining the depth-tracking mechanism, warranting close attention to future updates.
Remediation
Upgrade libexpat to version 2.8.2 or later. This patch properly implements XML_TOK_DATA_CHARS tracking in CDATA processing, closing the use-after-free window. Most distributions (Ubuntu, Red Hat, Alpine, Debian, etc.) have published updates. Verify patch application using package version commands (e.g., `apt show libexpat1` or `rpm -qa | grep expat`) and confirm linked applications recognize the new library. If libexpat is statically linked or embedded, recompile or reinstall dependent software after upgrading the library.
Patch guidance
Check your package manager for libexpat updates (Ubuntu/Debian: libexpat1, Red Hat/CentOS: expat). Most major distributions released patches within days of the June 21 publication. Apply updates in your standard change-control window; the CVSS score and local-access requirement mean this is not a zero-day emergency, but delaying beyond 30 days increases risk if local attackers or supply-chain threats emerge. Test parsing workflows in staging to confirm no regressions before production rollout. Rebuild or reinstall applications that statically link libexpat.
Detection guidance
Monitor libexpat package versions in your Software Bill of Materials (SBOM) tools or vulnerability scanners. During incident response, look for crashes or memory corruption (segmentation faults, abort signals) in XML-parsing processes, especially following unusual XML input. Application logs may show handler errors or XML validation failures preceding the crash. If you maintain detailed build artifacts, identify which binaries include libexpat and prioritize those. Network-based detection is unlikely since the vulnerability requires local access, but intrusion-detection systems tuned to catch memory-corruption exploits remain useful as a secondary control.
Why prioritize this
This vulnerability merits prompt but not emergency attention. The CVSS 4.9 score, local-access requirement, and high-complexity exploitation path place it in the 'routine patching' tier rather than 'critical incident' tier. However, three factors elevate priority: (1) libexpat's ubiquity in XML tooling, (2) the incomplete prior fix suggesting ongoing development uncertainty, and (3) the potential for supply-chain escalation if vendors bungling XML validation are compromised. Organizations should schedule patching within 30 days; those processing untrusted XML or exposed to local users should move faster.
Risk score, explained
CVSS 4.9 reflects: (AV:L) local attack vector—attacker must be on the system; (AC:H) high complexity—specific policy violations and handler conditions required; (PR:N) no privileges needed—but local presence is a privilege of sorts; (UI:N) no user interaction required once conditions are met; (S:U) impact is unscoped to one system; (C:L/I:L/A:L) confidentiality, integrity, and availability each slightly impacted by use-after-free (leaking small data, corrupting memory, crashing the process). The score appropriately captures that this is a real but friction-laden vulnerability not suitable for mass exploitation.
Frequently asked questions
Is this vulnerability in the CISA KEV catalog?
No. As of the last update, CVE-2026-56412 is not listed in the CISA Known Exploited Vulnerabilities catalog. There is no evidence of active exploitation in the wild. This does not mean the vulnerability is harmless—only that it has not yet been observed being weaponized by threat actors. Monitor CISA and your threat intelligence feeds for updates.
What's the difference between this CVE and CVE-2026-50219?
CVE-2026-50219 was an earlier use-after-free in libexpat's handler depth tracking. The developers attempted a fix, but that fix was incomplete—it did not account for XML_TOK_DATA_CHARS tokens in the doCdataSection function. CVE-2026-56412 is the residual vulnerability. You should ensure you are not just patching to the intermediate version; upgrade directly to 2.8.2 or verify that your current version includes the full fix.
Can this be exploited remotely over a network?
Unlikely in typical deployments. The vulnerability requires local system access or the ability to control XML input to a parsing process running with insufficient isolation. However, if your application accepts XML uploads without sandboxing, or if you run a service that parses untrusted XML, treat it as a remote risk. Server-side XML parsing is the main network-exposure vector; desktop applications are lower risk unless they process email attachments or downloaded documents.
What should I do if I cannot update immediately?
Mitigate by restricting XML input to trusted sources, enforcing strict schemas, and isolating XML-parsing processes from sensitive data. Disable or limit user-supplied XML uploads. Monitor process logs for crashes or memory errors. Prioritize upgrade within 30 days if possible. If you operate a supply-chain vendor or developer tool, upgrade sooner given reputational risk.
This analysis is provided for informational purposes and reflects the state of CVE-2026-56412 as of the publication date. We do not provide exploit code or weaponization guidance. Patch versions, vendor advisories, and availability should be verified against official sources. Organizations must conduct their own risk assessment based on their specific use of libexpat and XML-processing workflows. SEC.co makes no warranty regarding the completeness or accuracy of this intelligence; consult vendor advisories, CISA alerts, and internal security reviews before making deployment decisions. This document does not constitute professional security advice tailored to your environment. Source: NVD (public-domain), retrieved 2026-07-29. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-50219MEDIUMlibexpat Use-After-Free via Handler Re-Entrancy
- CVE-2026-56131MEDIUMlibexpat Use-After-Free in XML_ResumeParser Handler Call Tracking
- CVE-2025-55644MEDIUMHeap Use-After-Free in GPAC MP4Box v2.4 DoS Vulnerability
- CVE-2025-55650MEDIUMHeap Use-After-Free in GPAC MP4Box v2.4 DoS Vulnerability
- CVE-2025-60486MEDIUMHeap Use-After-Free in GPAC MP4Box MPEG-2 Dasher – DoS Vulnerability
- CVE-2026-10232MEDIUMAssimp Use-After-Free in ASE Parser (CVSS 5.3)
- CVE-2026-10634MEDIUMZephyr TCP Stack Use-After-Free Race Condition
- CVE-2026-10635MEDIUMXtensa Memory Domain Use-After-Free in Zephyr RTOS