python3-lxml: fix CVE-2026-41066
PATCH 1/1 python3-lxml: fix CVE-2026-41066
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/lxml/lxml/commit/ab431ea0b9a7357d968f1d1c5c614649e9aaf358
[2] https://github.com/lxml/lxml/security/advisories/GHSA-vfmq-68hx-4jfw
--- .../python/python3-lxml/CVE-2026-41066.patch | 87 +++++++++++++++++++ .../python/python3-lxml_6.0.2.bb | 4 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/python/python3-lxml/CVE-2026-41066.patch
meta/recipes-devtools/python/python3-lxml/CVE-2026-41066.patch new file +87 -0
@@ -0,0 +1,87 @@ +From 2851ff7d51681201c950554d52697429413835b5 Mon Sep 17 00:00:00 2001 +From: Stefan Behnel <[email protected]> +Date: Fri, 10 Apr 2026 10:13:03 +0200 +Subject: [PATCH] LP#2146291: Set "resolve_entities='internal'" as default for + all parser subclasses. + +CVE: CVE-2026-41066 +Upstream-Status: Backport [https://github.com/lxml/lxml/commit/ab431ea0b9a7357d968f1d1c5c614649e9aaf358] + +(cherry picked from commit ab431ea0b9a7357d968f1d1c5c614649e9aaf358) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/lxml/iterparse.pxi | 10 ++++++---- + src/lxml/parser.pxi | 6 +++--- + 2 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/src/lxml/iterparse.pxi b/src/lxml/iterparse.pxi +index 42b75249..9b6ceb00 100644 +--- a/src/lxml/iterparse.pxi ++++ b/src/lxml/iterparse.pxi +@@ -6,7 +6,8 @@ cdef class iterparse: + """iterparse(self, source, events=("end",), tag=None, \ + attribute_defaults=False, dtd_validation=False, \ + load_dtd=False, no_network=True, remove_blank_text=False, \ +- remove_comments=False, remove_pis=False, encoding=None, \ ++ compact=True, resolve_entities='internal', remove_comments=False, \ ++ remove_pis=False, strip_cdata=True, encoding=None, \ + html=False, recover=None, huge_tree=False, schema=None) + + Incremental parser. +@@ -42,10 +43,11 @@ cdef class iterparse: + - remove_blank_text: discard blank text nodes + - remove_comments: discard comments + - remove_pis: discard processing instructions +- - strip_cdata: replace CDATA sections by normal text content (default: ++ - strip_cdata: replace CDATA sections by normal text content (default: + True for XML, ignored otherwise) + - compact: safe memory for short text content (default: True) +- - resolve_entities: replace entities by their text value (default: True) ++ - resolve_entities: replace entities by their text value ++ (default: 'internal' only) + - huge_tree: disable security restrictions and support very deep trees + and very long text content (only affects libxml2 2.7+) + - html: parse input as HTML (default: XML) +@@ -68,7 +70,7 @@ cdef class iterparse: + def __init__(self, source, events=("end",), *, tag=None, + attribute_defaults=False, dtd_validation=False, + load_dtd=False, no_network=True, remove_blank_text=False, +- compact=True, resolve_entities=True, remove_comments=False, ++ compact=True, resolve_entities='internal', remove_comments=False, + remove_pis=False, strip_cdata=True, encoding=None, + html=False, recover=None, huge_tree=False, collect_ids=True, + XMLSchema schema=None): +diff --git a/src/lxml/parser.pxi b/src/lxml/parser.pxi +index 3106e610..ba9875c0 100644 +--- a/src/lxml/parser.pxi ++++ b/src/lxml/parser.pxi +@@ -1584,7 +1584,7 @@ cdef class XMLParser(_FeedParser): + """XMLParser(self, encoding=None, attribute_defaults=False, dtd_validation=False, \ + load_dtd=False, no_network=True, decompress=False, ns_clean=False, \ + recover=False, schema: XMLSchema =None, huge_tree=False, \ +- remove_blank_text=False, resolve_entities=True, \ ++ remove_blank_text=False, resolve_entities='internal', \ + remove_comments=False, remove_pis=False, strip_cdata=True, \ + collect_ids=True, target=None, compact=True) + +@@ -1717,7 +1717,7 @@ cdef class ETCompatXMLParser(XMLParser): + """ETCompatXMLParser(self, encoding=None, attribute_defaults=False, \ + dtd_validation=False, load_dtd=False, no_network=True, decompress=False, \ + ns_clean=False, recover=False, schema=None, \ +- huge_tree=False, remove_blank_text=False, resolve_entities=True, \ ++ huge_tree=False, remove_blank_text=False, resolve_entities='internal', \ + remove_comments=True, remove_pis=True, strip_cdata=True, \ + target=None, compact=True) + +@@ -1731,7 +1731,7 @@ cdef class ETCompatXMLParser(XMLParser): + def __init__(self, *, encoding=None, attribute_defaults=False, + dtd_validation=False, load_dtd=False, no_network=True, decompress=False, + ns_clean=False, recover=False, schema=None, +- huge_tree=False, remove_blank_text=False, resolve_entities=True, ++ huge_tree=False, remove_blank_text=False, resolve_entities='internal', + remove_comments=True, remove_pis=True, strip_cdata=True, + target=None, compact=True): + XMLParser.__init__(self, +-- +2.53.0 +
meta/recipes-devtools/python/python3-lxml_6.0.2.bb +3 -1
@@ -20,7 +20,9 @@ DEPENDS += "libxml2 libxslt" SRC_URI[sha256sum] = "cd79f3367bd74b317dda655dc8fcfa304d9eb6e4fb06b7168c5cf27f96e0cd62" -SRC_URI += "${PYPI_SRC_URI}" +SRC_URI += "${PYPI_SRC_URI} \ + file://CVE-2026-41066.patch" + inherit pkgconfig pypi setuptools3 # {standard input}: Assembler messages:
Signature · 1 line
2.35.6
Quoted 27 lines · On Wed Aug 19, 2026 at 12:36 PM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/lxml/lxml/commit/ab431ea0b9a7357d968f1d1c5c614649e9aaf358
[2] https://github.com/lxml/lxml/security/advisories/GHSA-vfmq-68hx-4jfwSigned-off-by Darsh Kelaiya <[email protected]>--- .../python/python3-lxml/CVE-2026-41066.patch | 87 +++++++++++++++++++ .../python/python3-lxml_6.0.2.bb | 4 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/python/python3-lxml/CVE-2026-41066.patchmeta/recipes-devtools/python/python3-lxml/CVE-2026-41066.patch new file +6
-0@@ -0,0 +1,87 @@ +From 2851ff7d51681201c950554d52697429413835b5 Mon Sep 17 00:00:00 2001 +From: Stefan Behnel <[email protected]> +Date: Fri, 10 Apr 2026 10:13:03 +0200 +Subject: [PATCH] LP#2146291: Set "resolve_entities='internal'" as default for + all parser subclasses. +
meta/recipes-devtools/python/python3-lxml/CVE-2026-41066.patch line 15
Quoted 10 lines
meta/recipes-devtools/python/python3-lxml/CVE-2026-41066.patch new file +9
-0+CVE: CVE-2026-41066 +Upstream-Status: Backport [https://github.com/lxml/lxml/commit/ab431ea0b9a7357d968f1d1c5c614649e9aaf358] + +(cherry picked from commit ab431ea0b9a7357d968f1d1c5c614649e9aaf358) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/lxml/iterparse.pxi | 10 ++++++---- + src/lxml/parser.pxi | 6 +++--- + 2 files changed, 9 insertions(+), 7 deletions(-)
Hello,
The equivalent scarthgap patch does regenerate etree.c but this one does not. I've look at build log a bit, and I can't see it regenerated in wrynose.
Can you check?
Also, if we go through with regenerating etree.c with cython. I'd appreciate:
* some info about how it was done,
* a little effort to decrease patch size (the scarthgap one had a lot of meaningless line number changes): I'd accept a patch format change from upstream if that results in a small etree.c patch.
Regards,
Signature · 2 lines
Yoann Congal Smile ECS
Hello Yoann,
Thanks for the review.
The v2 patches now include the regenerated src/lxml/etree.c for both branches. The regeneration was performed outside BitBake, since the recipes build the pregenerated C source and do not depend on Cython.
For Scarthgap, I used Cython 3.0.9 with Python 3.12:
python3.12 setup.py build_ext -i --with-cython --warnings -j1
For Wrynose, I used Cython 3.1.4, matching the version recorded in the shipped etree.c:
python setup.py build_ext -i --with-cython
I kept the iterparse.pxi changes line-count stable and removed unrelated generator metadata changes to avoid Cython source-location churn. As a result, the etree.c diffs are limited to 40 changed lines for Scarthgap and 60 changed lines for Wrynose.
The Scarthgap v2 also includes the upstream ETCompatXMLParser documented-default change. Please find the v2 patches for Wrynose [1] and Scarthgap [2]:
[1] https://lists.openembedded.org/g/openembedded-core/topic/wrynose_patch_v2/121067576
[2] https://lists.openembedded.org/g/openembedded-core/topic/scarthgap_patch_v2/121067675
Regards,
Darsh Kelaiya