Repository navigation
[miniflare] Local R2 S3 endpoint does not validate signed x-amz-checksum-* headers (real R2 returns BadDigest) #16970
workers-devprod
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Moved from #16945. Originally opened by mynk-tmr on 2026-11-15.
What versions & operating system are you using?
Describe the bug
The local R2 S3 endpoint (
/cdn-cgi/local/r2/s3/<bucket>/<key>) accepts a SigV4-signed PUT whose signedx-amz-checksum-sha256header does not match the body. It returns 200 with the MD5 ETag and stores the object. Real R2 (and MinIO/S3) validate flexible checksums and returnBadDigeston mismatch.The header is included in the SigV4 signed headers, so the signature is valid — only the checksum is never checked against the body.
Repro
Any SigV4-signed PUT with
x-amz-checksum-sha256set to the sha256 of a body different from the one sent returns 200 instead ofBadDigest. I can attach a standalone Node script (aws4fetch + node:http) if useful.Actual result
200, object stored.
Expected result
400 BadDigest, matching real R2 behavior, so client code and integrity checks behave the same locally and in production.Context
packages/miniflare/src/workers/r2/s3/index.worker.tsdocuments this as a known gap ("Flexible checksums ... are silently ignored ... The aws-chunked content encoding ... is not decoded either"). Content-MD5 is verified. Filing because there is no tracking issue and checksum validation is an integrity/compat concern, not just a missing feature.workers-devprod commented on 2026-11-15:
Automated triage
Issue assessment
bug(high)package:miniflare(high)product:r2(high)Actionability and missing information
Local R2 S3 endpoint accepts SigV4-signed PUTs with a mismatched signed x-amz-checksum-sha256 header, returning 200 and storing the object where real R2 returns BadDigest; affected versions, expected and actual behavior, and a conceptual repro are provided.
Reproduction reason: The report describes a current-behavior defect in miniflare's local R2 S3 endpoint, where a signed PUT with a mismatched x-amz-checksum-sha256 header is accepted with 200 instead of BadDigest, with enough version and behavior detail to attempt reproduction.
Reproduction
Evidence and attempted steps
Steps attempted:
git clone --depth 1 https://github.com/cloudflare/workers-sdk.git && cd workers-sdk && pnpm install --frozen-lockfilepnpm build --filter miniflarenode reproduce.mjscd /workspace/reproduction-output/project && pnpm install && pnpm reproducenode reproduce.mjs (via pnpm reproduce)Expected behavior: A SigV4-signed PUT to the local R2 S3 endpoint whose signed x-amz-checksum-sha256 header does not match the request body returns 400 BadDigest and is not stored, matching real R2/S3 flexible-checksum semantics.
Observed behavior: The local S3 endpoint returned 200 and stored the object (subsequent GET returned the uploaded body). Baseline PUT with a correct signed checksum returned 200, and a mismatched Content-MD5 PUT correctly returned 400 BadDigest, confirming the endpoint functions and validates MD5 while ignoring signed flexible checksum headers.
Artifact: Download reproduction archive (Cloudflare Access required).
This summary was generated by an LLM and may contain errors. Please verify its findings.
Triage bot commands and options
Repository collaborators with write or admin access can trigger actions by commenting on this issue:
@workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.umeraamir69 commented on 2026-11-16:
I opened a fix in #16948 (auto-closed by the vouch gate).
Branch (fork): https://github.com/umeraamir69/workers-sdk/tree/fix/r2-s3-checksum-16945
Change: validate signed
x-amz-checksum-*(CRC32 / CRC32C / SHA-1 / SHA-256) against the body on the local R2 S3 PutObject/UploadPart path and return400 BadDigeston mismatch; SHA-1 / SHA-256 on UploadPart return501 NotImplemented(matching real R2). Includes tests + changeset. Happy to reopen or hand the branch to a maintainer if useful.All reactions