Closed yaci closed 7 years ago
I will address this as soon as I have the time, thank you for pointing this out.
Thanks again for bringing this to my attention, currently this issue, as you said, is mostly managed by restricting file-types, so an attacker will be met by this:
file type not supported, please check your configuration
This issue is also mitigated by the fact that srv.php serves up time sensitive links, but this will likely be replaced by a cookie based exchange due to an annoyance in #13 in the near-ish future. The path traversal issue will be dealt with before that happens. But it seems pretty secure right now.
as for now, I have
../../../
from the beginning of the fn
keyThese should manage the problem fine, actually, just the first one should be enough... as for the rest of it, I like the idea of adding the prefix and file extension after transmission, checking the length there sounds good as well. It will have to wait, however. Thanks for the suggestions, I'm closing this as the vulnerability has been dealt with.
Let's consider an example url: https://domain.com/srv/?id=iqrcodes&key=someKey&fn=qrc_hash.png
The fn parameter takes a file name, but it can also take a path. I.e. it may be possible to execute the following https://domain.com/srv/?id=iqrcodes&key=someKey&fn=../../../somefile.png
This may result in a situation where attacker gains an access to a file outside public_html directory. You can read more about this kind of attack here: https://www.owasp.org/index.php/Path_Traversal
Currently it's mostly mitigated by the fact, that srv.php only processes requests for image files and other file types are rejected. Also my server configuration did not allow access to files outside public_html. Nevertheless I feel it would be good to address this.
The approach that I would suggest:
Another approach would be to send the short url and do the hashing on the server. In this way we would end up with a hash string regardless of user input.