libyang: Fix CVE-2026-41401 and CVE-2026-44673
PATCH 1/1 libyang: Fix CVE-2026-41401 and CVE-2026-44673
CVE-2026-41401:
Fix incorrect metadata list pointer update in lyd_parse_set_data_flags() when freeing the head metadata entry. Without this fix, crafted YANG XML documents with specific metadata ordering can trigger invalid pointer states in the metadata linked list.
CVE-2026-44673:
Fix integer overflow and OOM in the LYB binary parser. lyb_read_string() wraps len + 1 to 0 when len == UINT64_MAX, and lyb_read_term_value() truncates uint64_t to uint32_t causing undersized allocation. Both paths are reachable via malformed LYB input with crafted length fields.
---
CVE-2026-44673 patch follows the upstream fix style using LOGERR()/LY_EINVAL with a descriptive error message, since this is an input validation error rather than an out-of-memory condition. An additional len >= SIZE_MAX guard is added for 32-bit platform safety, as v2.1.148 uses uint64_t len whereas upstream uses uint32_t str_len.
I tested this patch set with libyang ptest and found no regression failures.
.../libyang/libyang/CVE-2026-41401.patch | 49 ++++++++++++++ .../libyang/libyang/CVE-2026-44673.patch | 66 +++++++++++++++++++ .../libyang/libyang_2.1.148.bb | 2 + 3 files changed, 117 insertions(+) create mode 100644 meta-oe/recipes-extended/libyang/libyang/CVE-2026-41401.patch create mode 100644 meta-oe/recipes-extended/libyang/libyang/CVE-2026-44673.patch
meta-oe/recipes-extended/libyang/libyang/CVE-2026-41401.patch new file +49 -0
@@ -0,0 +1,49 @@ +From 54c3276d871023da266d4ed3ceaee7e8d71d0b04 Mon Sep 17 00:00:00 2001 +From: Michal Vasko <[email protected]> +Date: Thu, 26 Mar 2026 08:33:44 +0100 +Subject: [PATCH] parser common BUGFIX invalid metadata removal + +Fix incorrect metadata list pointer update in lyd_parse_set_data_flags() +when freeing the head metadata entry via a separate meta pointer. The +condition must verify that meta2 is actually the head of *meta before +updating the list head pointer, and must use meta2->next (which is +saved before the free) rather than (*meta)->next. + +Without this fix, crafted YANG XML documents with specific metadata +ordering (e.g., operation + default metadata) can trigger invalid +pointer states in the metadata linked list. + +CVE: CVE-2026-41401 +Upstream-Status: Backport [https://github.com/CESNET/libyang/commit/54c3276d871023da266d4ed3ceaee7e8d71d0b04] + +Backport Changes: +- Adapted for v2.1.148 where the function is named + lyd_parse_set_data_flags (renamed to lyd_parser_set_data_flags in + newer versions). +- The fix logic is identical: change the else-if condition to also + check (meta2 == *meta) and use meta2->next instead of (*meta)->next. + +(cherry picked from commit 54c3276d871023da266d4ed3ceaee7e8d71d0b04) +Signed-off-by: Yunseong Kim <[email protected]> +--- + src/parser_common.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/parser_common.c b/src/parser_common.c +index 32152759e..f8a3b1c01 100644 +--- a/src/parser_common.c ++++ b/src/parser_common.c +@@ -394,8 +394,8 @@ lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct l + /* delete the metadata */ + if (prev_meta) { + prev_meta->next = meta2->next; +- } else if (meta != &node->meta) { +- *meta = (*meta)->next; ++ } else if ((meta != &node->meta) && (meta2 == *meta)) { ++ *meta = meta2->next; + } + lyd_free_meta_single(meta2); + +-- +2.43.0 +
meta-oe/recipes-extended/libyang/libyang/CVE-2026-44673.patch new file +66 -0
66 lines not on this page · raw message
meta-oe/recipes-extended/libyang/libyang_2.1.148.bb +2 -0
@@ -10,6 +10,8 @@ SRCREV = "fc4dbd923e044006c93df020590a1e5a8656c09e" SRC_URI = "git://github.com/CESNET/libyang.git;branch=master;protocol=https \ file://0001-test_context-skip-test-case-test_searchdirs.patch \ + file://CVE-2026-41401.patch \ + file://CVE-2026-44673.patch \ file://run-ptest \ "
Signature · 1 line
2.43.0