Amazon S3 is easy to set up and equally easy to misconfigure. Direct user file uploads introduce major security risks if not properly restricted.
10 S3 Upload Security Flaws to Avoid
- Public Buckets: Leaving bucket policies open. Always enable Block Public Access at the account level.
- Trusting Client Content-Type / File Extension: Extensions like
invoice.pdfcan be manipulated. Perform server-side MIME type detection on byte content. - Weak Presigned URLs: Using presigned GET/PUT with long expiry times and no file size constraints. Use presigned POST policies enforcing
content-length-range. - Missing File Size Restrictions: Malicious users could upload 100 GB files, exhausting your budget.
- No Malware Scanning: Uploaded files could contain malware. Implement scanning tools like GuardDuty Malware Protection for S3.
- Predictable Key Paths: Sequential file paths like `uploads/1001.pdf` enable enumeration. Use UUIDs.
- Serving Uploads from Main Domain: Malicious HTML/SVG uploads executed on your primary domain can steal cookies/tokens. Serve user content from a separate domain (e.g. `user-content.com`).
- Overly Broad IAM Roles: Granting `s3:*` instead of restricting access to specific buckets and prefixes.
- Wildcard CORS Policies (`*`): Permitting unauthorized origins to execute cross-site requests.
- Unencrypted Bucket Storage: Ensure KMS server-side encryption and bucket versioning are enabled.
How does your app validate uploads today?
LinkedIn Post Snippet & Hashtags
Share this key insight directly with your LinkedIn network: