4 ms·
GET ../../../etc/passwd
by sneak 5y ago
GET ../../../etc/passwd
- asah 5y agosandbox it? e.g. docker, OpenBSD chroot?
- jpegqs 5y agoI have provided protection against this.
- Someone 5y agoI don’t think it compiles on windows (netdb.h doesn’t exist there, I think), so you’re fine there, too, from a security viewpoint. However, if somebody did a quick and dirty “make it compile” port (include winsock2.h instead and, possibly, replace some functions/argument types), I think that would create security vulnerabilities because the fopen on Windows might support using backslashes as path separators. Even if it doesn’t, there’s UNC paths (https://en.wikipedia.org/wiki/Path_(computing)#Universal_Naming_Convention https://en.wikipedia.org/wiki/Path_(computing)#Universal_Nam...) to worry about. That made me wonder whether other OSes might have similar features. Reading https://pubs.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap04.html https://pubs.opengroup.org/onlinepubs/007904975/basedefs/xbd..., I’m not sure that forbids Unix from doing something similar. It says “A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.” That opens the door for doing special things for paths that start with //, for example by supporting “//machine:foo/bar/baz” on clusters.
- Arch-TK 5y agoGET //etc/passwd HTTP/1.0 I noticed the check for "/." in the path and I chuckled. I think if you strip all leading forward slashes and check for "/." then you may have it be "secure" on linux at least. Your best bet for fixing this on windows is making sure the code never compiles on windows because god knows what on earth the path handling is like on windows.
- NieDzejkob 5y agoLooks like you didn't even bother to test your claim.
- jart 5y agoGET %C0%AE%C0%AE/%C0%AE%C0%AE/%C0%AE%C0%AE/etc/passwd
- jpegqs 5y agoIt won't be a problem in this code because "%" is not handled. But could be a vulnerability for more implemented HTTP servers, and a few days ago I got this idea too.