Repository navigation
fix(storage, plugin-hono-server): every byte-reading upload door holds a body with no declared length to its own bound - #33323
Conversation
Claude-Session: https://claude.ai/code/session_017xRBcTHcckwGChckTwu6Lp Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcTHcckwGChckTwu6Lp Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcTHcckwGChckTwu6Lp Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcTHcckwGChckTwu6Lp Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcTHcckwGChckTwu6Lp Co-authored-by: Claude <noreply@anthropic.com>
…nd-undeclared-length
|
security#1 · sunhaolin · session_017xRBcTHcckwGChckTwu6Lp {
"issue": null,
"status": "done",
"branch": "claude/byte-doors-bound-undeclared-length",
"pr": "https://github.com/objectstack-ai/objectstack/pull/33323",
"session": "session_017xRBcTHcckwGChckTwu6Lp",
"premise_still_valid": true,
"summary": "IHttpRequest.rawBody widens to take an optional { maxBytes } (Clause-② yes (widening), Metadata-protocol none): an implementation holds the reading door's bound whether or not a length is declared, refusing 413 PAYLOAD_TOO_LARGE, and an escaped refusal is answered 413. plugin-hono-server holds it on every read path (original body and a held pre-read) and cancels the source past the bound; the QA reference adapter mirrors it; the storage chunk, local raw and upload-link PUTs and the upload-link form take-over each state their own bound and answer their own 413, and the upload-link PUT now judges the link before reading a byte (after the declared-length check, so the existing order pin holds). The advisory notes' items were worked in order: the one product choice they leave open (a byte door's bound when max_upload_mb is unset) is a fork in open_questions, unchanged here; the rest are summarised in the PR's Acceptance notes. Declared file surface: packages/spec/src/contracts/http-server.ts, packages/plugins/plugin-hono-server/src/{adapter,body-limit,body-limit.test}.ts, packages/qa/http-conformance/src/{adapter,request-body.conformance.test}.ts, packages/services/service-storage/src/{storage-routes,storage-limits.test,record-file-access.integration.test}.ts, .changeset/byte-door-own-bound.md; no breach. Open PR overlap: none of 25 open code PRs touch these files (heads fetched and diffed).",
"tests": "Head 36ce94c0 (origin/main 47a3b95e merged): plugin-hono-server 42 files / 555 passed; service-storage 84 files / 1640 passed, 1 skipped; @objectstack/hono 14 / 258 passed; http-conformance 20 / 286 passed (os-verify-lock VERDICT command-exit 0). New rule-named pins with CONTROLS in body-limit.test.ts (8), request-body.conformance.test.ts (both adapters + parity), storage-limits.test.ts (3), record-file-access.integration.test.ts (4). Ablation, fix committed first, via scripts/ablation-replace.mjs, each restored to the HEAD blob with git diff HEAD empty: (1) storage doors pass no bound: 4 red; (2) the upload-link link check before the read removed: 1 red; (3) the transport ignores maxBytes on the original body: red (the run did not complete); the reference adapter's in-read stop is not ablated (its answer is the same either way). Source-imported suites, so no dist leg was owed for (1) and (2); (3) is plugin-hono-server's own src.",
"gates": "Head 36ce94c0: dispatch-gates --commands derived 93; all run with exit codes recorded; --ran: 93 accounted, 92 exit 0, 1 NOT MEASURED (node scripts/check-plugin-teardown-shape.mjs --self-test exit 3, PREREQUISITE NOT MET: fixture commit beyond the shallow clone), 0 UNRUN. typecheck exit 0 for spec, plugin-hono-server, service-storage, http-conformance, hono, rest (every check:test-typecheck OK). spec check:generated: all 14 artifacts up to date. CI check-runs on #33323: in_progress / NOT MEASURED at report time.",
"dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
"mcp_calls": "4 — mcp__github__list_pull_requests x2, ToolSearch-loaded only; no MCP write tool",
"api_writes": "2 relay dispatches — advisory_read (read), pr_create #33323 (draft, assignee sunhaolin); plus this os-dev-report comment via post-stamped; git push not counted",
"open_questions": [
{
"question": "A byte door's bound when max_upload_mb is unset (no settings namespace bound, or bindToSettings:false): today, and after this PR, the door states no bound and reads the whole body.",
"options": [
"A — keep: no door bound when unset (status quo; zero work; the transport limit does not cover rawBody by design)",
"B — fall back to the transport's request-body limit (10 MiB default, OS_HTTP_MAX_BODY_BYTES) when unset: small change in storage-routes; narrowing (uploads over 10 MiB on hosts with no limit refused), so the breaking kit and the dogfood battery are owed, and the dogfood file request-body-limit-upload-doors pins the opposite today",
"C — apply the storage namespace's declared default (100 MB) when unset: same size of change and the same breaking kit as B, but matches what a bound settings namespace already enforces by default"
],
"recommendation": "C, because it gives every byte door a bound on every host while keeping the same number a deployment with settings already gets, so only hosts that unbound settings move; B would cap uploads at the transport limit, which the transport's own design says is not an upload bound."
}
],
"security_findings": "withheld",
"out_of_scope_findings": [
"carrier: none · noted, not filed — the upload-link several-file take-over still holds the raw bytes, the parsed form and one buffer per file at once, each bounded by the form limit (PR Acceptance notes)",
"carrier: cloud · noted, not filed — a route outside this repository that reads rawBody (named in the CLI source) should pass its bound"
]
} |
📓 Docs Drift CheckThis PR changes 4 package(s): 22 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 177 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 47e74e85fb3ff439a827a18eb2b59a984abb439c && git checkout 47e74e85fb3ff439a827a18eb2b59a984abb439c
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 020ce3d9e8c7ac9a97863cf31e151290d4938a70 16f52c33502283c2986510e036fa464c2b3b7a07 && git checkout -B drift-repro 020ce3d9e8c7ac9a97863cf31e151290d4938a70 && git merge --no-ff 16f52c33502283c2986510e036fa464c2b3b7a07
node scripts/docs-audit/affected-docs.mjs --json 020ce3d9e8c7ac9a97863cf31e151290d4938a70
|
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 36ce94c · 2026-11-14T18:08Z |
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract reviewServed-tier: Read: the PR body, the file list (10 files), the net diff against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentpackages/spec/src/contracts/http-server.ts — holds. The shape is right, the three length cases are stated exactly, and the
packages/plugins/plugin-hono-server/src/body-limit.ts, adapter.ts — agree with the contract. packages/services/service-storage/src/storage-routes.ts — the four doors state the right bounds (what the limit leaves the chunk;
packages/qa/http-conformance/src/adapter.ts — mirrors the rule for a body left on the socket, and the escaped answer matches the standard transport byte for byte.
Two should-fix findings, each a few lines; they earn a delta review of the fix. Implemented-by: VERDICT: PASS |
… the contract names maxBytes' domain Claude-Session: https://claude.ai/code/session_017xRBcTHcckwGChckTwu6Lp Co-authored-by: Claude <noreply@anthropic.com>
…nd-undeclared-length
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 16f52c3 · 2026-11-15T04:10Z |
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract reviewServed-tier: Delta review of record 6882087301 (head Check-runs on this head at render time: 24 concluded success (changeset, PR-body guards, queue guard, every lint job, source type check, spec liveness, dogfood gate), 11 skipped (opt-in, schedule and docs jobs), and 29 still running (Build Core, the Test Core and Test UI shards, three type-check jobs, the two E2E jobs). None has concluded failure. The verdict below is on the tree as read; the all-green landing check is still owed on this head once those runs conclude. ① Derived judgments
② Semver levelUnchanged and still right: ③ Boundary flags
④ Design judgmentFindings of record 6882087301, each judged on this head:
New in the hop:
packages/spec/src/contracts/http-server.ts — holds against both implementations and its first consumer, No must-fix and no should-fix. Nits only: this is the final round for this PR's contract face. Implemented-by: VERDICT: PASS |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f 席位核对ACCEPT at
Implemented-by: os-dev (security#1 cloud order, Generated by Claude Code |
|
security#1 · sunhaolin · session_017xRBcTHcckwGChckTwu6Lp {
"issue": null,
"status": "done",
"branch": "claude/byte-doors-bound-undeclared-length",
"pr": "https://github.com/objectstack-ai/objectstack/pull/33323",
"session": "session_017xRBcTHcckwGChckTwu6Lp",
"premise_still_valid": true,
"summary": "Patch round on the contract review of record 6882087301 (PASS at 36ce94c0, two should-fix). (1) The IHttpRequest.rawBody contract now states the domain of maxBytes (a non-negative whole number of bytes) and the one behaviour for any other value: the call itself throws a TypeError before anything is read, never returning a promise. That is what both implementations' rawBodyMaxBytes already did, and it is now pinned on both adapters. The repeated-calls sentence was reworded to match the code (a later call is judged against its own bound). (2) readDoorBytes answers the door's own refusal only for a bound the door stated; a size refusal on a read that stated no bound is thrown on as before. Pinned per door: chunk PUT and local raw PUT answer 500 INTERNAL with a message, and the upload-link PUT relays the host's 413 with its own words and leaves the link unspent. The reference adapter's rawBody comment no longer overstates (an eagerly read body is judged once read). The unset max_upload_mb fork is untouched and with the maintainer. Remaining nits not taken: the door message naming the door's limit when the host's refusal is the transport's (status and code are right).",
"tests": "Head 16f52c33 (origin/main merged again; install + closure build): plugin-hono-server 42 files / 556 passed; service-storage 86 / 1651 passed, 1 skipped; @objectstack/hono 14 / 258 passed; http-conformance 20 / 292 passed (os-verify-lock VERDICT command-exit 0). New: 3 storage pins (a host size refusal with no bound, one per door), 6 conformance cases (an out-of-domain maxBytes throws from the call, 3 values x 2 adapters). Ablation for finding 2, fix committed first: the stated-bound guard removed via scripts/ablation-replace.mjs (anchor 1 -> 0): 3 of 3 new pins red; restored to the HEAD blob, git diff HEAD empty.",
"gates": "Head 16f52c33: dispatch-gates --commands derived 93, all run with exit codes recorded; --ran: 93 accounted, 90 exit 0, 3 NOT MEASURED (exit 3, PREREQUISITE NOT MET: check-plugin-teardown-shape --self-test needs a fixture beyond the shallow clone; check:dual-build-cjs-loads and check:i18n need a full build this worktree does not have), 0 UNRUN. typecheck exit 0 for spec, plugin-hono-server, service-storage, http-conformance, hono, rest (every check:test-typecheck OK); spec check:generated: 14 of 14 up to date. CI on this head: in_progress, NOT MEASURED at report time.",
"dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
"mcp_calls": "0 this round",
"api_writes": "1 — this os-dev-report comment via post-stamped (relay); git push not counted",
"open_questions": [],
"security_findings": "withheld",
"out_of_scope_findings": []
} |
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
IHttpRequest.rawBody新增可选参数{ maxBytes }。max_upload_mb未设置时行为不变。回滚即还原本 PR。packages/plugins/plugin-hono-server/src/body-limit.ts(有界读取)、packages/services/service-storage/src/storage-routes.ts(各入口传入上限、上传链接先判链接再读)、packages/spec/src/contracts/http-server.ts(契约文字)。pnpm --filter @objectstack/plugin-hono-server exec vitest run src/body-limit.test.ts -t "own bound",预期 8 个用例全部通过。What changes
The rule: every byte-reading upload door holds a body with no declared length to its own bound, exactly as it holds a declared one, and refuses past the bound before the body is buffered further.
The contract change (rule level) — for the contract-tier review
IHttpRequest.rawBody(packages/spec/src/contracts/http-server.ts) widens from an accessor that takes no argument to one that takes an optional{ maxBytes?: number }, still answering a promise of the body's bytes:maxBytes. An implementation MUST then hold the body to it whether or not a length is declared: a declaredContent-Lengthover it is refused unread; a body with no declared length is refused once it passes it, and read no further; exactlymaxBytesis read whole.status413 andcodePAYLOAD_TOO_LARGE. The door answers it with its own refusal; one it lets escape is answered413 PAYLOAD_TOO_LARGE.maxBytesthe whole body is read, as before. Repeated calls answer what the first read: the same bytes (judged against each call's bound) or the first refusal.bodymember's text now names the transport's413refusal and its one way out: a door that then readsrawBodytakes the read over under its own bound, which it owes torawBody.Widening: an implementation that takes no argument still type-checks, and every call that passes nothing behaves as before.
What each consumer does with it
@objectstack/plugin-hono-server(adapter.ts,body-limit.ts)maxByteson every read path a byte door reaches: the original body, and a body a JSON or form pre-read already held. Past the bound the source is cancelled. An escaped refusal with no answer written is answered413 PAYLOAD_TOO_LARGE.@objectstack/http-conformance(adapter.ts, private, QA)@objectstack/service-storagechunkPUTmax_upload_mbleaves this chunk (the limit minus the bytes the upload already holds).@objectstack/service-storagepresigned local rawPUTmax_upload_mb.@objectstack/service-storageupload-linkPUT, one filemax_upload_mb; also judges the link (open, unexpired, the caller's) before reading a byte of the body. A body declaring more than the door takes is still refused first, as before.@objectstack/service-storageupload-link several-file form, taken over past the transport limitmax_upload_mbunsetEach storage door also still judges the bytes it read after the read, so a host whose
rawBodyignoresmaxByteskeeps the answers it had.Tests
All named by the rule, each with CONTROLS for the unchanged paths:
plugin-hono-serverbody-limit.test.ts— a byte door's own bound holds a body whether or not it declares a length: undeclared body past the bound refused with the source cancelled and bytes pulled at most the bound plus two chunks (application/octet-stream,application/json); a form taken over after the transport refusal held the same way; declared length over the bound refused with zero bytes pulled; escaped refusal answered 413 naming the bound. CONTROLS: exactly the bound read whole (declared and not); a body already read throughreq.bodyjudged against the bound once read.http-conformancerequest-body.conformance.test.ts— on both adapters over a real socket: body past the bound refused 413 (declared and not); escaped refusal answered 413; parity of the escaped answer's bytes. CONTROLS: exactly the bound read whole.service-storagestorage-limits.test.ts— local rawPUTand chunkPUTstate their bound and answer 413 with nothing stored and progress unchanged. CONTROLS: exactly the bound stored; nomax_upload_mbstates no bound.service-storagerecord-file-access.integration.test.ts— the upload-link door: bound held for one file with the link left unspent; the link judged before a byte is read (another user's link, a spent link: the body is never read); the several-file form held to the form limit. CONTROLS: a body within the bound lands; nomax_upload_mbstates no bound.Ablation (fix committed first, each mutation through
scripts/ablation-replace.mjs, restored to the HEAD blob withgit diff HEADempty):rawBody: 4 of the new storage cases red; restored.maxByteson the original body: the new transport describe red (the run did not complete); restored.Not ablated: the reference adapter's in-read stop (its answer is the same either way, since the post-read judgement also refuses; only the transport case measures bytes read).
Acceptance notes
max_upload_mbunset a byte door has no bound of its own, so it states none and reads the whole body, as before. What a door's bound should be then is a maintainer decision, reported to the seat as a fork.rawBodyand has a bound should pass it (rule stated in the contract).Verification
Final head
36ce94c0(after mergingorigin/main47a3b95):Touched packages: tests
@objectstack/plugin-hono-server— Test Files 42 passed · Tests 555 passed@objectstack/service-storage— Test Files 84 passed · Tests 1640 passed, 1 skipped@objectstack/hono— Test Files 14 passed · Tests 258 passed@objectstack/http-conformance— Test Files 20 passed · Tests 286 passedTypecheck and generated artifacts
typecheckforspec,plugin-hono-server,service-storage,http-conformance,hono,rest: exit 0, everycheck:test-typecheckOK.pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date.Derived gate families (dispatch-gates --commands, 93)
On
36ce94c0: 93 derived, 92 exit 0, 1 NOT MEASURED —node scripts/check-plugin-teardown-shape.mjs --self-testexit 3 (PREREQUISITE NOT MET: its fixture commit is outside this shallow clone).dispatch-gates --ranwith exit codes recorded: 93 accounted for, 0 UNRUN. Every other family CI runs is read from this PR's check-runs, not re-run locally.Generated by Claude Code