Skip to content

fix(service-storage): stored bytes are previewed in place only when they begin with their type's signature - #36768

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/sec1-865p-r4
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/sec1-865p-r4

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户在附件、文件下载里打开文件时:内容与其类型相符的图片、PDF、纯文本、音视频照常在浏览器里直接预览;内容与所标类型不符的文件改为下载到本地。
  • 这是文件存储加固的后续一步:本地存储发出文件时再核对一次文件内容的开头,确认它真是所标的那种文件。
  • 正常文件不受影响;若有人上传了内容与类型不符的文件,打开时会变成下载而不是预览。可以整体撤回本改动。
  • 要你做什么:无。

What changes

One more condition on the stored-bytes rule in packages/services/service-storage/src/served-bytes-policy.ts, applied by the local adapter's raw byte route:

  • Rule 4: an allow-listed type is previewed in place only when the stored bytes begin with that type's leading signature. Any other body, an empty one included, is answered as an attachment, with nosniff and the default sandbox policy. The answered type and file name do not change.
  • LEADING_SIGNATURES holds one test per type on INLINE_CONTENT_TYPES: PNG, JPEG, GIF, WebP, AVIF (by its brand), BMP, PDF, and each of the 13 audio and video types (MPEG audio, MP4, AAC, Ogg, the three WAV spellings, WebM, FLAC, QuickTime).
  • Plain text has no signature. Its test is the WHATWG MIME Sniffing standard's text-or-binary rule: the body opens with a byte-order mark, or its first 1445 bytes carry no binary data byte.
  • A type on the allow-list with no table entry is never inline, and a pin holds the table and the list equal.
  • Every signature is judged on a fixed leading window of the body, LEADING_WINDOW (1445 bytes, the plain-text test's window). The body is cut to that window before any test runs. The ftyp brand scan also stops at a fixed slot count (the major brand plus 31 compatible brands), whatever size the box states.
    • A box shorter than 16 bytes by its own size field carries no brand.
    • The minor-version slot is never read as a brand.
    • Each signature's bytes are built once, when the table is built.
  • The raw route already holds the whole body before it writes headers, so the check reads nothing extra. The S3 signed URL and the upload door are unchanged.
  • Module prose: rule 3's sandbox policy is described as what it asks the browser for. No rule rests on any answer being rendered as an opaque-origin document; the rules rest on the allow-list, nosniff and the signature.

Files to read first, by risk:

  1. served-bytes-policy.ts: LEADING_WINDOW, ftypBrand with FTYP_SCAN_END, the LEADING_SIGNATURES table and bytesBeginWithTheirTypeSignature. This is the hunk that decides preview or download, and how much of the body is read to decide it.
  2. served-bytes-policy.ts, servedBytesHeaders. The signature verdict demotes the disposition before the CSP is chosen, so a demoted media answer gets the default policy.
  3. storage-routes.ts, the raw GET handler, which now passes the body it holds.

Tests

Package suite, typecheck, and reverse verification at 208f25e
  • pnpm --filter @objectstack/service-storage test at 208f25e: Test Files 88 passed (88), Tests 1742 passed, 1 skipped. Lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/service-storage typecheck at 208f25e: lock VERDICT command-exit 0. This includes check:test-typecheck over the test file.
  • src/served-bytes-policy.test.ts: 30 tests, all green. The pins state the rule only:
    • the signature table covers every allow-listed type, the 13 audio and video types among them;
    • each type matches its own leading bytes, and an empty body matches none;
    • every alternate a type accepts is pinned with one head it accepts and one it refuses: MPEG audio with no ID3 tag, ADTS, ADIF and ID3 under AAC, GIF87a, each of the five classic QuickTime atoms, AVIF by its major or only a compatible brand, the minor-version slot, a box too short to carry a brand, and all three byte-order marks for plain text;
    • an ftyp brand counts only inside the fixed scan window, whatever size the box states;
    • a body is judged on its first LEADING_WINDOW bytes, whatever its length. Every signature test is handed at most that many bytes;
    • a body without its signature is an attachment under the default policy, media types included;
    • through the real raw GET handler: a raster file whose bytes lack its signature downloads and one that begins with it previews; the same for audio or video (the mismatch gets the default policy, the match gets the media policy); the same for plain text.
  • Reverse verification. Every mutation went through scripts/ablation-replace.mjs on committed code. Each anchor hit 1 to 0, and each was restored with the blob equal to HEAD and git diff HEAD empty.
    • Signature verdict removed from servedBytesHeaders: 4 failed, 23 passed, at da5f684.
    • One table entry removed: 2 failed, 25 passed, at da5f684.
    • Brand-scan slot clamp removed: 1 failed, 29 passed (the scan-window pin), at 208f25e.
    • Leading-window cut removed: 1 failed, 29 passed (the leading-window pin), at 208f25e.
  • Existing route fixtures that expect a preview now upload bytes that carry their type's signature. The dogfood and live E2E pins of fix(service-storage)!: stored bytes outside the inline allow-list are served as attachments, with nosniff and a sandbox CSP #36518 already used real PNG, PDF, WAV and text bytes, so they are untouched.

Acceptance notes

  • content/docs/permissions/attachments-access.mdx ("How a downloaded file is answered") still describes the allow-list as the condition for a preview. That stays true, but it does not mention the new signature condition. The doc is outside this PR's file surface, so it is left for the owning seat.

Verification

Two-minute check: pnpm --filter @objectstack/service-storage exec vitest run --maxWorkers=2 src/served-bytes-policy.test.ts. Expect 30 passed. Removing the signature verdict line in servedBytesHeaders should turn 4 of them red.

Local gates: the 73 families derived by dispatch-gates --commands ran at 208f25e, the final head. 71 exited 0. Two refused on a missing prerequisite (exit 3), so they are NOT MEASURED locally and CI runs them: check:dual-build-cjs-loads and check:i18n, which both need a whole-workspace build.


Generated by Claude Code

…hey begin with their type's signature

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASNY8XNef4ywkQio6S9ju4
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-storage, touching 20 documentable anchor(s).

7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/data-modeling/field-type-decision-tree.mdx (via TEXT (symbol, a top-level const))
  • content/docs/deployment/cli.mdx (via TEXT (symbol, a top-level const))
  • content/docs/frontend/plugin-development.mdx (via TEXT (symbol, a top-level const))
  • content/docs/getting-started/common-patterns.mdx (via TEXT (symbol, a top-level const))
  • content/docs/protocol/kernel/i18n-standard.mdx (via TEXT (symbol, a top-level const))
  • content/docs/protocol/objectql/query-syntax.mdx (via TEXT (symbol, a top-level const))
  • content/docs/protocol/objectql/types.mdx (via TEXT (symbol, a top-level const))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-3.mdx (via TEXT (symbol, a top-level const))
  • content/docs/releases/v17/17-5.mdx (via TEXT (symbol, a top-level const))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 68 of 251 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 7e586a9da4e610a118d842576c3af9ed6efe805a → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8f895798a9bd09a6f09bbb73d3aa0f534cf5decd — the merge of head 208f25e01f9451835e986e86abce0a90421be4dd into base 7e586a9da4e610a118d842576c3af9ed6efe805a, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8f895798a9bd09a6f09bbb73d3aa0f534cf5decd && git checkout 8f895798a9bd09a6f09bbb73d3aa0f534cf5decd
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7e586a9da4e610a118d842576c3af9ed6efe805a 208f25e01f9451835e986e86abce0a90421be4dd && git checkout -B drift-repro 7e586a9da4e610a118d842576c3af9ed6efe805a && git merge --no-ff 208f25e01f9451835e986e86abce0a90421be4dd

node scripts/docs-audit/affected-docs.mjs --json 7e586a9da4e610a118d842576c3af9ed6efe805a

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 7e586a9da4e610a118d842576c3af9ed6efe805a → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-mickey · session_01ASNY8XNef4ywkQio6S9ju4

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 5c24001e7d527c12d403e4edd05d52722d0e42ad
Local-runs: probe — timed a scratch copy of one signature helper on synthetic buffers to grade M1; nothing in the repo was built, run or re-run
Scope: packages/services/service-storage/src/served-bytes-policy.ts, packages/services/service-storage/src/storage-routes.ts, packages/services/service-storage/src/served-bytes-policy.test.ts, .changeset/sec1-865p-r4.md (② only) + read, not reviewed: packages/services/service-storage/src/index.ts, packages/services/service-storage/package.json, packages/services/service-storage/src/local-storage-adapter.ts, packages/services/service-storage/src/s3-storage-adapter.ts, packages/services/service-storage/src/record-file-access.ts, packages/spec/src/contracts/storage-service.ts, packages/qa/dogfood/test/stored-bytes-served-disposition.dogfood.test.ts
Security-touching: yes
Rule-change-verified: none

Inputs: the maintainer's ruling as the seat recorded it, the PR body, the file list (4 files, +247 −27) and the net diff against main, and the head's check-runs. Judged on the tree at the head.

Check-runs on this head, 52 in all: 28 success, 16 skipped, 8 still running (Test Core shards 1 to 8 of 10); none failed. Two roll-ups read success over skipped members: the Dogfood Regression Gate shards and Build & E2E UI did not run on this head, so the real-boot pin the test header cites is not a gate verdict here. Read, not run: its fixtures are genuine PNG, PDF, WAV and text bytes, so it reads green against the diff.

① Derived judgments

  • Package surface: unchanged. Right. package.json exports only ., and src/index.ts re-exports nothing from served-bytes-policy.ts. LEADING_SIGNATURES, bytesBeginWithTheirTypeSignature and the new required bytes member of servedBytesHeaders are module exports for the route and the test file, unreachable from the entry. index.ts is not in the diff.
  • Internal signature: servedBytesHeaders now requires bytes. Right. One caller exists (the raw GET handler); it passes the buffer it then sends. A required member means a later caller cannot compile without it.
  • HTTP answer of GET …/_local/raw/:token: status, body, content-type, file name and nosniff unchanged; content-disposition and content-security-policy now also follow the body. Right as ruled. No request that was accepted is refused. The set of answers that read inline shrinks; that is an answer changing, not an accept-set narrowing, and the published wording already calls inline "a request, not a verdict" (PresignedDownloadOptions.disposition).
  • Upload doors: accept-set unchanged. Right. The ruling did not take the refusal at upload.
  • S3 signed URL: unchanged. Right. The ruling did not take the S3 contract change; the module prose scopes rule 4 to a door that holds the bytes when it answers.
  • Metadata protocol: nothing an author can write changes. Metadata-protocol: none is right.

② Semver level

@objectstack/service-storage: patch, one package, and the diff moves only that package's runtime code: right for a fix with Metadata-protocol: none. Clause-②: no is right: no accept-set widens and no public surface grows, and the unsuffixed form is right too, since nothing a caller or author may send is refused (① third bullet). Both declaration lines stand line-initial in the changeset and in the PR body. The changeset states the rule and nothing else. One wording nit is N3 below.

③ Boundary flags

  • (a) Plain text is judged by the WHATWG text-or-binary test and does not refuse markup. Answered: holds. Plain text has no signature, so the ruling's sentence has no literal reading for it. Of the three readings open (never inline, always inline, the standard's text test), the dev's is the only one that keeps both ruled outcomes: a mismatched body downloads and a matching one previews. Markup under text/plain is text by rule 2; refusing text that looks like markup would rebuild a sniffing heuristic and demote ordinary source and log files. It is the one place the diff had to interpret the ruling; the changeset says so in plain words, which is where the approver reads it.
  • (b) An empty body is never inline. Answered: holds. An empty body has no leading bytes; the ruling's "otherwise" covers it. It is stricter than the standard (which reads an empty resource as text) and costs only the preview of an empty file. Pinned for all 21 types.
  • (c) Every allow-listed type has a signature, no exemptions. Answered: holds. It is the ruling's own word for the 13 media types. The table and the list are pinned equal in both directions, and a type with no entry fails closed.
  • SQL push-down: not applicable. The diff holds no query, no id materialisation and no in-app join.
  • Author: objectstack-fleet[bot].

④ Design judgment

Against the ruling, sentence by sentence:

  • "serves an allow-listed type inline only when the stored bytes' leading signature matches it": the route judges the same buffer it sends, before any header is written, and the verdict feeds both headers. Holds for 20 of the 21 entries. It does not hold for image/avif: see M1.
  • "Otherwise the answer is an attachment": holds. The demotion happens once, ahead of the disposition and the policy, so a demoted audio or video answer carries the default policy and not the media one; type, name and nosniff are unchanged. Pinned for every type at the header function and for raster, text, audio and video through the real handler.
  • "a serve-time check, not at the upload door": holds. No upload path is in the diff.
  • The ordered pins: a mismatched type that downloads and a matching one that previews (raster, text); a mismatched audio and a mismatched video type; a table over all 13 media types (toHaveLength(13) plus set equality). All present.
  • "about 120 lines": 111 added source lines across the two source files. In order.
  • Other doors: the raw byte route is the only door that answers stored bytes on the app origin. GET /files/:fileId redirects to it, /files/:fileId/url answers JSON, and the record-file service hands bytes in-process. HEAD reaches the same handler.

Findings:

  • M1 (must-fix) — the image/avif test (ftypBrand) is not held to a fixed leading window, unlike every other entry (1445 bytes at most). The rule is a leading signature: hold the test to a fixed leading window, build the brand bytes once, and pin both halves (a brand outside the window does not match; a stated box length past the window does not widen what is read). Detail is in the reviewer's local note.
  • S1 (should-fix) — the pins execute one alternate per type. No test runs the MPEG frame-header test (an MP3 with no ID3 tag, the commonest real form), ADIF or ID3 under audio/aac, GIF87a, the five classic QuickTime atoms, AVIF named only by a compatible brand, the skipped minor-version slot, or two of the three byte-order marks. A regression in any of these would turn genuine files into downloads, or loosen a test, with no red. A small table of one accepted and one refused head per alternate closes it.
  • N1 (nit) — the two frame-header tests read two bytes, as short as the standard's own BM; the standard's pattern for the same type reads a whole header and confirms a second frame. Leading signatures are the ruling's choice, so this is recorded and not graded higher; detail in the local note.
  • N2 (nit, accepted deviation) — genuine files that now download because their head is not the canonical one: an MP3 with padding ahead of its first frame, a PDF with bytes ahead of its header, UTF-16 text with no byte-order mark, an empty text file, an RF64 WAV, a FLAC behind an ID3 tag, an MP4 or MOV that opens with an atom the table does not list. Each fails to the safe side, as the ruling orders.
  • N3 (nit) — the changeset says plain text "carries no binary data byte"; the test reads the first 1445 bytes. The PR body states the window; the changeset is the text that ships.
  • N4 (nit, prose face, the owning seat's) — content/docs/permissions/attachments-access.mdx and the jsdoc on PresignedDownloadOptions.disposition state the allow-list as the condition and are silent on the new one. Both stay true as written; the PR body carries it as an acceptance note.

One must-fix, one should-fix.

Implemented-by: claude/sec1-865p-r4
Reviewed-by: session_01ASNY8XNef4ywkQio6S9ju4

VERDICT: FAIL

…g window of the bytes

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASNY8XNef4ywkQio6S9ju4
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-mickey · session_01ASNY8XNef4ywkQio6S9ju4

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 208f25e01f9451835e986e86abce0a90421be4dd
Local-runs: none
Scope: packages/services/service-storage/src/served-bytes-policy.ts, packages/services/service-storage/src/storage-routes.ts, packages/services/service-storage/src/served-bytes-policy.test.ts, .changeset/sec1-865p-r4.md (② only) + read, not reviewed: packages/services/service-storage/src/index.ts, packages/services/service-storage/package.json, packages/services/service-storage/src/local-storage-adapter.ts, packages/services/service-storage/src/s3-storage-adapter.ts, packages/services/service-storage/src/record-file-access.ts, packages/spec/src/contracts/storage-service.ts, packages/qa/dogfood/test/stored-bytes-served-disposition.dogfood.test.ts
Security-touching: yes
Rule-change-verified: none

Delta review. The prior record is the FAIL at 5c24001e7d527c12d403e4edd05d52722d0e42ad (M1, S1, N1 to N4). Judged here: the one commit between the two heads (3 files, +116 −23: the policy module, its test file, one changeset sentence), plus the parts of the net diff against main it touches. storage-routes.ts is not in the delta. Inputs: the maintainer's ruling as the seat recorded it, the PR body, and the head's check-runs.

Check-runs on this head, 57 in all: 39 success, 18 skipped, none failed, none running. Test Core (6/10) failed on the first attempt with a hook timeout in a @objectstack/cli integration test (data-commands.absent-database.integration.test.ts, a file outside the diff) and passed on the re-run; Test Core reads success on attempt 2. The package's suite ran on shard 9 of 10: served-bytes-policy.test.ts 30 tests green, 88 files passed. As on the prior head, the Dogfood Regression Gate shards and Build & E2E UI were skipped under roll-ups that read success, so the real-boot pin is not a gate verdict here; the delta does not touch what it reads.

① Derived judgments

  • Package surface: unchanged. Right. LEADING_WINDOW is a new module export, imported by the test file only. src/index.ts is not in the delta and re-exports nothing from the module.
  • Internal signatures: unchanged. Right. bytesBeginWithTheirTypeSignature and servedBytesHeaders keep their shape; the route's call is untouched and still passes the body it sends.
  • HTTP answer of GET …/_local/raw/:token: the verdict now depends on the first 1445 bytes of the body only. Right as ruled. Against the prior head, the verdict of 20 of the 21 types is the same for every body: no fixed-offset test reads past byte 12, and plain text was already read to 1445. Only image/avif moves, and only to the attachment side, for two malformed shapes: a box whose size field reads under 16, and a file whose brand is named only past the scan's fixed reach. No request that was accepted is refused.
  • Upload doors, S3 signed URL, metadata protocol: untouched by the delta.

② Semver level

@objectstack/service-storage: patch stands: the delta moves only that package's runtime code and tightens one answer. Clause-②: no and Metadata-protocol: none stand, line-initial in the changeset and in the PR body. The changeset's one new sentence states the 1445-byte window for plain text and that every type is judged on that same leading window: a rule, and it closes N3.

③ Boundary flags

  • Prior flags (a) plain text by the text-or-binary test, (b) an empty body is never inline, (c) every allow-listed type has a signature: the delta changes none of them. Each still holds.
  • (d) One window for every type, 1445 bytes. Answered: holds. The ruling says "leading signature" and names no length. The standard's resource header is the one length the module already used, and it is at least what every entry needs: the longest fixed test reads 12 bytes, the brand scan 136, plain text 1445. No entry needs more than the cut hands it.
  • (e) A box shorter than 16 bytes by its own size field carries no brand. Answered: holds. A file-type box holds a major brand and a minor version before any compatible brand, so 16 is its floor. The two special values of the size field (0 and 1) fall under the same refusal; for a leading file-type box neither is a form a genuine AVIF takes, and the answer is the safe side.
  • (f) The brand scan stops at a fixed slot count, whatever size the box states. Answered: holds. The reach is the least of the box's stated end, the head's end and offset 136. The stated count is off by one: see N5.
  • SQL push-down: not applicable. The delta holds no query, no id materialisation and no in-app join.
  • Author: objectstack-fleet[bot].

④ Design judgment

Against the ruling, "serves an allow-listed type inline only when the stored bytes' leading signature matches it": at this head it holds for all 21 entries. bytesBeginWithTheirTypeSignature, the one entry point servedBytesHeaders calls, cuts the body to LEADING_WINDOW before it looks up any test; the cut is a view, not a copy. The two tests that scan (the brand test and plain text) are each bounded on their own as well, so the rule does not rest on the cut alone. "Otherwise the answer is an attachment": unchanged by the delta, and still pinned for every type.

The window, tried at its edges:

  • The cut hands indices 0 to 1444. The plain-text test's own window equals the cut, so its inner bound is a no-op under the door and a guard if an entry is ever called directly. The first byte outside the window is pinned as not read (index 1445).
  • The brand scan reads slots at offsets 8 to 132 in steps of 4 and skips offset 12. A brand at 132 counts and one at 136 does not; both are pinned, with the size field at its maximum. A slot counts only when all 4 of its bytes are inside the reach, so a size that is not a multiple of 4 does not admit a partial slot.
  • Size field: under 16 is refused before the scan (pinned at 12); 16 with the brand in the major slot is accepted (pinned).
  • Each signature's bytes are built when the table is built: at, RIFF, the brand list and the byte-order marks all close over a prebuilt array.

Prior findings:

  • M1: closed. Every test is handed a fixed leading window, the brand scan has its own fixed reach, the brand bytes are built once, and both halves are pinned: a brand outside the window does not match (an ftyp brand counts only inside the fixed scan window…), and a stated box length past the window does not widen what is read (the same pin, and a body is judged on its first LEADING_WINDOW bytes…, which also asserts that all 21 tests are handed at most the window).
  • S1: closed. One table now runs every alternate with one accepted and one refused head: an MPEG frame header with no ID3 tag (refused once on the layer bits and once on the version bits), ADTS, ADIF and ID3 under audio/aac, GIF87a, each of the five classic QuickTime atoms, AVIF by avis as major brand and by avif as a compatible brand only, the minor-version slot not read as a brand, and all three byte-order marks, each followed by a binary data byte so the mark is what decides.
  • N1 (nit): unchanged; stands as recorded.
  • N2 (nit, accepted deviation): unchanged; flags (e) and (f) add two malformed AVIF shapes to the same safe side.
  • N3: closed by the changeset sentence.
  • N4 (nit, prose face, the owning seat's): unchanged; the PR body still carries it as an acceptance note.

New in this round:

  • N5 (nit) — the stated reach of the brand scan is one more than the code's. FTYP_SCAN_END = 8 + 4 * 32 covers the major brand, the minor-version slot and 30 compatible brands; the jsdoc on the constant and the PR body both say 31. The pin sits on the code's edge (132 in, 136 out), so code and test agree and only the wording is off. Say 30, or move the constant to the count that was meant.
  • N6 (nit) — two bounds are pinned from one side only. No pin places a wanted brand between a short box's stated end and the scan's reach, so the box-end term of the minimum could be dropped with no red. No pin puts a binary data byte in the last position inside the plain-text window (index 1444), so a shorter window would stay green; the changeset now publishes 1445.

No must-fix, no should-fix.

Implemented-by: claude/sec1-865p-r4
Reviewed-by: session_01ASNY8XNef4ywkQio6S9ju4

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-mickey · session_01ASNY8XNef4ywkQio6S9ju4

席位记录 · ACCEPT · head 208f25e01f9451835e986e86abce0a90421be4dd

维护者速读

  • 改了什么:本地存储发出文件时,只有内容开头确实是所标类型的白名单文件(图片、PDF、纯文本、音视频)才在浏览器里直接预览;内容与类型不符的一律改为下载,并使用最严的默认沙箱策略。
  • 为什么:落实安全席位高危公告的后续项,维护者已裁定的方案 C(原话「865p C」)。
  • 若出错:只会让少数内容不规范的文件从预览变成下载;上传与 S3 不受影响。可整体撤回。
  • 要你做什么:请批准当前 head 208f25e0(签名契约审核 PASS:本 PR 上的 delta 记录,前一轮 FAIL 记录 7108961907 的 M1、S1 已关闭)。你在会话里回复同意后,由席位翻 ready、挂 auto-merge 落地。

席位意见:ACCEPT。完整 L2 一轮(FAIL)与 delta L2(PASS)均在案,独立对抗复核提出的唯一问题已在本 head 修复。

席位核对

  1. 形态: draft PR,基于 main,无卡。只改 @objectstack/service-storage(patch)的规则模块、本地原始字节路由与测试,外加一个 changeset;Clause-②: no、Metadata-protocol: none,两轮 L2 均判成立。
  2. 前提实测: 新规则测试在修复前为红、修复后为绿;撤掉签名判定、撤掉固定窗口或扫描上限,对应的钉子都会变红(PR 正文列出计数)。
  3. 门禁: 本 head 57 项 check:39 成功、18 跳过、0 失败。Test Core (6/10) 首次因与本 diff 无关的 CLI 集成测试钩子超时失败,经中继重跑一次后通过。
  4. 接受的偏差: 纯文本按 WHATWG 文本/二进制规则判定、不拒标记;空文件一律下载;若干内容开头不规范的真实文件会改为下载(N2)。余下 nit N1、N4、N5、N6 记录在 L2 记录中,不阻塞。
  5. 范围外去向,Skills-docs:: S3 签名链接不在裁定范围内(A 方案搁置);content/docs/permissions/attachments-access.mdx 未提新条件但仍然成立,由席位另行跟进。未触及 skills/**。
  6. 落地条款: 维护者批准当前 head 后,席位执行 pr_ready + automerge_enable;head 若再移动,须重新取得同形 L2 PASS。合并后公告仍为草稿,台账记合并。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-mickey · session_01ASNY8XNef4ywkQio6S9ju4

Landing · head 208f25e01f9451835e986e86abce0a90421be4dd (2026-11-23T21:14Z)

  • Approval (provenance): who: the maintainer (account os-mickey); what, verbatim: 「以上都同意」, answering the seat's request to approve head 208f25e0 (ACCEPT 7112730348); where: the security#1 Claude Code session session_01ASNY8XNef4ywkQio6S9ju4.
  • Pre-landing reads: head unchanged since the ACCEPT; check-runs 39 success, 18 skipped, 0 failed; mergeable_state clean; file list holds no governed path; 367 changed lines (under the 3,000 human-merge line). Contract review PASS on this head: 7112667330.
  • Action: relay pr_ready + automerge_enable. The merge queue lands it.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 21:15
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit d59d875 Nov 23, 2026
86 of 88 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/sec1-865p-r4 branch November 23, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants