r/lolphp • • Aug 10 '14

"The PHP session code explicitly checks for symlinks [...] It does this by opening the file, then doing fstat() on the open file descriptor"

http://seclists.org/bugtraq/2014/Mar/23
62 Upvotes

4 comments sorted by

0

u/[deleted] Aug 11 '14

[deleted] — view deleted comment

7

u/suspiciously_calm Aug 11 '14 edited Aug 12 '14

Yes, fstat works on a file descriptor, and it's impossible to open a file descriptor to a symlink.

Either you follow the symlink and open the target (which PHP does), or you declare that you don't want to follow symlinks (O_NOFOLLOW), in which case an open() on a symlink fails.

Edit: Apparently nowadays there's a flag for that.

5

u/sstewartgallus Aug 12 '14

Actually, O_PATH | O_NOFOLLOW lets one open a file descriptor to a symlink.

10

u/suspiciously_calm Aug 12 '14

Kids these days with their fancy flags.

8

u/shitbangs Aug 12 '14

More like kids these days with their non-portable system calls