Bug 680789 - logrotate: Race condition by creation of new files after renaming the previous version if compression or copy creation requested (arbitrary system file integrity corruption)
logrotate: Race condition by creation of new files after renaming the previou...
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
: Security
Depends On:
  Show dependency treegraph
Reported: 2011-02-27 14:17 EST by Jan Lieskovsky
Modified: 2011-03-11 01:30 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2011-03-11 01:30:25 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
proposed patch (929 bytes, patch)
2011-03-01 04:15 EST, Jan Kaluža
no flags Details | Diff

  None (edit)
Description Jan Lieskovsky 2011-02-27 14:17:28 EST
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.
Comment 3 Jan Kaluža 2011-03-01 04:15:16 EST
Created attachment 481568 [details]
proposed patch

This is backported patch from Debian without unlink command which fixes this issue.
Comment 4 Jan Kaluža 2011-03-01 04:17:49 EST
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.
Comment 7 Jan Lieskovsky 2011-03-03 05:15:05 EST
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.

Note You need to log in before you can comment on or make changes to this bug.