fix(security): close Content-Length bypass in multipart upload size g… - #1117
Merged
RUKAYAT-CODER merged 1 commit intoJul 28, 2026
Merged
Conversation
|
@AbuJulaybeeb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…uard - Refactored the file size guard in main.ts to enforce stream-level byte counting. - Missing or unparseable Content-Length requests without chunked encoding are now rejected with 411 Length Required. - Added a counting stream guard that destroys the request if actual payload bytes exceed the limit. - Updated multer config in upload-validation.util.ts to dynamically read FILE_UPLOAD_MAX_BYTES. - Added e2e tests for chunked upload bypassing and understated Content-Length scenarios. Closes rinafcode#989
AbuJulaybeeb
force-pushed
the
feat/close-content-length-bypass
branch
from
July 28, 2026 16:52
9e1f4ca to
7a8dab6
Compare
Contributor
|
Thank you for contributing to the project. |
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.
Fixes #989
**: Closes a security bypass in the multipart upload size guard where missing, unparseable, or manipulated
Content-Lengthheaders would allow arbitrarily large files to be uploaded into memory.Security Mitigations & Changes
src/main.tsGuard Refactor:Content-Lengthclaim, we now enforce a stream-level counting guard that intercepts data chunks in real-time as they are consumed.bytesReadexceed the configuredFILE_UPLOAD_MAX_BYTESlimit, the request is immediately aborted viareq.destroy(), completely stopping the flow and preserving process memory.Content-Lengththat lackTransfer-Encoding: chunkedare immediately rejected with411 Length Required.src/media/validation/upload-validation.util.tsUpdate:MEDIA_UPLOAD_INTERCEPTOR_OPTIONS) to dynamically parse and enforce the environment variableFILE_UPLOAD_MAX_BYTESdirectly, ensuring consistency between Express middleware and Multer.test/security/upload-bypass.e2e-spec.ts):Content-Length.