Arbitrary write on s3://shopify-delivery-app-storage/files
The S3 upload policy for the Shopify Delivery app allowed writing any file under the files/ directory, not just the intended upload path. An attacker could replace another shop's downloadable files if they obtained a signed download link.
- Triaged in under an hour
- Fixed in 27 hours
- Paid in 27 hours
- Disclosed after 48 hours
Short
The policy used to upload files via the Delivery app is too generic which results in an arbitrary write (and replace) of files in the files/ directory.
Disclaimer: While I was unable to create a second store to fully test this (I can't create new development stores right now, support is researching this), I strongly believe that this vulnerability works as I expect it to work due to the nature of the policy.
Current Policy
{
"expiration": "2015-10-14T15:27:47Z",
"conditions": [
{
"bucket": "shopify-delivery-app-storage"
},
[
"starts-with", "$key", "files/"
],
{
"acl": "private"
},
{
"success_action_status": "200"
},
["content-length-range", 0, 5368709120]
]
}
What's wrong here
The only (security relevant) limitations we have here are:
- Signature + Policy are only valid for one day
- The key has to start with files/
- ACL has to be set private
So, one can basically write arbitrary files to the S3 bucket as long as those are within the files/ dir. This doesn't hinder anybody as all the 'good stuff to replace' is under that dir. As the ACL is private, files can just be downloaded when the delivery app signed a download request, so the attacker needs to get a hold on a valid link.
The vector
- Find a shop with a downloadable good and purchase it OR get a manual direct link
- Grab the bucket key when the file will be downloaded directly from S3 (via signed url)
- Go to your own shop, create a product with a downloadable good
- Note down the parameters used to POST the file when you upload it
- Issue a new request to the key recorded from the data you don't own with the parameters you just grabbed from your own delivery app
- Profit
One could do a ton of fun stuff to the files, to my mind come Viruses, Exploits, Illegal Content, etc.
How it should be
The policy should be tailored directly to the upload at hand, especially the key. The app does return the specific path already where the file should be placed by the client, I don't see why the policy doesn't reflect that. The policy should be nailed directly to that key to eliminate this vulnerability.
What I did that you should cleanup
I did upload 2 files to the bucket which don't belong to anyone, those files are:
- files/hackerone/simon/brakhane/kitty.jpg
- files/kitty.jpg
You might want to clean them away as they can't be downloaded anyway and just cost you money.
Cheers, Simon
PS: I do hope strongly this isn't already known ;)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The upload policy only restricted the key prefix to 'files/' instead of the exact file path, allowing writes to any object under that directory.
Impact
An attacker could replace other shops' downloadable files with malicious content, but they first need a valid signed download link because the files are private.
What the attacker needed
A shop with a downloadable product; a valid signed download link for the target file; ability to upload a file in one's own shop
The fix
The upload policy should be restricted to the exact key path returned by the app for each upload.
How it was found
- Find a shop with a downloadable good and purchase it or get a manual direct link.
- Grab the bucket key when the file is downloaded directly from S3 via a signed URL.
- Go to your own shop and create a product with a downloadable good.
- Note down the parameters used to POST the file when you upload it.
- Issue a new request to the key recorded from the data you don't own with the parameters from your own delivery app.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you upload a file to a cloud storage service like Amazon S3, the server gives your browser a temporary permission slip (a policy) that says what you are allowed to do. Here, that permission slip was too broad: it let anyone write any file inside a shared folder, not just their own upload. So if someone knew the secret web address of another shop's file, they could overwrite it with their own content.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.