3 ms·
Problematic how? It doesn't mean the whitelist has to be in the code, it could be 'generated' from a database (let whitelist be the result of select file_name f
by wereHamster 10y ago
Problematic how? It doesn't mean the whitelist has to be in the code, it could be 'generated' from a database (let whitelist be the result of select file_name from uploaded_files_table)
- paulddraper 10y agoThen file_name needs to be reasonable and not arbitrary, right? I don't care where you push your checks around to, just as long as they exist.
- wyager 10y agoA hex-encoded file hash as a file name is a safe bet. You can resolve file names (unsanitized, stored safely in a database) to hashes and load the files from disk. This general approach (whitelisting file URLs) lets us localize any path sanitation to the file upload code, rather than every single request.