Skip to content

fix(cas): reject short/torn uploads and report honest write status - #35

Open
b7r6 wants to merge 2 commits into
mainfrom
b7r6/cas-integrity-unified
Open

b7r6 wants to merge 2 commits into
mainfrom
b7r6/cas-integrity-unified

Conversation

@b7r6

@b7r6 b7r6 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

What and why

Lane A stability fix from the findings catalog (see nativelink-findings-2026-10-05.csv
on the meta/findings-catalog-2026-10-05 branch), rebased onto OSS main
@bf4b3aa855. This fork PR exists to validate the change on CI that is
representative of upstream PR lanes (public read-only cache, same endpoints)
before any upstream submission.

How was this verified?

The branch carries its own regression tests (fails-without where the fix
class allows it — see the branch's test commits). This PR's purpose is the
full representative CI run; green here rehearses the exact checks an
upstream PR would face.

Risk

Fork-internal validation PR; nothing lands anywhere by merging this. The
underlying fix's risk assessment happens at upstream-submission time.

AI assistance

Agent-assisted pipeline (Claude) for rebase and PR mechanics under my
direction; the fix itself carries verification in its tests.

@github-actions

This comment has been minimized.

@b7r6
b7r6 force-pushed the b7r6/cas-integrity-unified branch 2 times, most recently from 30462da to fdd0a68 Compare October 7, 2026 20:28
b7r6 and others added 2 commits October 7, 2026 23:07
… size

A ByteStream Write that sets finish_write=true before sending the full
size declared in its resource name was accepted as a complete upload: the
handler returned OK with committed_size equal to the full declared size,
the blob then showed as present in FindMissingBlobs, and Read served the
truncated bytes under a digest they do not hash to -- silent CAS content
corruption.

Both the streaming path (process_client_stream) and the oneshot path
(inner_write_oneshot) only guarded the too-many-bytes case and committed
on finish_write without checking that the received byte count equalled the
declared size. A VerifyStore-fronted write path catches this on EOF, but an
unverified store tier (filesystem/memory fast tier) commits the partial.

Reject finish_write with InvalidArgument when bytes_received != expected_size
in both paths. The compressed path already verifies decoded size and digest.

Also fixes a latent same-class defect in max_decoding_message_size_test,
whose success case declared a size that did not match the bytes it sent and
only passed because of this bug.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Unifies the handler-level short finish_write rejection (N13, e5d1b0d)
with two further CAS-integrity fixes for the same disclosure (TRA-1373):

- filesystem_store: refuse to emplace a blob whose byte count disagrees
  with an ExactSize upload hint. A torn/aborted upload stream closes the
  writer half, which arrives at the store as a clean EOF; without this
  commit-point guard the partial bytes are stored under the full digest
  key regardless of any handler check (finish_write never arrives on the
  abort path).
- bytestream_server: QueryWriteStatus clamps committed_size to the
  declared digest size (the filesystem store reports block-rounded
  on-disk footprint, e.g. 17 -> 4096) and only reports complete once the
  store holds at least that many bytes, instead of unconditional
  complete=true.

Regression tests:
- short_finish_write_is_rejected_and_not_committed (oneshot path, N13)
- short_finish_write_is_rejected (streaming multi-message path)
- aborted_mid_stream_upload_is_not_committed (EOF without finish_write;
  only the store-level guard can catch this)
- max_decoding_message_size_test updated: it asserted the old
  short-upload-accepted behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@b7r6
b7r6 force-pushed the b7r6/cas-integrity-unified branch from fdd0a68 to 5a7d252 Compare October 8, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant