Repository navigation
proxy test: Cover hcexpr, 100-continue, XSS escaping, wstunnel, AJP TE and CRLF smuggling - #1152
Conversation
…E and CRLF smuggling Adding various tests ProxyHCExpri condition test in test_09, an Expect: 100-continue test in test_06, balancer-manager and (moved to the generators module) server-info Host-header escaping, an AJP Transfer-Encoding smuggling test in test_04, and encoded-CRLF no-smuggling through RewriteRule [P], ProxyPassMatch nocanon and LocationMatch in test_11. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Thanks, good coverage overall. Two don't quite hold up though: test_proxy_011_04 (RewriteRule [P], no nocanon) never reaches the backend -- 403 before that, so the assert passes on an empty list. And test_proxy_13_01 only survives because the fake backend hangs up right after answering; a real websocket backend would very likely swallow the pipelined second request into the tunnel instead. |
test_proxy_011_04 asserted no-smuggling on an empty backend capture: RewriteRule [P] matches the decoded URI, so the rewritten query string holds decoded control characters, which mod_rewrite rejects with 403 (AH10410) before the request is forwarded. Assertng the 403 and that nothing reaches the backend, and made the 011_05/011_06 asserts more meaningful by asserting the backend received exactly one request with the CRLFs still percent-encoded. test_proxy_13_01 never reached mod_proxy_wstunnel: with proxy_http loaded, ProxyWebsocketFallbackToProxyHttp defaults to On so mod_proxy_wstunnel declines, and mod_proxy_http only tunnels after a 101 response, which the fake backend never sends. Test rewritten to test what it actually exercised -- both pipelined requests answer when the backend does not upgrade, with the Upgrade headers forwarded. Add a new test: test_proxy_13_02 with the fallback Off to pin mod_proxy_wstunnel behavior: with a verbatim relay, no response for a pipelined request behind the tunnel, and the client connection closed once the backend hangs up. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Hi @arturobernalg test_proxy_011_04 now checks what really happens: the request is rejected with 403 before it reaches the backend. test_proxy_13_01 had a bigger problem: it never used mod_proxy_wstunnel at all. I changed the test to test this directly: both pipelined requests must be answered, and the Upgrade headers must be forwarded to the backend. After a real 101 the connection is a tunnel, so a pipelined request behind it is tunnel data this behavior is correct and I did not test against it. Instead I added a new test with ProxyWebsocketFallbackToProxyHttp Off, which uses mod_proxy_wstunnel for real. |
|
Ran these two against trunk to double check. Good progress, but not quite there yet: test_proxy_011_05 / 011_06: these are red right now, not flaky. The test_proxy_13_02: good that it now forces the real tunnel, but the backend only does one Small one: 011_04 ignores AH10410 in the log but doesn't actually check it's the reason for the 403. |
011_05/011_06: the percent-encoded CRLF check is now case-insensitive; curl re-encodes the URI with upper-case hex on some platforms, so the lower-case assert never matched there. 011_04: assert the AH10410 rejection is actually logged, so the 403 is pinned to the query-string check and not just to any 403. 13_02: the tunnel backend now keeps reading after answering, until the pipelined request arrives (or the connection ends), and asserts it was forwarded into the tunnel to the same backend -- proving the swallow instead of only checking the client saw no second response. Draining before the close also keeps the FIN clean; closing with unread data can surface as a reset and lose the response in flight. TCPFaker grows an overridable _handle_connection() hook for this. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Thank you pointing out the continuing issues with the tests, it's very appreciated 011_05 / 011_06: case-sensitive %0d%0a (the red tests): The assert now compares against faker.all_requests[0].lower(). 13_02: coin-flip capture + RST risk: The tunnel backend now overrides a new TCPFaker._handle_connection() hook (minimal scaffolding extension in env.py) to keep reading after answering until the pipelined GET /ws2 arrives, then drains with a short grace timeout before closing. The test now asserts positively that the pipelined request was forwarded into the tunnel to the same The drain-then-close also fixes the RST concern: the socket is empty when it shuts down, so the FIN is clean on Windows too. Instrumented runs confirmed the keep-reading path is genuinely exercised (first recv = request 1 only, 011_04: AH10410 not actually checked: Now does the wait_for on the AH10410 "Rewritten query string" line and asserts it's found, so the 403 is pinned to that check rather than any 403. |
Adding various tests ProxyHCExpri condition test in test_09, an Expect: 100-continue test in test_06, balancer-manager and (moved to the generators module) server-info
Host-header escaping, an AJP Transfer-Encoding smuggling test in test_04, and encoded-CRLF no-smuggling through RewriteRule [P], ProxyPassMatch nocanon and LocationMatch in test_11.
(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.