+2
−1
+195
−2
+1
−14
Loading
Add defense-in-depth limits to multipart/form-data parsing for POST object
to prevent DoS attacks via oversized uploads:
- MAX_FORM_FIELD_SIZE: 1 MB per field (matching MinIO)
- MAX_FORM_FIELDS_SIZE: 20 MB total for all form fields
- MAX_FORM_PARTS: 1000 maximum parts
- MAX_POST_OBJECT_FILE_SIZE: 5 GB for file content (matching S3 single PUT limit)
Why buffering instead of streaming:
A pure streaming solution using FileStream was initially attempted, but it
breaks compatibility with s3s-proxy and other consumers that use the AWS SDK.
The AWS SDK requires a known Content-Length to compute SHA-256 checksums for
SigV4 request signing. Since FileStream returns an unknown remaining length,
the SDK throws UnsizedRequestBody errors.
MinIO can accept streaming POST uploads directly because its HTTP server
parses multipart boundaries at the protocol level without needing size upfront.
However, when requests are proxied through s3s-proxy using the AWS SDK, the
SDK's cryptographic signing algorithm requires the body size before transmission.
The buffering approach with size limits provides:
1. Protection against unbounded memory allocation (DoS mitigation)
2. Compatibility with AWS SDK-based consumers (s3s-proxy, etc.)
3. Known content length for downstream request signing
Fixes #370
Signed-off-by:
Kefu Chai <tchaikov@gmail.com>