Are Presigned URLs Safe for Image Uploads in My App?

0
18
Asked By CuriousCoder42 On

Hey everyone! I'm new to AWS and I'm working on a mobile app with a serverless backend. The app has features like user profiles and profile images. When a user wants to upload a profile image, I've set it up so that a POST request goes to an API gateway, which then triggers a lambda function to handle the upload to an S3 bucket. My lambda function also performs file checks to ensure that no malicious content gets uploaded.

I've been hearing a lot about presigned URLs and I'm curious about how I can integrate them into my app. It makes sense to me, but I'm also worried that it could be a security risk. The way I see it, using a presigned URL means the user would upload directly to S3 instead of going through my lambda, and that feels risky because if someone reverse-engineers the app, they could get a valid presigned URL and upload anything they want. So, is using presigned URLs for image uploads a bad idea? Are there any ways I can make it more secure? Also, I'm using Firebase for authentication—would implementing an app check help mitigate these risks?

5 Answers

Answered By FilenameFreak On

Definitely consider using presigned URLs! The key is to ensure they're short-lived and unique for each request. Also, for authentication, make sure your lambda that provides the presigned URL verifies the user is legit. You want only authorized users to be able to request those URLs.

Answered By SafeUploader24 On

1. Always create a new presigned URL for each upload request and keep it short-lived.
2. Implement a post-upload validation step to check for any malicious content after uploads are finished, maybe with a trigger lambda. This will give you extra protection even if someone gets hold of the URL.

Answered By TechSavvy123 On

It's totally safe to use presigned URLs for uploads if you do it right! Just make sure you generate a unique presigned URL for each upload with a short expiration time. That way, even if someone gets hold of it, they’ll only have a limited time to use it. Also, it's a good idea to monitor the uploads to ensure they stay within your expected file size limits and perform validations after the upload is completed.

Answered By S3Expert88 On

Presigned URLs are indeed the way to go for image uploads. If you're worried about malicious uploads, one strategy is to use a staging bucket where files are temporarily held before you verify they are safe, and then you can move them to their final destination. Just ensure your application checks are robust to prevent unauthorized access.

Answered By UploadGuru99 On

Using presigned URLs is actually a great approach because it lets your users upload larger files than your lambda can handle directly. You'll want to ensure you restrict the expected content length based on what is being uploaded, and you can always have the lambda check the file once it gets uploaded. If you set up a lambda function to process the upload events in S3, you can delete any suspicious files right after checking them.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.