squid: patch CVE-2021-46784
PATCH 1/6 squid: patch CVE-2021-46784
Details: https://nvd.nist.gov/vuln/detail/CVE-2021-46784
Pick the backported patch from v4 branch, that referenced the same PR[1] that the patch[2] from the nvd report refers to.
[1]: https://github.com/squid-cache/squid/pull/1022
[2]: https://github.com/squid-cache/squid/commit/5e2ea2b13bd98f53e29964ca26bb0d602a8a12b9
--- .../squid/files/CVE-2021-46784.patch | 133 ++++++++++++++++++ .../recipes-daemons/squid/squid_4.15.bb | 1 + 2 files changed, 134 insertions(+) create mode 100644 meta-networking/recipes-daemons/squid/files/CVE-2021-46784.patch
meta-networking/recipes-daemons/squid/files/CVE-2021-46784.patch new file +133 -0
@@ -0,0 +1,133 @@ +From 0cfe0d3efe438658ac3b1eeac44bdc07836a1649 Mon Sep 17 00:00:00 2001 +From: Joshua Rogers <[email protected]> +Date: Mon, 18 Apr 2022 13:42:36 +0000 +Subject: [PATCH] Improve handling of Gopher responses (#1022) + +CVE: CVE-2021-46784 +Upstream-Status: Backport [https://github.com/squid-cache/squid/commit/780c4ea1b4c9d2fb41f6962aa6ed73ae57f74b2b] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/gopher.cc | 45 ++++++++++++++++++++------------------------- + 1 file changed, 20 insertions(+), 25 deletions(-) + +diff --git a/src/gopher.cc b/src/gopher.cc +index 169b0e1..6187da1 100644 +--- a/src/gopher.cc ++++ b/src/gopher.cc +@@ -371,7 +371,6 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + char *lpos = NULL; + char *tline = NULL; + LOCAL_ARRAY(char, line, TEMP_BUF_SIZE); +- LOCAL_ARRAY(char, tmpbuf, TEMP_BUF_SIZE); + char *name = NULL; + char *selector = NULL; + char *host = NULL; +@@ -381,7 +380,6 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + char gtype; + StoreEntry *entry = NULL; + +- memset(tmpbuf, '\0', TEMP_BUF_SIZE); + memset(line, '\0', TEMP_BUF_SIZE); + + entry = gopherState->entry; +@@ -416,7 +414,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + return; + } + +- String outbuf; ++ SBuf outbuf; + + if (!gopherState->HTML_header_added) { + if (gopherState->conversion == GopherStateData::HTML_CSO_RESULT) +@@ -583,34 +581,34 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + break; + } + +- memset(tmpbuf, '\0', TEMP_BUF_SIZE); +- + if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) { + if (strlen(escaped_selector) != 0) +- snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s@%s%s%s/\">%s</A>\n", +- icon_url, escaped_selector, rfc1738_escape_part(host), +- *port ? ":" : "", port, html_quote(name)); ++ outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s@%s%s%s/\">%s</A>\n", ++ icon_url, escaped_selector, rfc1738_escape_part(host), ++ *port ? ":" : "", port, html_quote(name)); + else +- snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s%s%s/\">%s</A>\n", +- icon_url, rfc1738_escape_part(host), *port ? ":" : "", +- port, html_quote(name)); ++ outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s%s%s/\">%s</A>\n", ++ icon_url, rfc1738_escape_part(host), *port ? ":" : "", ++ port, html_quote(name)); + + } else if (gtype == GOPHER_INFO) { +- snprintf(tmpbuf, TEMP_BUF_SIZE, "\t%s\n", html_quote(name)); ++ outbuf.appendf("\t%s\n", html_quote(name)); + } else { + if (strncmp(selector, "GET /", 5) == 0) { + /* WWW link */ +- snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"http://%s/%s\">%s</A>\n", +- icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name)); ++ outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"http://%s/%s\">%s</A>\n", ++ icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name)); ++ } else if (gtype == GOPHER_WWW) { ++ outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n", ++ icon_url, rfc1738_escape_unescaped(selector), html_quote(name)); + } else { + /* Standard link */ +- snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n", +- icon_url, host, gtype, escaped_selector, html_quote(name)); ++ outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n", ++ icon_url, host, gtype, escaped_selector, html_quote(name)); + } + } + + safe_free(escaped_selector); +- outbuf.append(tmpbuf); + } else { + memset(line, '\0', TEMP_BUF_SIZE); + continue; +@@ -643,13 +641,12 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + break; + + if (gopherState->cso_recno != recno) { +- snprintf(tmpbuf, TEMP_BUF_SIZE, "</PRE><HR noshade size=\"1px\"><H2>Record# %d<br><i>%s</i></H2>\n<PRE>", recno, html_quote(result)); ++ outbuf.appendf("</PRE><HR noshade size=\"1px\"><H2>Record# %d<br><i>%s</i></H2>\n<PRE>", recno, html_quote(result)); + gopherState->cso_recno = recno; + } else { +- snprintf(tmpbuf, TEMP_BUF_SIZE, "%s\n", html_quote(result)); ++ outbuf.appendf("%s\n", html_quote(result)); + } + +- outbuf.append(tmpbuf); + break; + } else { + int code; +@@ -677,8 +674,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + + case 502: { /* Too Many Matches */ + /* Print the message the server returns */ +- snprintf(tmpbuf, TEMP_BUF_SIZE, "</PRE><HR noshade size=\"1px\"><H2>%s</H2>\n<PRE>", html_quote(result)); +- outbuf.append(tmpbuf); ++ outbuf.appendf("</PRE><HR noshade size=\"1px\"><H2>%s</H2>\n<PRE>", html_quote(result)); + break; + } + +@@ -694,13 +690,12 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) + + } /* while loop */ + +- if (outbuf.size() > 0) { +- entry->append(outbuf.rawBuf(), outbuf.size()); ++ if (outbuf.length() > 0) { ++ entry->append(outbuf.rawContent(), outbuf.length()); + /* now let start sending stuff to client */ + entry->flush(); + } + +- outbuf.clean(); + return; + } +
meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -0
@@ -33,6 +33,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2 file://CVE-2023-49286.patch \ file://CVE-2023-50269.patch \ file://CVE-2023-5824.patch \ + file://CVE-2021-46784.patch \ " SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"
PATCH 2/6 squid: patch CVE-2022-41317
Details: https://nvd.nist.gov/vuln/detail/CVE-2022-41317
Pick the v4 patch referenced in the nvd report.
--- .../squid/files/CVE-2022-41317.patch | 26 +++++++++++++++++++ .../recipes-daemons/squid/squid_4.15.bb | 1 + 2 files changed, 27 insertions(+) create mode 100644 meta-networking/recipes-daemons/squid/files/CVE-2022-41317.patch
meta-networking/recipes-daemons/squid/files/CVE-2022-41317.patch new file +26 -0
@@ -0,0 +1,26 @@ +From 745d5d5a6d10731656adfc2b1b4d16ef208dd073 Mon Sep 17 00:00:00 2001 +From: Amos Jeffries <[email protected]> +Date: Wed, 17 Aug 2022 23:32:43 +0000 +Subject: [PATCH] Fix typo in manager ACL (#1113) + +CVE: CVE-2022-41317 +Upstream-Status: Backport [https://github.com/squid-cache/squid/commit/2c5d2de9bdcd25d1127987f8f76c986ab5bfb6da] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/cf.data.pre | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/cf.data.pre b/src/cf.data.pre +index 4aef432..f15d56b 100644 +--- a/src/cf.data.pre ++++ b/src/cf.data.pre +@@ -1001,7 +1001,7 @@ DEFAULT: ssl::certUntrusted ssl_error X509_V_ERR_INVALID_CA X509_V_ERR_SELF_SIGN + DEFAULT: ssl::certSelfSigned ssl_error X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT + ENDIF + DEFAULT: all src all +-DEFAULT: manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/ ++DEFAULT: manager url_regex -i ^cache_object:// +i ^[^:]+://[^/]+/squid-internal-mgr/ + DEFAULT: localhost src 127.0.0.1/32 ::1 + DEFAULT: to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1/128 ::/128 + DEFAULT_DOC: ACLs all, manager, localhost, and to_localhost are predefined.
meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -0
@@ -34,6 +34,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2 file://CVE-2023-50269.patch \ file://CVE-2023-5824.patch \ file://CVE-2021-46784.patch \ + file://CVE-2022-41317.patch \ " SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"
PATCH 3/6 squid: patch CVE-2022-41318
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2022-41318
Pick the v4 patch referenced in the nvd report.
--- .../squid/files/CVE-2022-41318.patch | 45 +++++++++++++++++++ .../recipes-daemons/squid/squid_4.15.bb | 1 + 2 files changed, 46 insertions(+) create mode 100644 meta-networking/recipes-daemons/squid/files/CVE-2022-41318.patch
meta-networking/recipes-daemons/squid/files/CVE-2022-41318.patch new file +45 -0
@@ -0,0 +1,45 @@ +From 36a55f44abe5ee0387d83663397e7fe111e21fa4 Mon Sep 17 00:00:00 2001 +From: Amos Jeffries <[email protected]> +Date: Tue, 9 Aug 2022 23:34:54 +0000 +Subject: [PATCH] Bug 3193 pt2: NTLM decoder truncating strings (#1114) + +The initial bug fix overlooked large 'offset' causing integer +wrap to extract a too-short length string. + +Improve debugs and checks sequence to clarify cases and ensure +that all are handled correctly. + +CVE: CVE-2022-41318 +Upstream-Status: Backport [https://github.com/squid-cache/squid/commit/4031c6c2b004190fdffbc19dab7cd0305a2025b7] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + lib/ntlmauth/ntlmauth.cc | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/lib/ntlmauth/ntlmauth.cc b/lib/ntlmauth/ntlmauth.cc +index 5d96372..f00fd51 100644 +--- a/lib/ntlmauth/ntlmauth.cc ++++ b/lib/ntlmauth/ntlmauth.cc +@@ -107,10 +107,19 @@ ntlm_fetch_string(const ntlmhdr *packet, const int32_t packet_size, const strhdr + int32_t o = le32toh(str->offset); + // debug("ntlm_fetch_string(plength=%d,l=%d,o=%d)\n",packet_size,l,o); + +- if (l < 0 || l > NTLM_MAX_FIELD_LENGTH || o + l > packet_size || o == 0) { +- debug("ntlm_fetch_string: insane data (pkt-sz: %d, fetch len: %d, offset: %d)\n", packet_size,l,o); ++ if (l < 0 || l > NTLM_MAX_FIELD_LENGTH) { ++ debug("ntlm_fetch_string: insane string length (pkt-sz: %d, fetch len: %d, offset: %d)\n", packet_size,l,o); + return rv; + } ++ else if (o <= 0 || o > packet_size) { ++ debug("ntlm_fetch_string: insane string offset (pkt-sz: %d, fetch len: %d, offset: %d)\n", packet_size,l,o); ++ return rv; ++ } ++ else if (l > packet_size - o) { ++ debug("ntlm_fetch_string: truncated string data (pkt-sz: %d, fetch len: %d, offset: %d)\n", packet_size,l,o); ++ return rv; ++ } ++ + rv.str = (char *)packet + o; + rv.l = 0; + if ((flags & NTLM_NEGOTIATE_ASCII) == 0) {
meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -0
@@ -35,6 +35,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2 file://CVE-2023-5824.patch \ file://CVE-2021-46784.patch \ file://CVE-2022-41317.patch \ + file://CVE-2022-41318.patch \ " SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"
PATCH 4/6 squid: patch CVE-2023-46724
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2023-46724
Pick the patch from the details of the nvd report.
--- .../squid/files/CVE-2023-46724.patch | 41 +++++++++++++++++++ .../recipes-daemons/squid/squid_4.15.bb | 1 + 2 files changed, 42 insertions(+) create mode 100644 meta-networking/recipes-daemons/squid/files/CVE-2023-46724.patch
meta-networking/recipes-daemons/squid/files/CVE-2023-46724.patch new file +41 -0
@@ -0,0 +1,41 @@ +From 7025a946c8795244f8b50a40a84640ca8ed9e321 Mon Sep 17 00:00:00 2001 +From: Andreas Weigel <[email protected]> +Date: Wed, 18 Oct 2023 04:14:31 +0000 +Subject: [PATCH] Fix validation of certificates with CN=* (#1523) + +The bug was discovered and detailed by Joshua Rogers at +https://megamansec.github.io/Squid-Security-Audit/ +where it was filed as "Buffer UnderRead in SSL CN Parsing". + +CVE: CVE-2023-46724 +Upstream-Status: Backport [https://github.com/squid-cache/squid/commit/792ef23e6e1c05780fe17f733859eef6eb8c8be3] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/anyp/Uri.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/anyp/Uri.cc b/src/anyp/Uri.cc +index 54597f1..b0b60cf 100644 +--- a/src/anyp/Uri.cc ++++ b/src/anyp/Uri.cc +@@ -173,6 +173,10 @@ urlInitialize(void) + assert(0 == matchDomainName("*.foo.com", ".foo.com", mdnHonorWildcards)); + assert(0 != matchDomainName("*.foo.com", "foo.com", mdnHonorWildcards)); + ++ assert(0 != matchDomainName("foo.com", "")); ++ assert(0 != matchDomainName("foo.com", "", mdnHonorWildcards)); ++ assert(0 != matchDomainName("foo.com", "", mdnRejectSubsubDomains)); ++ + /* more cases? */ + } + +@@ -756,6 +760,8 @@ matchDomainName(const char *h, const char *d, uint8_t flags) + return -1; + + dl = strlen(d); ++ if (dl == 0) ++ return 1; + + /* + * Start at the ends of the two strings and work towards the
meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -0
@@ -36,6 +36,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2 file://CVE-2021-46784.patch \ file://CVE-2022-41317.patch \ file://CVE-2022-41318.patch \ + file://CVE-2023-46724.patch \ " SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"
PATCH 5/6 squid: patch CVE-2025-59362
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2025-59362
Pick the PR content that's referenced in the nvd report.
--- .../squid/files/CVE-2025-59362.patch | 51 +++++++++++++++++++ .../recipes-daemons/squid/squid_4.15.bb | 1 + 2 files changed, 52 insertions(+) create mode 100644 meta-networking/recipes-daemons/squid/files/CVE-2025-59362.patch
meta-networking/recipes-daemons/squid/files/CVE-2025-59362.patch new file +51 -0
@@ -0,0 +1,51 @@ +From 4b9784928c87225605fd223b6fa0e5b42d039359 Mon Sep 17 00:00:00 2001 +From: Alex Rousskov <[email protected]> +Date: Sat, 30 Aug 2025 06:49:36 +0000 +Subject: [PATCH] Fix ASN.1 encoding of long SNMP OIDs (#2149) + +CVE: CVE-2025-59362 +Upstream-Status: Backport [https://github.com/squid-cache/squid/commit/0d89165ee6da10e6fa50c44998b3cd16d59400e9] +--- + lib/snmplib/asn1.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/lib/snmplib/asn1.c b/lib/snmplib/asn1.c +index 8a4e471..0bb1f0b 100644 +--- a/lib/snmplib/asn1.c ++++ b/lib/snmplib/asn1.c +@@ -771,6 +771,7 @@ asn_build_objid(u_char * data, int *datalength, + * lastbyte ::= 0 7bitvalue + */ + u_char buf[MAX_OID_LEN]; ++ u_char *bufEnd = buf + sizeof(buf); + u_char *bp = buf; + oid *op = objid; + int asnlength; +@@ -789,6 +790,10 @@ asn_build_objid(u_char * data, int *datalength, + while (objidlength-- > 0) { + subid = *op++; + if (subid < 127) { /* off by one? */ ++ if (bp >= bufEnd) { ++ snmp_set_api_error(SNMPERR_ASN_ENCODE); ++ return (NULL); ++ } + *bp++ = subid; + } else { + mask = 0x7F; /* handle subid == 0 case */ +@@ -806,8 +811,16 @@ asn_build_objid(u_char * data, int *datalength, + /* fix a mask that got truncated above */ + if (mask == 0x1E00000) + mask = 0xFE00000; ++ if (bp >= bufEnd) { ++ snmp_set_api_error(SNMPERR_ASN_ENCODE); ++ return (NULL); ++ } + *bp++ = (u_char) (((subid & mask) >> bits) | ASN_BIT8); + } ++ if (bp >= bufEnd) { ++ snmp_set_api_error(SNMPERR_ASN_ENCODE); ++ return (NULL); ++ } + *bp++ = (u_char) (subid & mask); + } + }
meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -0
@@ -37,6 +37,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2 file://CVE-2022-41317.patch \ file://CVE-2022-41318.patch \ file://CVE-2023-46724.patch \ + file://CVE-2025-59362.patch \ " SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"
PATCH 6/6 squid: fix esi PACKAGECONFIG
In reply to Gyorgy Sarvarilibxml has derecated the "xmlSetFeature" call, and hid is behind a special config flag (--with-legacy), which is not used by default in oe-core.
This makes compilation fail, when "esi" PACKAGECONFIG is enabled:
Libxml2Parser.cc:94:5: error: 'xmlSetFeature' was not declared in this scope; did you mean 'xmlHasFeature'?
This backported patch fixes this.
--- ...ct-and-unnecessary-xmlSetFeature-cal.patch | 35 +++++++++++++++++++ .../recipes-daemons/squid/squid_4.15.bb | 1 + 2 files changed, 36 insertions(+) create mode 100644 meta-networking/recipes-daemons/squid/files/0001-ESI-Drop-incorrect-and-unnecessary-xmlSetFeature-cal.patch
meta-networking/recipes-daemons/squid/files/0001-ESI-Drop-incorrect-and-unnecessary-xmlSetFeature-cal.patch new file +35 -0
@@ -0,0 +1,35 @@ +From c312f7fa80371cc6db583590258381ebc7cd18f6 Mon Sep 17 00:00:00 2001 +From: Nick Wellnhofer <[email protected]> +Date: Sun, 20 Feb 2022 19:42:40 +0000 +Subject: [PATCH] ESI: Drop incorrect and unnecessary xmlSetFeature() call + (#988) + +xmlSetFeature() has been deprecated for 10+ years and will eventually be +removed from libxml2. Squid calls xmlSetFeature() with the wrong +argument: a nil `value` pointer instead of a pointer to a zero value. +When called with a nil `value`, the function does nothing but returning +an error. Squid does not check whether xmlSetFeature() call is +successful, and the bug went unnoticed since libxml2 support was added +in commit 964b44c. + +Since libxml2 does not substitute entities by default, the call can be +removed to achieve the intended effect. + +Upstream-Status: Backport [https://github.com/squid-cache/squid/commit/5db4df2c6f83b5c26357f4439d28b92ef7071cd5] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + src/esi/Libxml2Parser.cc | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/esi/Libxml2Parser.cc b/src/esi/Libxml2Parser.cc +index 2b9ba0a..0301b77 100644 +--- a/src/esi/Libxml2Parser.cc ++++ b/src/esi/Libxml2Parser.cc +@@ -91,7 +91,6 @@ ESILibxml2Parser::ESILibxml2Parser(ESIParserClient *aClient) : theClient (aClien + + /* TODO: grab the document encoding from the headers */ + parser = xmlCreatePushParserCtxt(&sax, static_cast<void *>(this), NULL, 0, NULL); +- xmlSetFeature(parser, "substitute entities", 0); + + if (entity_doc == NULL) + entity_doc = htmlNewDoc(NULL, NULL);
meta-networking/recipes-daemons/squid/squid_4.15.bb +1 -0
@@ -38,6 +38,7 @@ SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.bz2 file://CVE-2022-41318.patch \ file://CVE-2023-46724.patch \ file://CVE-2025-59362.patch \ + file://0001-ESI-Drop-incorrect-and-unnecessary-xmlSetFeature-cal.patch \ " SRC_URI:remove:toolchain-clang = "file://0001-configure-Check-for-Wno-error-format-truncation-comp.patch"