So, this month we landed a new client for whom we must keep track of distributor's and doctor's orders and sales. The client had a requirement to k...
For further actions, you may consider blocking this person and/or reporting abuse
There are a number of security problems here.
Never user plaintext AWS credentials
Don't have public buckets
AWS is usually pretty clear about the risks of not having buckets configured to block all public access. It is far more secure to have your users upload the file to a server which then performs an
s3:PutObject
call.If someone is able to get your service to give them signed URLs for uploading contents, you may very quickly find harmful files uploaded to your bucket.
Your CORS settings invite SSRF and CSRF
Your
axios
error handling is insecureThe
axios
module includes all authorization headers in the error object it returns, so yourconsole.error()
will log sensitive information.Finally, you're using the old version of the AWS SDK
AWS-SDK v2 is being deprecated soon: aws.amazon.com/blogs/developer/ann...
The V3 of the SDK is pretty easy to use, and the nice thing about the change is that it's going to be similarly functional across all of the various libraries (e.g. Rust, Java, JavaScript), using similar patterns. Gone will be the days of language-specific AWS SDK patterns.
Damn, thank you, I really mean it. Thats a lot to take but I will study one by one on the points you mentioned and try to improve my practice in existing and upcoming projects 🤝🙌😬
During the production setup mostly the API routes stay under the auth middleware but I guess I can move the entire logic on the server which will take a single/multiple files and return the uploaded paths to keep it modular this I don't compose my bucket in any way
I very much appreciate you receiving that well. Security is hard, and security in the cloud is harder. There are a lot of tools but it's really hard to keep up with all of them.
If it helps, I never use IAM users. For humans, we should use federated authentication using something like Okta, or Auth0, and for infrastructure running code in AWS we should use execution roles or instance profiles.
Nobody can steal credentials which do not exist, or (in the case of AWS STS) are ephemeral and expire quickly.
Okay understood, I will try to practice using okta or Auth0 for future projects
Wholesome exchange right here.... Love this community 🙌
@manchicken
1) So how should I store them? How do you store them?
Fetch them at runtime and discard them when you no longer need them. Also, use instance profiles and STS when possible, avoiding having long-lived secrets in the first place.
In 2024, there is no good reason to rely on access tokens and user passwords in AWS.
Thnks. It is not my decision to use S3.
Nice share! 🙌
Thanks lee
I read multiple articles related to aws signed urls and I would say that this one pieces them togehter.
Good read!
Thanks brother, I will try to update the article with more details on security
Great article bother..... Helped me a lot
Best article ever i went through 💯