summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2024-03-13 23:39:24 +0100
committerSteve Sakoman <steve@sakoman.com>2024-03-25 04:11:25 -1000
commitfe9d4cb61321da23b6a9046545bde03a625e6ce0 (patch)
tree5cf35c45c171a3f69e8c67fd4370152ba7773431 /meta
parent6d1a878bbf24c66f7186b270f823fcdf82e35383 (diff)
downloadpoky-fe9d4cb61321da23b6a9046545bde03a625e6ce0.tar.gz
expat: patch CVE-2024-28757
Picked patch from https://github.com/libexpat/libexpat/pull/842 which is referenced in the NVD CVE report. (From OE-Core rev: c02175e97348836429cecbfad15d89be040bbd92) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rwxr-xr-xmeta/recipes-core/expat/expat/CVE-2024-28757.patch58
-rw-r--r--meta/recipes-core/expat/expat_2.5.0.bb1
2 files changed, 59 insertions, 0 deletions
diff --git a/meta/recipes-core/expat/expat/CVE-2024-28757.patch b/meta/recipes-core/expat/expat/CVE-2024-28757.patch
new file mode 100755
index 0000000000..768dab0c84
--- /dev/null
+++ b/meta/recipes-core/expat/expat/CVE-2024-28757.patch
@@ -0,0 +1,58 @@
1From 1d50b80cf31de87750103656f6eb693746854aa8 Mon Sep 17 00:00:00 2001
2From: Sebastian Pipping <sebastian@pipping.org>
3Date: Mon, 4 Mar 2024 23:49:06 +0100
4Subject: [PATCH] lib/xmlparse.c: Detect billion laughs attack with isolated
5 external parser
6
7When parsing DTD content with code like ..
8
9 XML_Parser parser = XML_ParserCreate(NULL);
10 XML_Parser ext_parser = XML_ExternalEntityParserCreate(parser, NULL, NULL);
11 enum XML_Status status = XML_Parse(ext_parser, doc, (int)strlen(doc), XML_TRUE);
12
13.. there are 0 bytes accounted as direct input and all input from `doc` accounted
14as indirect input. Now function accountingGetCurrentAmplification cannot calculate
15the current amplification ratio as "(direct + indirect) / direct", and it did refuse
16to divide by 0 as one would expect, but it returned 1.0 for this case to indicate
17no amplification over direct input. As a result, billion laughs attacks from
18DTD-only input were not detected with this isolated way of using an external parser.
19
20The new approach is to assume direct input of length not 0 but 22 -- derived from
21ghost input "<!ENTITY a SYSTEM 'b'>", the shortest possible way to include an external
22DTD --, and do the usual "(direct + indirect) / direct" math with "direct := 22".
23
24GitHub issue #839 has more details on this issue and its origin in ClusterFuzz
25finding 66812.
26
27CVE: CVE-2024-28757
28Upstream-Status: Backport [https://github.com/libexpat/libexpat/commit/1d50b80cf31de87750103656f6eb693746854aa8]
29
30Signed-off-by: Peter Marko <peter.marko@siemens.com>
31---
32 lib/xmlparse.c | 6 +++++-
33 1 file changed, 5 insertions(+), 1 deletion(-)
34
35diff --git a/lib/xmlparse.c b/lib/xmlparse.c
36index b884d82b5..d44baa68d 100644
37--- a/lib/xmlparse.c
38+++ b/lib/xmlparse.c
39@@ -7655,6 +7655,8 @@ copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) {
40
41 static float
42 accountingGetCurrentAmplification(XML_Parser rootParser) {
43+ // 1.........1.........12 => 22
44+ const size_t lenOfShortestInclude = sizeof("<!ENTITY a SYSTEM 'b'>") - 1;
45 const XmlBigCount countBytesOutput
46 = rootParser->m_accounting.countBytesDirect
47 + rootParser->m_accounting.countBytesIndirect;
48@@ -7662,7 +7664,9 @@ accountingGetCurrentAmplification(XML_Parser rootParser) {
49 = rootParser->m_accounting.countBytesDirect
50 ? (countBytesOutput
51 / (float)(rootParser->m_accounting.countBytesDirect))
52- : 1.0f;
53+ : ((lenOfShortestInclude
54+ + rootParser->m_accounting.countBytesIndirect)
55+ / (float)lenOfShortestInclude);
56 assert(! rootParser->m_parentParser);
57 return amplificationFactor;
58 }
diff --git a/meta/recipes-core/expat/expat_2.5.0.bb b/meta/recipes-core/expat/expat_2.5.0.bb
index 7080f934d1..eb7ce1436e 100644
--- a/meta/recipes-core/expat/expat_2.5.0.bb
+++ b/meta/recipes-core/expat/expat_2.5.0.bb
@@ -10,6 +10,7 @@ VERSION_TAG = "${@d.getVar('PV').replace('.', '_')}"
10 10
11SRC_URI = "https://github.com/libexpat/libexpat/releases/download/R_${VERSION_TAG}/expat-${PV}.tar.bz2 \ 11SRC_URI = "https://github.com/libexpat/libexpat/releases/download/R_${VERSION_TAG}/expat-${PV}.tar.bz2 \
12 file://run-ptest \ 12 file://run-ptest \
13 file://CVE-2024-28757.patch \
13 " 14 "
14 15
15UPSTREAM_CHECK_URI = "https://github.com/libexpat/libexpat/releases/" 16UPSTREAM_CHECK_URI = "https://github.com/libexpat/libexpat/releases/"