Commit 24013f5
authored
fix: enforce the request-smuggling (CL.TE) check at the proxy chokepoint (#598)
* fix: enforce CL.TE smuggling check at the proxy chokepoint, drop broken CL.0 body-read (#14)
* fix: enforce HTTP/1.x request-smuggling checks at the proxy chokepoint
The CL.0/CL.TE check lived inside StandardEndpointMapper, so custom or test
mappers bypassed it; the CL.0 body-read also blocked the event loop without
ever catching the smuggle, since the decoder splits CL:0 + trailing bytes
into two pipelined requests. Run the check before map() and use a per-
connection taint flag to reject the next request after a Content-Length: 0.
* revert: drop the per-connection CL.0 taint
A legitimate Content-Length: 0 request followed by another request on the
same keep-alive connection is routine (CORS preflight, empty-body POSTs,
HEAD/DELETE/OPTIONS), so tainting the connection caused collateral 400s on
normal flows. The proxy layer cannot reliably distinguish a pipelined-burst
smuggle from sequential keep-alive reuse without channel-buffer inspection,
so keep only the header-only CL.TE check and accept that pure CL.0 smuggling
is not addressed at this layer.
* fix: smuggling check runs before filters can mutate CL/TE
Move the rejectAsSmuggling decision above the filter loop in processRequest
so a user-supplied request filter that strips or rewrites Content-Length or
Transfer-Encoding cannot bypass the check. The smuggling boolean is captured
on the raw inbound headers; filters and the mapper run as before.
* fix: reject detected smuggling before the filter chain, not just the mapper
A request flagged as CL.TE smuggling was still run through every request filter
before being mapped to a 400. Short-circuit to MapResult.badRequest() so a
detected attack skips both the filters and the mapper. Detection still runs on
the raw inbound headers first (in the if-condition), so a filter cannot mask it.1 parent bf8bdb7 commit 24013f5
2 files changed
Lines changed: 19 additions & 30 deletions
File tree
- carapace-server/src/main/java/org/carapaceproxy
- core
- server/mapper
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
| |||
209 | 218 | | |
210 | 219 | | |
211 | 220 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
| |||
Lines changed: 0 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| |||
149 | 147 | | |
150 | 148 | | |
151 | 149 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | 150 | | |
177 | 151 | | |
178 | 152 | | |
| |||
0 commit comments