mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2563] [CLOSED] serve: a number json reads as infinite, or nesting deeper than Python recurses, is a 400 instead of a dropped connection #4128
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4128
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2563
Author: @qiuzan2001
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:chief-docs/overflow-400📝 Commits (1)
da49fa4serve: a number json reads as infinite, or nesting deeper than Python recurses, is a 400 instead of a dropped connection📊 Changes
4 files changed (+51 additions, -7 deletions)
View changed files
📝
serve/runconfig.py(+4 -2)📝
serve/server.py(+7 -5)📝
serve/test_request_hardening.py(+21 -0)📝
serve/test_runconfig.py(+19 -0)📄 Description
What it changes. Python's
jsonreadsInfinity,-Infinity,NaNand1e400(as an infinite float) and nests as deep as its recursion limit allows. Some of those requests got no HTTP answer at all: the connection closed and a traceback went to the log.POST /v1/chat/completions//v1/messageswith"max_tokens"or"max_completion_tokens"ofInfinity,-Infinityor1e400:int()raisedOverflowError, which noexceptin_posttook.json's limit (100,000 levels), or a tool'sparametersschema 600 levels deep (the server's own walk of it):RecursionError, same result.POST /config(the Settings view's keys):reasoning_budget_tokens: Infinityand a 400-digit whole number forsampling.temperature(float()overflows) dropped the connection the same way, andInfinityforidle_unload_s,engine_silence_sorsampling.temperaturewas accepted and written into the run config asInfinity, which is not JSON that other programs (editors,jq) read.Now
OverflowErrorandRecursionErrorjoin the existing malformed-request 400 (TypeError,KeyError, ... "the request is malformed (...)", traceback in the log; aRecursionErrorlogs its last 8 frames instead of ~1,000, ~240 KB per request before).runconfig._numberrefuses a float that is not finite (a 400 naming the key), and_config_postanswers anOverflowErrorwith 400. A huge whole number foridle_unload_sis still taken, as before.What it leaves alone. Every request that got an answer before gets the same answer: the new
exceptentries only catch what used to escape to the socket server, and an error after the answer began is still re-raised as before. The web app cannot send these values (JSON.stringify(Infinity)isnull). Needs the API key where one is set, like any request.How it was checked. New tests, each failing before the change:
test_request_hardening.Hardening.test_an_infinite_number_is_400(9 cases),test_a_too_deeply_nested_body_is_400(600 and 100,000 levels),test_runconfig.Apply.test_refused(non-finite values for 8 keys, and a huge whole number still taken),test_runconfig.Http.test_a_number_too_big_or_not_finite_is_400. The wholeservesuite passes on the final commit (788 tests) excepttest_keepawake.test_service_holds_for_the_whole_request_including_early_close, which fails the same way onmainon this Linux box (Ubuntu, Python 3.14). A sub-agent reviewer fuzzed 1e400 and a 400-digit integer into ~22 numeric fields on 10 routes: no dropped connection after the change. Found in a security read ofserve/server.py(#544's invitation).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.