Mitigation of a race condition in createOutputFile()#235
Mitigation of a race condition in createOutputFile()#235whotwagner wants to merge 1 commit intologrotate:masterfrom
Conversation
If the "create"-option is set, there is a time window between rotating the logfile and creating/touching a new empty file. If a user is in control of the parent directory, he/she could replace it during this time window with a symbolic link to any directory. If logrotate was executed by root, the new file will be created first with permissions of root and then the ownerships will be set to the user. After the file was created, the user might be able to write any content to this file.
|
First off, thank you for helping us to improve logrotate! But I do not think that the proposed change could reliably mitigate the attack vector you were describing for multiple reasons:
The change also introduces a memory leak but it is not important at this step of the review. |
|
Hi,
I am going to close this pull request. |
|
Yes, it is not easy to make 20+ years old software immediately perfectly secure. On the other hand, we should at least improve the documentation. It currently roughly says what the |
|
I fully understand you that it isn't easy to fix certain things and I think its a great idea to make admins aware. |
... to rotate files in directories that are directly or indirectly in control of non-privileged users. Originally reported in the following pull request: #235
|
I have submitted pull request #236 to improve the documentation. |
Rotating logfiles for which just one directory of the absolute path could be modified by another user is dangerous. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping insecure logfiles. A function is_trusted_dir() is introduced. It checks the complete path including symlinks for insecure configurations.
It is dangerous to rotate logfiles located in a directory-path that could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. A function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
It is dangerous to rotate logfiles located in a directory-path that could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. A function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
It is dangerous to rotate logfiles that located in a directory-path which could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. The function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
It is dangerous to rotate logfiles that located in a directory-path which could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. The function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
It is dangerous to rotate logfiles that located in a directory-path which could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. The function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
It is dangerous to rotate logfiles that located in a directory-path which could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. The function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
It is dangerous to rotate logfiles that located in a directory-path which could be modified by another user. Due to race conditions a privilege escalation could happen. This was already discussed at the pull-request logrotate#235 This commit makes logrotate skipping logfiles that are located in a insecure directory. The function is_trusted_dir() is introduced. It checks the complete path of a logfile-directory including symlinks for insecure configurations.
If the "create"-option is set, there is a time window between rotating the logfile
and creating/touching a new empty file. If a user is in control of the parent
directory, he/she could replace it during this time window with a symbolic link to
any directory. If logrotate was executed by root, the new file will be created first
with permissions of root and then the ownerships will be set to the user. After the
file was created, the user might be able to write any content to this file.