Skip to contentSkip to conversation

raptor2: patch CVE-2017-18926

PATCH New Gyorgy Sarvari 1 participant 5 messages Jan 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 raptor2: patch CVE-2017-18926

Details: https://nvd.nist.gov/vuln/detail/CVE-2017-18926

NVD advisory mentions the original announcement on oss-security mailing list[1]. This mentions a bug link[2] related to this vulnerability. The bug mentions the revision of the fix - pick that patch from the project's git repository.

[1]: https://www.openwall.com/lists/oss-security/2017/06/07/1
[2]: https://bugs.librdf.org/mantis/view.php?id=617

---
 .../raptor2/files/CVE-2017-18926.patch        | 44 +++++++++++++++++++
 .../recipes-support/raptor2/raptor2_2.0.15.bb |  8 ++--
 2 files changed, 48 insertions(+), 4 deletions(-)
 create mode 100644 meta-oe/recipes-support/raptor2/files/CVE-2017-18926.patch
meta-oe/recipes-support/raptor2/files/CVE-2017-18926.patch new file +44 -0
new file mode 100644
index 0000000000..f3211c899b
@@ -0,0 +1,44 @@
+From 686fc0608480f4b2d2f8c60717141ad8e3c5a849 Mon Sep 17 00:00:00 2001
+From: Dave Beckett <[email protected]>
+Date: Sun, 16 Apr 2017 23:15:12 +0100
+Subject: [PATCH] Calcualte max nspace declarations correctly for XML writer
+
+(raptor_xml_writer_start_element_common): Calculate max including for
+each attribute a potential name and value.
+
+Fixes Issues #0000617 http://bugs.librdf.org/mantis/view.php?id=617
+and #0000618 http://bugs.librdf.org/mantis/view.php?id=618
+
+CVE: CVE-2017-18926
+Upstream-Status: Backport [https://github.com/dajobe/raptor/commit/590681e546cd9aa18d57dc2ea1858cb734a3863f]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/raptor_xml_writer.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/raptor_xml_writer.c b/src/raptor_xml_writer.c
+index 693b946..0d3a36a 100644
+--- a/src/raptor_xml_writer.c
++++ b/src/raptor_xml_writer.c
+@@ -181,9 +181,10 @@ raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,
+   size_t nspace_declarations_count = 0;  
+   unsigned int i;
+ 
+-  /* max is 1 per element and 1 for each attribute + size of declared */
+   if(nstack) {
+-    int nspace_max_count = element->attribute_count+1;
++    int nspace_max_count = element->attribute_count * 2; /* attr and value */
++    if(element->name->nspace)
++      nspace_max_count++;
+     if(element->declared_nspaces)
+       nspace_max_count += raptor_sequence_size(element->declared_nspaces);
+     if(element->xml_language)
+@@ -237,7 +238,7 @@ raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,
+         }
+       }
+ 
+-      /* Add the attribute + value */
++      /* Add the attribute's value */
+       nspace_declarations[nspace_declarations_count].declaration=
+         raptor_qname_format_as_xml(element->attributes[i],
+                                    &nspace_declarations[nspace_declarations_count].length);
meta-oe/recipes-support/raptor2/raptor2_2.0.15.bb +4 -4
index 577c6ee00a..193cf13b21 100644
@@ -9,10 +9,10 @@ LIC_FILES_CHKSUM = " \
 
 DEPENDS = "libxml2 libxslt curl yajl"
 
-SRC_URI = " \
-    http://download.librdf.org/source/${BPN}-${PV}.tar.gz \
-    file://0001-configure.ac-do-additional-checks-on-libxml2-also-wh.patch \
-"
+SRC_URI = "http://download.librdf.org/source/${BPN}-${PV}.tar.gz \
+           file://0001-configure.ac-do-additional-checks-on-libxml2-also-wh.patch \
+           file://CVE-2017-18926.patch \
+           "
 SRC_URI[md5sum] = "a39f6c07ddb20d7dd2ff1f95fa21e2cd"
 SRC_URI[sha256sum] = "ada7f0ba54787b33485d090d3d2680533520cd4426d2f7fb4782dd4a6a1480ed"
 
#1 lore raw

PATCH 2/5 raptor2: patch CVE-2020-25713

Details: https://nvd.nist.gov/vuln/detail/CVE-2020-25713

Pick the git cmmit that is mentioned as a solution in the related bug[1] from the NVD advisory.

[1]: https://bugs.librdf.org/mantis/view.php?id=650

---
 .../raptor2/files/CVE-2020-25713.patch        | 33 +++++++++++++++++++
 .../recipes-support/raptor2/raptor2_2.0.15.bb |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 meta-oe/recipes-support/raptor2/files/CVE-2020-25713.patch
meta-oe/recipes-support/raptor2/files/CVE-2020-25713.patch new file +33 -0
new file mode 100644
index 0000000000..a2694135e2
@@ -0,0 +1,33 @@
+From 00fa124e379fab85217ac62bdd0feddfd9510ae5 Mon Sep 17 00:00:00 2001
+From: Dave Beckett <[email protected]>
+Date: Sat, 18 Sep 2021 17:40:00 -0700
+Subject: [PATCH] XML Writer : compare namespace declarations correctly
+
+Apply patch from
+0001-CVE-2020-25713-raptor2-malformed-input-file-can-lead.patch.1
+that fixes Issue#0000650 https://bugs.librdf.org/mantis/view.php?id=650
+which overwrote heap during XML writing in parse type literal
+content.  This was detected with clang asan.
+
+Thanks to Michael Stahl / mst2 for the fix.
+
+CVE: CVE-2020-25713
+Upstream-Status: Backport [https://github.com/dajobe/raptor/commit/4f5dbbffcc1c6cf0398bd03450453289a0979dea]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/raptor_xml_writer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/raptor_xml_writer.c b/src/raptor_xml_writer.c
+index 0d3a36a..17b1c44 100644
+--- a/src/raptor_xml_writer.c
++++ b/src/raptor_xml_writer.c
+@@ -221,7 +221,7 @@ raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,
+           
+           /* check it wasn't an earlier declaration too */
+           for(j = 0; j < nspace_declarations_count; j++)
+-            if(nspace_declarations[j].nspace == element->attributes[j]->nspace) {
++            if(nspace_declarations[j].nspace == element->attributes[i]->nspace) {
+               declare_me = 0;
+               break;
+             }
meta-oe/recipes-support/raptor2/raptor2_2.0.15.bb +1 -0
index 193cf13b21..7ee097b6ce 100644
@@ -12,6 +12,7 @@ DEPENDS = "libxml2 libxslt curl yajl"
 SRC_URI = "http://download.librdf.org/source/${BPN}-${PV}.tar.gz \
            file://0001-configure.ac-do-additional-checks-on-libxml2-also-wh.patch \
            file://CVE-2017-18926.patch \
+           file://CVE-2020-25713.patch \
            "
 SRC_URI[md5sum] = "a39f6c07ddb20d7dd2ff1f95fa21e2cd"
 SRC_URI[sha256sum] = "ada7f0ba54787b33485d090d3d2680533520cd4426d2f7fb4782dd4a6a1480ed"
#2 lore raw

PATCH 3/5 raptor2: patch CVE-2024-57822

In reply to Gyorgy Sarvari

Details: https://nvd.nist.gov/vuln/detail/CVE-2024-57822

Pick the patch mentioned in the related github issue[1]. The issue contains fixes for 2 issues, but only the first patch is related to this vulnerability.

[1]: https://github.com/dajobe/raptor/issues/70

---
 .../raptor2/files/CVE-2024-57822.patch        | 42 +++++++++++++++++++
 .../recipes-support/raptor2/raptor2_2.0.15.bb |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta-oe/recipes-support/raptor2/files/CVE-2024-57822.patch
meta-oe/recipes-support/raptor2/files/CVE-2024-57822.patch new file +42 -0
new file mode 100644
index 0000000000..ee31474cf9
@@ -0,0 +1,42 @@
+From 9dc72f9534df6e2b94ce22ceb3d90224c1153184 Mon Sep 17 00:00:00 2001
+From: Dave Beckett <[email protected]>
+Date: Thu, 6 Feb 2025 21:12:37 -0800
+Subject: [PATCH] Fix Github issue 70 A) Integer Underflow in
+ raptor_uri_normalize_path()
+
+(raptor_uri_normalize_path): Return empty buffer if path gets to 0
+length
+
+CVE: CVE-2024-57822
+Upstream-Status: Backport [https://github.com/dajobe/raptor/commit/da7a79976bd0314c23cce55d22495e7d29301c44]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/raptor_rfc2396.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/raptor_rfc2396.c b/src/raptor_rfc2396.c
+index 89183d9..2f0195f 100644
+--- a/src/raptor_rfc2396.c
++++ b/src/raptor_rfc2396.c
+@@ -351,6 +351,10 @@ raptor_uri_normalize_path(unsigned char* path_buffer, size_t path_len)
+           *dest++ = *s++;
+         *dest = '\0';
+         path_len -= len;
++        if(path_len <= 0) {
++          *path_buffer = '\0';
++          return 0;
++        }
+ 
+         if(p && p < prev) {
+           /* We know the previous prev path component and we didn't do
+@@ -390,6 +394,10 @@ raptor_uri_normalize_path(unsigned char* path_buffer, size_t path_len)
+     /* Remove <component>/.. at the end of the path */
+     *prev = '\0';
+     path_len -= (s-prev);
++    if(path_len <= 0) {
++      *path_buffer = '\0';
++      return 0;
++    }
+   }
+ 
+ 
meta-oe/recipes-support/raptor2/raptor2_2.0.15.bb +1 -0
index 7ee097b6ce..d110b8475f 100644
@@ -13,6 +13,7 @@ SRC_URI = "http://download.librdf.org/source/${BPN}-${PV}.tar.gz \
            file://0001-configure.ac-do-additional-checks-on-libxml2-also-wh.patch \
            file://CVE-2017-18926.patch \
            file://CVE-2020-25713.patch \
+           file://CVE-2024-57822.patch \
            "
 SRC_URI[md5sum] = "a39f6c07ddb20d7dd2ff1f95fa21e2cd"
 SRC_URI[sha256sum] = "ada7f0ba54787b33485d090d3d2680533520cd4426d2f7fb4782dd4a6a1480ed"
#3 lore raw

PATCH 4/5 raptor2: patch CVE-2024-57823

In reply to Gyorgy Sarvari

Details: https://nvd.nist.gov/vuln/detail/CVE-2024-57822

Pick the patch mentioned in the related github issue[1]. The issue contains fixes for 2 issues, but only the second patch is related to this vulnerability.

[1]: https://github.com/dajobe/raptor/issues/70

---
 .../raptor2/files/CVE-2024-57823.patch        | 29 +++++++++++++++++++
 .../recipes-support/raptor2/raptor2_2.0.15.bb |  1 +
 2 files changed, 30 insertions(+)
 create mode 100644 meta-oe/recipes-support/raptor2/files/CVE-2024-57823.patch
meta-oe/recipes-support/raptor2/files/CVE-2024-57823.patch new file +29 -0
new file mode 100644
index 0000000000..8e5a03379c
@@ -0,0 +1,29 @@
+From 8071a8c4f379831d2c975e04a3197d13ec4d44a3 Mon Sep 17 00:00:00 2001
+From: Dave Beckett <[email protected]>
+Date: Fri, 7 Feb 2025 11:38:34 -0800
+Subject: [PATCH] Fix Github issue 70 B) Heap read buffer overflow in ntriples
+ bnode
+
+(raptor_ntriples_parse_term_internal): Only allow looking at the last
+character of a bnode ID only if bnode length >0
+
+CVE: CVE-2024-57823
+Upstream-Status: Backport [https://github.com/dajobe/raptor/commit/ece2c79df43091686a538b8231cf387d84bfa60e]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/raptor_ntriples.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/raptor_ntriples.c b/src/raptor_ntriples.c
+index 60fd3aa..c44f8c4 100644
+--- a/src/raptor_ntriples.c
++++ b/src/raptor_ntriples.c
+@@ -208,7 +208,7 @@ raptor_ntriples_parse_term_internal(raptor_world* world,
+             locator->column--;
+             locator->byte--;
+           }
+-          if(term_class == RAPTOR_TERM_CLASS_BNODEID && dest[-1] == '.') {
++          if(term_class == RAPTOR_TERM_CLASS_BNODEID && position > 0 && dest[-1] == '.') {
+             /* If bnode id ended on '.' move back one */
+             dest--;
+ 
meta-oe/recipes-support/raptor2/raptor2_2.0.15.bb +1 -0
index d110b8475f..422326d2b6 100644
@@ -14,6 +14,7 @@ SRC_URI = "http://download.librdf.org/source/${BPN}-${PV}.tar.gz \
            file://CVE-2017-18926.patch \
            file://CVE-2020-25713.patch \
            file://CVE-2024-57822.patch \
+           file://CVE-2024-57823.patch \
            "
 SRC_URI[md5sum] = "a39f6c07ddb20d7dd2ff1f95fa21e2cd"
 SRC_URI[sha256sum] = "ada7f0ba54787b33485d090d3d2680533520cd4426d2f7fb4782dd4a6a1480ed"
#4 lore raw

PATCH 5/5 squid: upgrade 4.15 -> 4.17

In reply to Gyorgy Sarvari

These are bugfix releases.

Changelogs:
4.17:
- WCCP: Validate packets better

4.16:
- Regression Fix: --with-valgrind-debug build broken since 4.15
- Bug 5129 pt1: remove Lock use from HttpRequestMethod
- Bug 5128: Translation: Fix '% i' typo in es/ERR_FORWARDING_DENIED
- Bug 4528: ICAP transactions quit on async DNS lookups

---
 .../recipes-daemons/squid/{squid_4.15.bb => squid_4.17.bb}      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 rename meta-networking/recipes-daemons/squid/{squid_4.15.bb => squid_4.17.bb} (98%)
meta-networking/recipes-daemons/squid/squid_4.17.bb renamed from meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -1
similarity index 98%
rename from meta-networking/recipes-daemons/squid/squid_4.15.bb
rename to meta-networking/recipes-daemons/squid/squid_4.17.bb
index 575ad76ad3..b0b13f72d5 100644
@@ -43,7 +43,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2
 
 SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"
 
-SRC_URI[sha256sum] = "71635811e766ce8b155225a9e3c7757cfc7ff93df26b28d82e5e6fc021b9a605"
+SRC_URI[sha256sum] = "acf5c3c1707695147226742d1d6cef8993bb32536a622743b51514c3cb501da5"
 
 LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
                     file://errors/COPYRIGHT;md5=0e03cd976052c45697ad5d96e7dff8dc \