Arbitrary read on s3://shopify-delivery-app-storage/files
The fog gem normalised a user-controlled filename, allowing a malicious user to include '../' and craft an S3 bucket key that pointed to another user's file. An attacker could then obtain a valid signed download link for any file in the bucket if they knew its key.
- Triaged in 5 days
- Fixed in 5 days
- Paid in 5 days
- Disclosed after 5 days
Summary by the program
The fog gem performs path normalization on the user-controlled filename, which would have allowed a malicious user to specify a path containing "../". A valid download link (including the required signature) could be retrieved for any file uploaded to the amazon bucket, including other user's file.
The report
Short
An attacker is able to read arbitrary files from the delivery app storage if the bucket key is known to him.
Vector
- The victim uploads a.png to a product his shop located at https://myhackeronestore.myshopify.com.
1a) The file is stored at s3://shopify-delivery-app-storage/files/myhackeronestore.myshopify.com/5682196162/a.png 2) The attacker uploads b.png to a product in his shop (location irrelevant) and changes the 'attachment[filepath]' parameter from "b.png" to "b.png/../../../../files/myhackeronestore.myshopify.com/5682196162/a.png" in the initial call to /attachments. 3) The attacker will now go ahead an generate a manual download link for his newly created attachment
3a) When he visits the generated manual download link the site will state "b.png/../../../../files/myhackeronestore.myshopify.com/5682196162/a.png" as the file name 3b) When the attacker proceeds to press the download button he'll get a working link to get a.png from the victim.
What's wrong here
The attacker is able to craft the bucket key in a way to use path traversals (and possibly other wired things related to AWS S3 key names) to get files he shouldn't have access to.
How it should be
In an ideal world the delivery app should control 100% of the bucket key name to make sure no harm can be done by attacks like this. This could be achieved by having a mapping from uploaded_filename to actual_key_in_s3 (is there a way to tell S3 how the downloaded file should be named?).
Conclusion
In my book this is fraud and shouldn't be there ;) You might consider the approach to control 100% of the bucket key to rule an entire class of bugs/vulnerabilities here out as filtering of the filename is tricky and will probably fail (now or in the near feature, who knows what S3 offers as a neat new 'feature' in the future). Also there are just too many variants on how things could get wrong, what comes to mind is: Encoding interpretation failures on the app side, hidden/not well documented features on the AWS side,...
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
Impact
An attacker could read arbitrary files from the delivery app storage if they knew the bucket key, potentially accessing other users' files.
What the attacker needed
Attacker has a shop account; victim has uploaded a file; attacker knows the bucket key of the target file
The fix
The delivery app should control 100% of the bucket key name, for example by mapping the uploaded filename to an actual key in S3.
How it was found
- Victim uploads a file to their shop, which is stored under their shop's path in the bucket.
- Attacker uploads a file to their own shop and changes the attachment filepath parameter to include '../' sequences pointing to the victim's file.
- Attacker generates a manual download link for their attachment.
- Attacker visits the link, sees the crafted filename, and presses download to get the victim's file.
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, the app builds a storage path from the filename you give. If that filename contains '../', the path can climb out of your own folder and point at someone else's file. The app then hands you a signed link to that file, so you can download it.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.