Repository navigation
fix(s3): enforce content-length-range in presigned POST policies - #1449
Merged
ferhatelmas merged 2 commits intoSep 28, 2026
Merged
ferhatelmas merged 2 commits into
ferhatelmas merged 2 commits into
Conversation
A signed POST policy's content-length-range condition was recognized but not enforced, so an upload of any size up to the bucket limit was accepted. The range now narrows the upload's size limit, and a file below its minimum is rejected with EntityTooSmall before it is stored. Malformed ranges are rejected as invalid policies.
Signed-off-by: Ferhat Elmas <[email protected]>
ferhatelmas
force-pushed
the
feat/post-policy-content-length-range
branch
from
September 28, 2026 18:48
5edb691 to
b219e87
Compare
ferhatelmas
approved these changes
Sep 28, 2026
ferhatelmas
left a comment
Member
There was a problem hiding this comment.
Good initial implementation but updated to include:
- don't parse policy again, use from signature
- similarly snapshot for multipart
- use last range if multiple as s3
- use coercion as s3
- some test hardening
Coverage Report for CI Build 36467765022Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.02%) to 83.659%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions17 previously-covered lines in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
4 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
S3 compatibility fix: follow-up to the TODO left in #1211.
What is the current behavior?
content-length-rangein a presigned POST policy is recognized but ignored (policy.ts: "recognized but NOT enforce yet"). Uploads of any size up to the bucket or global limit are accepted, even when the signed policy allows only 10–100 bytes.What is the new behavior?
EntityTooLarge(413), through the sameByteLimitTransformStreamthat already enforces the bucket limit.EntityTooSmallerror (400, as S3 returns). The check runs in the stream's_flush, so the upload fails before the object is stored.min > max, non-integer, or a missing bound) is rejected asInvalidSignature, like other unsupported conditions.Tests
policy.test.ts): range extraction, intersection, and each malformed shape.s3-protocol.test.ts), presigned POST with['content-length-range', 10, 100]: 50 bytes → 200; 101 bytes → 413 and nothing stored; 9 bytes → 400EntityTooSmalland nothing stored. Without the change, the 101-byte and 9-byte cases fail.s3-protocol.test.ts(129 tests) and the full unit suite (2476) pass locally. Lint andtscare clean.I use AI assistance when working on patches, and I check and test everything before submitting.