diff options
| author | Hauke Mehrtens | 2026-06-13 00:40:48 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-15 23:38:07 +0000 |
| commit | 7b1bec45826bd78c8afc993435bdc0f1df2fe399 (patch) | |
| tree | 2b9aae8d6f42db8b74cc9a963a84ce73d6e00806 | |
| parent | b78f518478794e16ba3568fc1258e40bf3e8eb3b (diff) | |
| download | uhttpd-7b1bec45826bd78c8afc993435bdc0f1df2fe399.tar.gz | |
ubus: close connection on POST body parse error
uh_ubus_data_send() is only entered while there is still POST body data
to read. When the JSON body is delivered in several TCP segments and a
complete object has already been parsed (du->jsobj set), or the body
exceeds UH_UBUS_MAX_POST_SIZE, the error path emits a JSON-RPC parse
error and returns 0 without consuming the remaining declared
Content-Length bytes. The caller neither drained the rest of the body
nor closed the connection, so the unread body suffix was parsed as a
new HTTP request on the same keep-alive connection (request smuggling).
Set connection_close in the error path so the out-of-sync connection is
torn down instead of being reused.
Link: https://github.com/openwrt/uhttpd/security/advisories/GHSA-wgwp-64hh-f52p
Reported-by: @dyingc
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | ubus.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -942,6 +942,12 @@ static int uh_ubus_data_send(struct client *cl, const char *data, int len) return len; error: + /* We abort parsing the request body here without consuming the + * remaining declared Content-Length bytes. Close the connection even + * when keep alive is set, as the unread body suffix would otherwise be + * interpreted as the start of the next request (request smuggling). + */ + cl->request.connection_close = true; uh_ubus_single_error(cl, ERROR_PARSE); return 0; } |