|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-11-25 20:43 UTC] jann+php at thejh dot net
Description: ------------ My php version: git commit a37ff1fa4bb149dc81fc812d03cdf7685c499403 This patch fixes two problems. First problem: php does an fstat() on a file descriptor to check whether the file it just opened was accessed through a symlink. That's never going to work because the fd points to the file, not to the symlink. My fix: Remove the check, use O_NOFOLLOW instead. Second problem: When the session.save_path is a directory that everyone can write into (like on Debian), even if it's not possible to find the IDs of existing sessions, a local attacker can just create a new session file with malicious session data, chmod it to 666 and access any webapp hosted on the system with the session ID he chose. The webapp then opens the session file and treats it as if it had created it. My fix: fstat() the session, check the uid that created the file. If it's neither the result of getuid() nor uid 0, ignore the existing file. (uid 0 because someone might be crazy enough to put session.save_path on a filesystem that doesn't support uids, which would probably make the uid default to 0) PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Please remove this check! It is bad idea! Many sites are running under www-user! It breaks them with "Warning : Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct" + /* check that this session file was created by us or root в.. we + don't want to end up accepting the sessions of another webapp */ + if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid())) { + close(data->fd); + data->fd = -1; + return;