From 32c0f6f240fcb041ae7df44a9bbf958d627a8212 Mon Sep 17 00:00:00 2001
From: Radoslav Kolev <radoslav.kolev@suse.com>
Date: Fri, 21 Nov 2025 11:21:18 +0200
Subject: [PATCH] wget: don't allow control characters or spaces in the URL

Fixes CVE-2025-60876 malicious URL can be used to inject
HTTP headers in the request.

Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com>
Reviewed-by: Emmanuel Deloget <logout@free.fr>

CVE: CVE-2025-60876
Upstream-Status: Submitted [https://lists.busybox.net/pipermail/busybox/2025-November/091840.html]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 networking/wget.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/networking/wget.c b/networking/wget.c
index 9ec0e67..7602563 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -536,6 +536,15 @@ static void parse_url(const char *src_url, struct host_info *h)
 {
 	char *url, *p, *sp;
 
+	/* Fix for CVE-2025-60876 - don't allow control characters or spaces in the URL */
+	/* otherwise a malicious URL can be used to inject HTTP headers in the request */
+	const unsigned char *u = (void *) src_url;
+	while (*u) {
+		if (*u <= ' ')
+			bb_simple_error_msg_and_die("Unencoded control character found in the URL!");
+		u++;
+	}
+
 	free(h->allocated);
 	h->allocated = url = xstrdup(src_url);
 
