简体   繁体   English

在Web App中公开AWS S3签名URL?

[英]Exposing AWS S3 Signed URLs in Web App?

I have been trying to find an answer to this question for a couple of hours now, but have not managed to come up with a conclusive answer. 我一直试图在几个小时内找到这个问题的答案,但还没有想出一个确凿的答案。 I am hoping someone here will be able to shed some light on my question. 我希望有人能够对我的问题有所了解。 Consider the following Example AWS S3 URL: 请考虑以下示例AWS S3 URL:

https://some-bucket.s3-eu-west-2.amazonaws.com/uploads/images/some_image.jpg?X-Amz-Expires=600&X-Amz-Date=20170920T124015Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAI6CJYFYSSWMXXXXX/20170920/eu-west-2/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=0481296b70633de9efb2fce6e20751df2f55fd79b5ff9570c02ff8f587dce825 https://some-bucket.s3-eu-west-2.amazonaws.com/uploads/images/some_image.jpg?X-Amz-Expires=600&X-Amz-Date=20170920T124015Z&X-Amz-Algorithm=AWS4-HMAC- SHA256&X-AMZ-凭证= AKIAI6CJYFYSSWMXXXXX / 20170920 / EU-西-2 / S3 / aws4_request&X-AMZ-SignedHeaders =宿主&X-AMZ-签名= 0481296b70633de9efb2fce6e20751df2f55fd79b5ff9570c02ff8f587dce825

In my specific example, the above URL is a request to view an image on S3 which I am exposing directly in a HTML img tag, and the user in Amz-Credential has both read and write permissions. 在我的具体示例中,上面的URL是在S3上查看图像的请求,我直接在HTML img标记中公开,并且Amz-Credential中的用户具有读取和写入权限。 The URL is also set to expire in 10 minutes. 该URL也设置为在10分钟后过期。

Is is safe to link to the image directly via this URL, or is there any possibility that within these 10 minutes, the signature from this URL could be used in a maliciously crafted REST request to delete or modify the image instead of viewing it? 是否可以通过此URL直接链接到图像,或者是否有可能在这10分钟内,此URL中的签名可用于恶意制作的REST请求,以删除或修改图像而不是查看图像?

I do suspect a different action will have a different signature to make this impossible, but given my very limited understanding of AWS auth, I thought it better to ask just in case. 我怀疑不同的行为会有不同的签名使这个变得不可能,但鉴于我对AWS auth的理解非常有限,我认为最好先问一下以防万一。

I know I could create a read-only user (extra complexity) or hide the S3 URL behind a controller action on my own web app (requires 2 total requests to load each image, making it inefficient), but I would rather learn whether my current approach is safe or not before resorting to either of these. 我知道我可以创建一个只读用户(额外的复杂性)或隐藏在我自己的Web应用程序上的控制器操作后面的S3 URL(需要2个加载每个图像的请求,使其效率低下),但我宁愿了解我是否在诉诸这些方法之前,目前的方法是否安全。

Thank you kindly for your time. 谢谢你的时间。 :) :)

If your pre-signed url has PUT or DELETE permission someone could try to get the Signature + AccessKeyId to overwrite or delete your object. 如果您的预签名网址具有PUT或DELETE权限,则有人可能会尝试让Signature + AccessKeyId覆盖或删除您的对象。

Just make sure that you are signing the url with a read-only permission and I guess you're good. 只需确保您使用只读权限对网址进行签名,我猜你很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM