
When webhooks, ingestion pipelines, or mobile apps upload files directly to an S3-compatible bucket, proxying the upload through your web backend wastes server memory, ties up worker connections, and inflates cloud compute bills. Direct client-to-bucket uploads solve the bottleneck.
The vulnerability lies in how those upload URLs are generated. An unconstrained presigned PUT URL gives anyone who holds the link permission to upload up to 5 TB of arbitrary data—from ransomware binaries to multi-gigabyte disk-exhaustion bombs. Securing upload drops requires locking down Content-Type headers, enforcing strict size limits, and slashing token lifetimes.
Unconstrained vs hardened presigned upload drops
Here is what changes when you move from default SDK presigned PUT links to hardened, cryptographically enforced upload policies:
| Security control | Default presigned PUT (unconstrained) | Hardened webhook drop (enforced) | Risk reduction |
|---|---|---|---|
| Payload size limit | Up to 5 TB (bucket object limit) | 10 KB – 50 MB strict boundary | Prevents storage exhaustion denial-of-service |
| Content-Type validation | Ignored / unverified | Locked to expected MIME (e.g. application/pdf) | Blocks executable, script, and HTML uploads |
| URL expiration (TTL) | 24 hours (86,400 seconds) | 300 seconds (5 minutes) | Closes exposure window if URLs leak into logs |
| Tamper response | HTTP 200 OK (payload accepted) | HTTP 403 Forbidden (signature mismatch) | Immediate gateway refusal at the edge |
| Access key risk | Zero credentials exposed to client | Zero credentials exposed to client | Maintains zero-trust bucket architecture |
| Replay protection | Reusable until expiry timestamp | Single-use / tight 5-minute window | Prevents unauthorized object overwrites |
How SigV4 header locking works
AWS Signature Version 4 (SigV4) does not just sign the HTTP method and object key. It also calculates a signature over the list of headers specified in the <code>X-Amz-SignedHeaders</code> parameter:
- Content-Type signing: When your server includes
ContentType='application/pdf'during URL generation, S3 insertscontent-typeintoX-Amz-SignedHeaders. If the client tries to uploadbad.shastext/plainorapplication/octet-stream, the storage API immediately rejects the request with403 SignatureDoesNotMatch. - Exact size enforcement: Including
ContentLength=file_bytesforces the client to send that exact byte count. An attacker attempting to stream a 50 GB payload fails the header check. - Dynamic size boundaries: For clients where the exact size is not known in advance, S3 presigned POST policies enforce a strict range via
["content-length-range", 10240, 52428800](10 KB to 50 MB). - Short expiration TTL: Reducing token lifetime from the default 3,600s or 86,400s down to 300s (5 minutes) ensures webhook callbacks must use the URL immediately or request a fresh ticket.
Generating hardened presigned URLs in Python
Use the following Python implementation with <code>boto3</code> to generate signed PUT URLs with enforced Content-Type, Content-Length, and short expiration:
Testing attack scenarios with curl
We tested four curl scenarios against our hardened endpoint to verify rejection behavior:
Worked math: storage exhaustion bill shock
Suppose a rogue webhook actor or unauthenticated client discovers an open presigned upload drop that lacks size limits. Here is how quickly storage costs compound compared to an enforced 50 MB boundary:
| Attack volume | Payload size | Ingested storage | Monthly cost at $0.023/GB (AWS S3) | Hardened drop (50 MB limit) | Monthly cost with 50 MB cap |
|---|---|---|---|---|---|
| 100 uploads | 10 GB dumps | 1,000 GB (1.0 TB) | $23.00 / mo | 5.0 GB total | $0.12 / mo |
| 500 uploads | 50 GB dumps | 25,000 GB (25.0 TB) | $575.00 / mo | 25.0 GB total | $0.58 / mo |
| 2,000 uploads | 100 GB dumps | 200,000 GB (200.0 TB) | $4,600.00 / mo | 100.0 GB total | $2.30 / mo |
A strict 50 MB size ceiling neutralizes storage bill spikes by over 99.9%, while immediate 300-second token expirations prevent attackers from stockpiling reusable URLs.
Storage architecture on tport.space
<b>tport.space</b> provides high-performance, S3-compatible object storage with public files and zero egress fees. By combining S3 SigV4 presigned PUT drops for uploads with public buckets for downstream delivery, you build cost-effective file ingestion pipelines with zero per-gigabyte egress fees on downloads.
Check our companion guides for bucket caching and architecture best practices:
- Measure browser cache hit savings and conditional request overhead in Cache-Control on S3 images (
/articles/cache-control-s3-images-requests-bytes). - Compare signed URLs with public object storage in Presigned URLs or public files: how to share a bucket object without leaking a key (
/articles/presigned-urls-public-files-share-bucket-object). - Set up custom index pages, cache headers, and routing in Hosting a static site from a bucket: index pages, 404s and cache headers tested (
/articles/hosting-static-site-bucket-index-404-cache).
Secure your file drops and serve public files from S3-compatible storage with zero egress fees.
Deploy on tport.space