Skip to contentSkip to conversation

civetweb: patch CVE-2020-27304

PATCH New Gyorgy Sarvari 1 participant 1 message Oct 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 civetweb: patch CVE-2020-27304

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

Take the patches referenced in
https://jfrog.com/blog/cve-2020-27304-rce-via-directory-traversal-in-civetweb-http-server/
(which URL is also referenced by NIST)

---
 ...01-Sanitize-upload-filename-like-URL.patch | 27 ++++++
 ...ple-Upload-to-temporary-directory-an.patch | 90 +++++++++++++++++++
 .../civetweb/civetweb_git.bb                  |  2 +
 3 files changed, 119 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/civetweb/civetweb/0001-Sanitize-upload-filename-like-URL.patch
 create mode 100644 meta-networking/recipes-connectivity/civetweb/civetweb/0002-handle_form-example-Upload-to-temporary-directory-an.patch
meta-networking/recipes-connectivity/civetweb/civetweb/0001-Sanitize-upload-filename-like-URL.patch new file +27 -0
new file mode 100644
index 0000000000..0e2ee700c8
@@ -0,0 +1,27 @@
+From e7c4fca110a0823262cf444371d01309c85c760f Mon Sep 17 00:00:00 2001
+From: bel2125 <[email protected]>
+Date: Sat, 3 Jul 2021 21:54:28 +0200
+Subject: [PATCH] Sanitize upload filename like URL
+
+CVE: CVE-2020-27304
+
+Upstream-Status: Backport [https://github.com/civetweb/civetweb/commit/b2ed60c589172b37f3d705c69d84313eeb8348b1]
+
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/handle_form.inl | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/handle_form.inl b/src/handle_form.inl
+index 9853faf1..21536158 100644
+--- a/src/handle_form.inl
++++ b/src/handle_form.inl
+@@ -55,6 +55,8 @@ url_encoded_field_found(const struct mg_connection *conn,
+ 			mg_cry_internal(conn, "%s: Cannot decode filename", __func__);
+ 			return MG_FORM_FIELD_STORAGE_SKIP;
+ 		}
++		remove_dot_segments(filename_dec);
++
+ 	} else {
+ 		filename_dec[0] = 0;
+ 	}
meta-networking/recipes-connectivity/civetweb/civetweb/0002-handle_form-example-Upload-to-temporary-directory-an.patch new file +90 -0

90 lines not on this page · raw message

meta-networking/recipes-connectivity/civetweb/civetweb_git.bb +2 -0
index e9c2056180..1648d13d99 100644
@@ -8,6 +8,8 @@ SRCREV = "4b440a339979852d5a51fb11a822952712231c23"
 PV = "1.12+git${SRCPV}"
 SRC_URI = "git://github.com/civetweb/civetweb.git;branch=master;protocol=https \
            file://0001-Unittest-Link-librt-and-libm-using-l-option.patch \
+           file://0001-Sanitize-upload-filename-like-URL.patch \
+           file://0002-handle_form-example-Upload-to-temporary-directory-an.patch \
            "
 
 S = "${WORKDIR}/git"