Security – Giving other users write access to apache logs can result in root exploit – How does this work

apache-2.2exploitloggingSecurity

On http://httpd.apache.org/docs/2.2/logs.html

Anyone who can write to the directory where Apache is writing a log file can almost certainly gain access to the uid that the server is started as, which is normally root. Do NOT give people write access to the directory the logs are stored in without being aware of the consequences; see the security tips document for details

How does this work? How does writing to a file that Apache is also writing to grant access to the Apache Parent Process user (root)?

Best Answer

Check out the security tips page.

http://httpd.apache.org/docs/2.2/misc/security_tips.html

If you allow non-root users to modify any files that root either executes or writes on then you open your system to root compromises. For example, someone could replace the httpd binary so that the next time you start it, it will execute some arbitrary code. If the logs directory is writeable (by a non-root user), someone could replace a log file with a symlink to some other system file, and then root might overwrite that file with arbitrary data. If the log files themselves are writeable (by a non-root user), then someone may be able to overwrite the log itself with bogus data.

Since apache opens and reads the log file as root, there is a danger here for abuse. Not sure why you would want a non-root (apache) user to have write access to the files. You can safely grant read access but would suggest that write access only be given to old files that have rotated. Apache is not opening these files when you use logrotate to manage log rotation.

Related Topic