* [oe-core][PATCH] libxml-parser-perl: patch CVE-2006-10003
@ 2026-04-15 6:51 haiqing.bai
2026-04-16 19:11 ` Paul Barker
0 siblings, 1 reply; 2+ messages in thread
From: haiqing.bai @ 2026-04-15 6:51 UTC (permalink / raw)
To: openembedded-core, haiqing.bai
From: Haiqing Bai <haiqing.bai@windriver.com>
XML::Parser versions through 2.47 for Perl has an off-by-one
heap buffer overflow in st_serial_stack. In the case
(stackptr == stacksize - 1), the stack will NOT be expanded.
Then the new value will be written at location (++stackptr),
which equals stacksize and therefore falls just outside the
allocated buffer. The bug can be observed when parsing an
XML file with very deep element nesting.
References:
https://nvd.nist.gov/vuln/detail/CVE-2006-10003
Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com>
---
.../libxml-parser-perl/CVE-2006-10003.patch | 75 +++++++++++++++++++
.../perl/libxml-parser-perl_2.47.bb | 1 +
2 files changed, 76 insertions(+)
create mode 100644 meta/recipes-devtools/perl/libxml-parser-perl/CVE-2006-10003.patch
diff --git a/meta/recipes-devtools/perl/libxml-parser-perl/CVE-2006-10003.patch b/meta/recipes-devtools/perl/libxml-parser-perl/CVE-2006-10003.patch
new file mode 100644
index 0000000000..7953ed4548
--- /dev/null
+++ b/meta/recipes-devtools/perl/libxml-parser-perl/CVE-2006-10003.patch
@@ -0,0 +1,75 @@
+From e494a2c3a76b752f6008486fbb36a59f833666c0 Mon Sep 17 00:00:00 2001
+From: Toddr Bot <toddbot@rinaldo.us>
+Date: Mon, 16 Mar 2026 22:16:11 +0000
+Subject: [PATCH] fix: off-by-one heap buffer overflow in st_serial_stack
+ growth check
+
+When st_serial_stackptr == st_serial_stacksize - 1, the old check
+(stackptr >= stacksize) would not trigger reallocation. The subsequent
+++stackptr then writes at index stacksize, one element past the
+allocated buffer.
+
+Fix by checking stackptr + 1 >= stacksize so the buffer is grown
+before the pre-increment write.
+
+Add a deep nesting test (600 levels) to exercise this code path.
+
+Fixes #39
+
+Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
+
+CVE: CVE-2006-10003
+
+Upstream-Status: Backport [https://github.com/cpan-authors/XML-Parser/commit/3eb9cc95420fa0c3f76947c4708962546bf27cfd.patch]
+
+Signed-off-by: Bai, Haiqing <Haiqing.Bai@windriver.com>
+---
+ Expat/Expat.xs | 2 +-
+ t/deep_nesting.t | 22 ++++++++++++++++++++++
+ 2 files changed, 23 insertions(+), 1 deletion(-)
+ create mode 100644 t/deep_nesting.t
+
+diff --git a/Expat/Expat.xs b/Expat/Expat.xs
+index dbad380..f04a0cf 100644
+--- a/Expat/Expat.xs
++++ b/Expat/Expat.xs
+@@ -499,7 +499,7 @@ startElement(void *userData, const char *name, const char **atts)
+ }
+ }
+
+- if (cbv->st_serial_stackptr >= cbv->st_serial_stacksize) {
++ if (cbv->st_serial_stackptr + 1 >= cbv->st_serial_stacksize) {
+ unsigned int newsize = cbv->st_serial_stacksize + 512;
+
+ Renew(cbv->st_serial_stack, newsize, unsigned int);
+diff --git a/t/deep_nesting.t b/t/deep_nesting.t
+new file mode 100644
+index 0000000..8237b5f
+--- /dev/null
++++ b/t/deep_nesting.t
+@@ -0,0 +1,22 @@
++BEGIN { print "1..1\n"; }
++
++# Test for deeply nested elements to exercise st_serial_stack reallocation.
++# This catches off-by-one errors in the stack growth check (GH #39).
++
++use XML::Parser;
++
++my $depth = 600;
++
++my $xml = '';
++for my $i (1 .. $depth) {
++ $xml .= "<e$i>";
++}
++for my $i (reverse 1 .. $depth) {
++ $xml .= "</e$i>";
++}
++
++my $p = XML::Parser->new;
++eval { $p->parse($xml) };
++
++print "not " if $@;
++print "ok 1\n";
+--
+2.49.1
+
diff --git a/meta/recipes-devtools/perl/libxml-parser-perl_2.47.bb b/meta/recipes-devtools/perl/libxml-parser-perl_2.47.bb
index b6d28c4bb3..68854c5b20 100644
--- a/meta/recipes-devtools/perl/libxml-parser-perl_2.47.bb
+++ b/meta/recipes-devtools/perl/libxml-parser-perl_2.47.bb
@@ -8,6 +8,7 @@ DEPENDS += "expat"
SRC_URI = "http://www.cpan.org/modules/by-module/XML/XML-Parser-${PV}.tar.gz \
file://0001-Makefile.PL-make-check_lib-cross-friendly.patch \
+ file://CVE-2006-10003.patch \
"
SRC_URI[sha256sum] = "ad4aae643ec784f489b956abe952432871a622d4e2b5c619e8855accbfc4d1d8"
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [oe-core][PATCH] libxml-parser-perl: patch CVE-2006-10003
2026-04-15 6:51 [oe-core][PATCH] libxml-parser-perl: patch CVE-2006-10003 haiqing.bai
@ 2026-04-16 19:11 ` Paul Barker
0 siblings, 0 replies; 2+ messages in thread
From: Paul Barker @ 2026-04-16 19:11 UTC (permalink / raw)
To: haiqing.bai, openembedded-core
[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]
On Wed, 2026-04-15 at 06:51 +0000, haiqing.bai via
lists.openembedded.org wrote:
> From: Haiqing Bai <haiqing.bai@windriver.com>
>
> XML::Parser versions through 2.47 for Perl has an off-by-one
> heap buffer overflow in st_serial_stack. In the case
> (stackptr == stacksize - 1), the stack will NOT be expanded.
> Then the new value will be written at location (++stackptr),
> which equals stacksize and therefore falls just outside the
> allocated buffer. The bug can be observed when parsing an
> XML file with very deep element nesting.
>
> References:
> https://nvd.nist.gov/vuln/detail/CVE-2006-10003
>
> Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com>
We had some questions about this on the patch review call, given the
CVE was assigned with a year of 2006! I was also a little confused
reading about a fix already being present in XML::Parser v2.45, but that
is for CVE-2006-10002 whereas this is CVE-2006-10003 (one digit higher).
So, all seems to be in order and we should take this patch.
Best regards,
--
Paul Barker
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-16 19:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 6:51 [oe-core][PATCH] libxml-parser-perl: patch CVE-2006-10003 haiqing.bai
2026-04-16 19:11 ` Paul Barker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox