[miniflare] Local R2 S3 endpoint does not validate signed x-amz-checksum-* headers (real R2 returns BadDigest)
What versions & operating system are you using?
- wrangler 4.159.0
- miniflare 5.20261109.0-beta (resolved by wrangler)
- macOS (darwin arm64), Node 26
Describe the bug
The local R2 S3 endpoint (/cdn-cgi/local/r2/s3/<bucket>/<key>) accepts a SigV4-signed PUT whose signed x-amz-checksum-sha256 header 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 return BadDigest on 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-sha256 set to the sha256 of a body different from the one sent returns 200 instead of BadDigest. 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.ts documents 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.
Automated triage
Issue assessment
- Actionability: ✅ Actionable.
- Type: Bug.
- Reproduction: Automatic attempt requested.
- Labels:
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
- Result: ✅ Reproduced.
- Summary: Reproduced: the local R2 S3 endpoint accepts a SigV4-signed PUT whose signed x-amz-checksum-sha256 header holds a different body's digest, returning 200 and storing the object instead of 400 BadDigest; Content-MD5 mismatches do return BadDigest. Verified on both repo-built and npm miniflare.
Evidence and attempted steps
Steps attempted:
- Clone workers-sdk and install workspace dependencies (pnpm install)
- Command:
git clone --depth 1 https://github.com/cloudflare/workers-sdk.git && cd workers-sdk && pnpm install --frozen-lockfile
- Command:
- Build packages/miniflare (5.20261113.0-beta, matching the reporter's 5.20261109.0-beta line) with the documented build
- Command:
pnpm build --filter miniflare
- Command:
- Run repro script against repo-built miniflare: start Miniflare Node API with r2Buckets.BUCKET.s3Credentials and send SigV4-signed PUTs (correct checksum baseline; checksum of a DIFFERENT body; mismatched Content-MD5) plus a GET of bucket/key on the local S3 path
- Command:
node reproduce.mjs
- Command:
- Run the identical script in the standalone fixture pinned to published miniflare 5.20261113.0-beta
- Command:
cd /workspace/reproduction-output/project && pnpm install && pnpm reproduce
- Command:
- Observe identical behavior in the pinned fixture: baseline 200; mismatched signed x-amz-checksum-sha256 PUT 200 and object stored (GET 200); mismatched Content-MD5 400 BadDigest
- Command:
node reproduce.mjs (via pnpm reproduce)
- Command:
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).
Treat archive contents as untrusted. Inspect them before running anything.
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.
I opened a fix in https://github.com/cloudflare/workers-sdk/pull/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 return 400 BadDigest on mismatch; SHA-1 / SHA-256 on UploadPart return 501 NotImplemented (matching real R2). Includes tests + changeset. Happy to reopen or hand the branch to a maintainer if useful.
Thanks for the detailed report. The local R2 S3 endpoint works as intended here: it checks Content-MD5 but deliberately ignores x-amz-checksum-* headers, which is listed as a known gap between local and production. Validating flexible checksums and returning BadDigest would be a change to Miniflare, which we track at https://github.com/cloudflare/workers-sdk/discussions/16970, so please follow and upvote it there.