summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/lighttpd/lighttpd/0001-mod_extforward-fix-out-of-bounds-OOB-write-fixes-313.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/lighttpd/lighttpd/0001-mod_extforward-fix-out-of-bounds-OOB-write-fixes-313.patch')
-rw-r--r--meta/recipes-extended/lighttpd/lighttpd/0001-mod_extforward-fix-out-of-bounds-OOB-write-fixes-313.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/meta/recipes-extended/lighttpd/lighttpd/0001-mod_extforward-fix-out-of-bounds-OOB-write-fixes-313.patch b/meta/recipes-extended/lighttpd/lighttpd/0001-mod_extforward-fix-out-of-bounds-OOB-write-fixes-313.patch
new file mode 100644
index 0000000000..da59b7297a
--- /dev/null
+++ b/meta/recipes-extended/lighttpd/lighttpd/0001-mod_extforward-fix-out-of-bounds-OOB-write-fixes-313.patch
@@ -0,0 +1,100 @@
1From 27103f3f8b1a2857aa45b889e775435f7daf141f Mon Sep 17 00:00:00 2001
2From: povcfe <povcfe@qq.com>
3Date: Wed, 5 Jan 2022 11:11:09 +0000
4Subject: [PATCH] [mod_extforward] fix out-of-bounds (OOB) write (fixes #3134)
5
6(thx povcfe)
7
8(edited: gstrauss)
9
10There is a potential remote denial of service in lighttpd mod_extforward
11under specific, non-default and uncommon 32-bit lighttpd mod_extforward
12configurations.
13
14Under specific, non-default and uncommon lighttpd mod_extforward
15configurations, a remote attacker can trigger a 4-byte out-of-bounds
16write of value '-1' to the stack. This is not believed to be exploitable
17in any way beyond triggering a crash of the lighttpd server on systems
18where the lighttpd server has been built 32-bit and with compiler flags
19which enable a stack canary -- gcc/clang -fstack-protector-strong or
20-fstack-protector-all, but bug not visible with only -fstack-protector.
21
22With standard lighttpd builds using -O2 optimization on 64-bit x86_64,
23this bug has not been observed to cause adverse behavior, even with
24gcc/clang -fstack-protector-strong.
25
26For the bug to be reachable, the user must be using a non-default
27lighttpd configuration which enables mod_extforward and configures
28mod_extforward to accept and parse the "Forwarded" header from a trusted
29proxy. At this time, support for RFC7239 Forwarded is not common in CDN
30providers or popular web server reverse proxies. It bears repeating that
31for the user to desire to configure lighttpd mod_extforward to accept
32"Forwarded", the user must also be using a trusted proxy (in front of
33lighttpd) which understands and actively modifies the "Forwarded" header
34sent to lighttpd.
35
36lighttpd natively supports RFC7239 "Forwarded"
37hiawatha natively supports RFC7239 "Forwarded"
38
39nginx can be manually configured to add a "Forwarded" header
40https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/
41
42A 64-bit build of lighttpd on x86_64 (not known to be affected by bug)
43in front of another 32-bit lighttpd will detect and reject a malicious
44"Forwarded" request header, thereby thwarting an attempt to trigger
45this bug in an upstream 32-bit lighttpd.
46
47The following servers currently do not natively support RFC7239 Forwarded:
48nginx
49apache2
50caddy
51node.js
52haproxy
53squid
54varnish-cache
55litespeed
56
57Given the general dearth of support for RFC7239 Forwarded in popular
58CDNs and web server reverse proxies, and given the prerequisites in
59lighttpd mod_extforward needed to reach this bug, the number of lighttpd
60servers vulnerable to this bug is estimated to be vanishingly small.
61Large systems using reverse proxies are likely running 64-bit lighttpd,
62which is not known to be adversely affected by this bug.
63
64In the future, it is desirable for more servers to implement RFC7239
65Forwarded. lighttpd developers would like to thank povcfe for reporting
66this bug so that it can be fixed before more CDNs and web servers
67implement RFC7239 Forwarded.
68
69x-ref:
70 "mod_extforward plugin has out-of-bounds (OOB) write of 4-byte -1"
71 https://redmine.lighttpd.net/issues/3134
72 (not yet written or published)
73 CVE-2022-22707
74
75Upstream-Status: Backport
76CVE: CVE-2022-22707
77Signed-off-by: Ross Burton <ross.burton@arm.com>
78
79Signed-off-by: Purushottam Choudhary <purushottam.choudhary@kpit.com>
80Signed-off-by: Purushottam Choudhary <purushottamchoudhary29@gmail.com>
81---
82 src/mod_extforward.c | 2 +-
83 1 file changed, 1 insertion(+), 1 deletion(-)
84
85diff --git a/src/mod_extforward.c b/src/mod_extforward.c
86index ba957e04..fdaef7f6 100644
87--- a/src/mod_extforward.c
88+++ b/src/mod_extforward.c
89@@ -715,7 +715,7 @@ static handler_t mod_extforward_Forwarded (request_st * const r, plugin_data * c
90 while (s[i] == ' ' || s[i] == '\t') ++i;
91 if (s[i] == ';') { ++i; continue; }
92 if (s[i] == ',') {
93- if (j >= (int)(sizeof(offsets)/sizeof(int))) break;
94+ if (j >= (int)(sizeof(offsets)/sizeof(int))-1) break;
95 offsets[++j] = -1; /*("offset" separating params from next proxy)*/
96 ++i;
97 continue;
98--
992.25.1
100