Skip to content

Heap Use-After-Free write in libyang XML metadata parsing (lyd_parse_data_mem / lyd_parse_mem_xml)

Moderate
michalvasko published GHSA-9f49-8x56-jmjc Mar 26, 2026

Package

No package listed

Affected versions

SO <= 5.2.5

Patched versions

SO 5.2.6

Description

Summary

A heap use-after-free write in libyang’s XML data parser can be triggered by a crafted YANG XML document with specific metadata attributes, leading to memory corruption (process crash, and potentially code execution in some deployments).

In lyd_parser_set_data_flags at src/parser_common.c:316-319, the metadata list head pointer is incorrectly updated when freeing a non-head "default" metadata entry.

Validated against: https://github.com/CESNET/libyang @ 6b5ed47 (devel)

Details and PoC

Build fuzzers:

  git clone https://github.com/google/oss-fuzz.git
  cd oss-fuzz
  python3 infra/helper.py build_fuzzers --sanitizer address libyang

Run the PoC: python3 infra/helper.py reproduce libyang lyd_parse_mem_xml poc.bin

Expected output: ASAN reports heap-use-after-free WRITE in lyd_insert_meta at tree_data.c:1313.

We have attached a zip containing:

  • Full technical details of each finding
  • Reproduction steps and proof-of-concept where applicable
  • Candidate patch(es) with regression tests

Impact

Any application using libyang to parse attacker-controlled (or semi-trusted) XML-encoded YANG instance data (NETCONF/RESTCONF, config import, etc.) is impacted. That can lead to denial of service issues. Depending on allocator behavior and application heap layout, memory corruption could potentially be leveraged further.

Bug discovery context

Anthropic is conducting research into the use of large language models for automated vulnerability discovery in open source software. As part of that work, Anthropic used Claude to scan a set of widely used open source projects for security issues. Anthropic then engaged Trail of Bits to independently triage, manually validate, and develop patches for the findings. Each issue in this report has been reviewed and confirmed by human security researchers at Trail of Bits.

Thank you for your work on libyang!

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

CVE ID

No known CVE

Weaknesses

Use After Free

The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory belongs to the code that operates on the new pointer. Learn more on MITRE.

Credits