Context
I've been recently looking at UUIDs (mostly v4) and their uses to maybe start using them in some of my apps. I started asking myself some question about security as one does. Then I fell on the Is it safe to rely on UUIDs for privacy? question which led me to Are random URLs a safe way to protect profile photos?.
Simulation
To allow better understanding of my issue, here is how the targeted site would work:
- Some static content files are served publicly in a given folder
site.com/uploads/ - The files are publicly accessible but their filenames are cryptographically random hashes like
site.com/uploads/rnvaat22suhb1ftc0nxrm9hqfdafzoy4.pdf- In this instance, we will assume the dev storing static files in the public space did his due diligence of using cryptographically safest PRNG to generate the file name, making sure they are as "unguessable" as practically possible.
- To prevent the answers from going around the subject, we'll assume the dev cannot implement it in any other way (stupid yes! but spec is spec)
Issue
When comparing anything password-like (here, random file names), the devs implementing the comparison/lookup needs to make sure it is safe against timing attack. The problem is that, most of the time, the dev who placed the files on the server is not the one responsible for coding the web server/OS serving public static files and thus cannot control that part of the problem.
Let's say a bad actor finds out about this site and knows the existence of the public uploads/ folder. I believe timing attacks could be a problem here.
Using the site.com/uploads/rnvaat22suhb1ftc0nxrm9hqfdafzoy4.pdf example:
- Try
site.com/uploads/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf-- 404 - Try
site.com/uploads/baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf-- 404 - ...
- Try
site.com/uploads/raaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf-- 404, but just a bit slower
Knowing that TCP timestamps exists and that HTTP is implemented using TCP. We know the server uptime and can abstract out the network jitter. If the server deactivated TCP timestamps, we could theoretically still be able to guess it by using statistics.
Is this a real and probable problem?
NOTE: I'm not looking for suggestion to "make the app better". I know attack mitigation tactics exist (throttling). They are not the idea here.
raaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdffile because araaaaaaaaaaaaaaaaaaaaaaaaaaaaaab.pdffile exists?" ? – schroeder Oct 12 '23 at 22:02