@@ -0,0 +1,94 @@
1+From 45fa3f18adf57ef9d743038743d9c90573aeeb91 Mon Sep 17 00:00:00 2001
2+From: Dimitri John Ledkov <xnox@ubuntu.com>
3+Date: Tue, 19 May 2020 18:20:39 +0100
4+Subject: [PATCH] wget: implement TLS verification with
5+ ENABLE_FEATURE_WGET_OPENSSL
6+
7+When ENABLE_FEATURE_WGET_OPENSSL is enabled, correctly implement TLS
8+verification by default. And only ignore verification errors, if
9+--no-check-certificate was passed.
10+
11+Also note, that previously OPENSSL implementation did not implement
12+TLS verification, nor printed any warning messages that verification
13+was not performed.
14+
15+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1879533
16+
17+CVE-2018-1000500
18+
19+Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
20+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
21+---
22+ networking/wget.c | 20 +++++++++++++++++---
23+ 1 file changed, 17 insertions(+), 3 deletions(-)
24+
25+diff --git a/networking/wget.c b/networking/wget.c
26+index f2fc9e215..6a8c08324 100644
27+--- a/networking/wget.c
28++++ b/networking/wget.c
29+@@ -91,6 +91,9 @@
30+ //config: patches, but do want to waste bandwidth expaining how wrong
31+ //config: it is, you will be ignored.
32+ //config:
33++//config: FEATURE_WGET_OPENSSL does implement TLS verification
34++//config: using the certificates available to OpenSSL.
35++//config:
36+ //config:config FEATURE_WGET_OPENSSL
37+ //config: bool "Try to connect to HTTPS using openssl"
38+ //config: default y
39+@@ -115,6 +118,9 @@
40+ //config: If openssl can't be executed, internal TLS code will be used
41+ //config: (if you enabled it); if openssl can be executed but fails later,
42+ //config: wget can't detect this, and download will fail.
43++//config:
44++//config: By default TLS verification is performed, unless
45++//config: --no-check-certificate option is passed.
46+
47+ //applet:IF_WGET(APPLET(wget, BB_DIR_USR_BIN, BB_SUID_DROP))
48+
49+@@ -124,8 +130,11 @@
50+ //usage: IF_FEATURE_WGET_LONG_OPTIONS(
51+ //usage: "[-c|--continue] [--spider] [-q|--quiet] [-O|--output-document FILE]\n"
52+ //usage: " [-o|--output-file FILE] [--header 'header: value'] [-Y|--proxy on/off]\n"
53++//usage: IF_FEATURE_WGET_OPENSSL(
54++//usage: " [--no-check-certificate]\n"
55++//usage: )
56+ /* Since we ignore these opts, we don't show them in --help */
57+-/* //usage: " [--no-check-certificate] [--no-cache] [--passive-ftp] [-t TRIES]" */
58++/* //usage: " [--no-cache] [--passive-ftp] [-t TRIES]" */
59+ /* //usage: " [-nv] [-nc] [-nH] [-np]" */
60+ //usage: " [-P DIR] [-S|--server-response] [-U|--user-agent AGENT]" IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..."
61+ //usage: )
62+@@ -137,7 +146,9 @@
63+ //usage: "Retrieve files via HTTP or FTP\n"
64+ //usage: IF_FEATURE_WGET_LONG_OPTIONS(
65+ //usage: "\n --spider Only check URL existence: $? is 0 if exists"
66+-///////: "\n --no-check-certificate Don't validate the server's certificate"
67++//usage: IF_FEATURE_WGET_OPENSSL(
68++//usage: "\n --no-check-certificate Don't validate the server's certificate"
69++//usage: )
70+ //usage: )
71+ //usage: "\n -c Continue retrieval of aborted transfer"
72+ //usage: "\n -q Quiet"
73+@@ -662,7 +673,7 @@ static int spawn_https_helper_openssl(const char *host, unsigned port)
74+ pid = xvfork();
75+ if (pid == 0) {
76+ /* Child */
77+- char *argv[8];
78++ char *argv[9];
79+
80+ close(sp[0]);
81+ xmove_fd(sp[1], 0);
82+@@ -689,6 +700,9 @@ static int spawn_https_helper_openssl(const char *host, unsigned port)
83+ argv[5] = (char*)"-servername";
84+ argv[6] = (char*)servername;
85+ }
86++ if (!(option_mask32 & WGET_OPT_NO_CHECK_CERT)) {
87++ argv[7] = (char*)"-verify_return_error";
88++ }
89+
90+ BB_EXECVP(argv[0], argv);
91+ xmove_fd(3, 2);
92+--
93+2.28.0
94+