A race condition was found in the way the logrotate utility created new files after renaming the previous version if compression or creation of a copy was requested in the configuration file. If the logrotate utility was run on a log file contained within an attacker controllable directory, a local attacker could use this flaw to trick the logrotate utility into replacing arbitrary system files (if logrotate was run under privileged user account, root) with the copied or compressed contents of a log file.
Created attachment 481568 [details] proposed patch This is backported patch from Debian without unlink command which fixes this issue.
Note that final patch can change, because this issue is tightly connected with other bugs, so there will be maybe one bigger patch which will cover more bugs.
Further clarified details from Stefan Fritsch of Debian Security Team: ======================================================================= There is a race between renaming 950 if (!debug && rename(oldName, newName)) { a previous generation log file (say from "foo.1" to "foo.2") and opening a file with the old name ("foo.1") for writing. The open for write can happen both in copyTruncate() or in compressLogFile() at 302 outFile = createOutputFile(compressedName, O_RDWR | O_CREAT | O_TRUNC, sb); The fix would be to use O_EXCL.