Bug #14879
openwthttp dedicated-process: parent rejects chunked response from session process ("unexpected chunked encoding!"), browser gets 500
0%
Description
Wt version: 4.14.4 (official SDK Wt-4.14.4-msvs2022-Windows-x64-SDK); first seen with 4.10.4
Platform: Windows (seen at a customer on Windows Server 2025, reproduced on Windows Server 2022)
Connector: wthttp, session-management = dedicated-process
Description
In dedicated-process mode the parent forwards every request to the session process over 127.0.0.1 (ProxyReply). Because it sends "Connection: close", the child never uses chunked transfer coding, and ProxyReply::handleResponseRead() treats "Transfer-Encoding: chunked" as an error: it logs "unexpected chunked encoding!" and answers the browser with 500.
At a customer site running ESET Security with protocol filtering enabled, the loopback traffic between parent and child gets re-encoded. The child answers 200, but the response reaches the parent with "Transfer-Encoding: chunked". As a result every request fails with 500 and no session can be started at all. shared-process mode works on the same machine, since there is no loopback hop.
Chunked is valid HTTP/1.1, and RFC 9112, section 7.1 requires a recipient to be able to parse it. We therefore suggest that ProxyReply decode a chunked response instead of failing. A patch against 4.14.4 is attached. We have shipped the same change on 4.10.4 to our customers, and with it the affected system works.
Steps to reproduce (no virus scanner needed)
The attached repro.cpp simulates the filtering proxy. Started normally, it is a plain Wt application. When the parent starts it as a session process (--parent-port=N), it does not run Wt. Instead it runs a minimal stand-in that announces its port the same way Server::handleConnected() does ("port:\n") and answers every request with a chunked 200.
- Build repro.cpp against Wt (link wt and wthttp), e.g. with MSVC:
- Put the attached wt_config.xml next to it. It only enables dedicated-process:
<server>
<application-settings location="*">
<session-management>
<dedicated-process>
<max-num-sessions>10</max-num-sessions>
</dedicated-process>
</session-management>
</application-settings>
</server>
- Start it:
- Request a page:
Expected: 200 with body "hello from the child".
Actual (Wt 4.14.4):
With the attached patch applied to 4.14.4:
HTTP/1.1 200 OK ... hello from the child [warning] "wthttp/proxy: child process 6068 responds with chunked encoding, decoding it; something between parent and child alters the response"
About the patch
- Only src/http/ProxyReply.C and ProxyReply.h are changed. The patch applies to 4.14.4 with "git apply -p1".
- When the child's response is chunked, ProxyReply::appendResponseData() decodes it incrementally (chunk size, data, trailer) instead of rejecting it.
- After the last chunk the reply is finished without waiting for EOF, because whatever re-encoded the response may keep the connection to the child open.
- Malformed chunking is logged as an error and the reply is aborted.
- The header check uses icontains instead of iequals, so a value like "gzip, chunked" is detected as well. Other transfer codings than chunked are not decoded.
- A warning is logged once per process, so the cause stays visible to the administrator.
Files
RM Updated by Romain Mardulyn 25 days ago
- Target version set to 4.16.0
ED Updated by emil de keyser 17 days ago
- Status changed from New to InProgress
- Assignee set to emil de keyser
ED Updated by emil de keyser 17 days ago
- Status changed from InProgress to Review
- Assignee deleted (
emil de keyser)
RM Updated by Romain Mardulyn 12 days ago
- Assignee set to Romain Mardulyn