Skip to content

Avoid operating in insecure directories#455

Open
cgzones wants to merge 1 commit intologrotate:mainfrom
cgzones:wip
Open

Avoid operating in insecure directories#455
cgzones wants to merge 1 commit intologrotate:mainfrom
cgzones:wip

Conversation

@cgzones
Copy link
Member

@cgzones cgzones commented Aug 2, 2022

Logrotate is known to be affected by race conditions when operating
on files in "insecure" directories1. Since logrotate is commonly run
as root this can lead to privilege escalation[2,3].

Ensure log and olddir directories are "secure"4, i.e. owned by a
foreign non-root user or group-writable and owned by a foreign non-root
user or world-writable and sticky-bit not set.

Add a new directive 'allownonsecuredir' as last resort to allow rotation
in such directories.

Supersedes: #237

@kdudka
Copy link
Member

kdudka commented Aug 3, 2022

Why do we need to cache uid and gid of logrotate process?

Copy link
Member

@kdudka kdudka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this pull request make #237 obsolete?

Logrotate is known to be affected by race conditions when operating
on files in "insecure" directories[1].  Since logrotate is commonly run
as root this can lead to privilege escalation[2,3].

Ensure log and olddir directories are "secure"[4], i.e. owned by a
foreign non-root user or group-writable and owned by a foreign non-root
user or world-writable and sticky-bit not set.

Add a new directive 'allownonsecuredir' as last resort to allow rotation
in such directories.

[1]: https://github.com/whotwagner/logrotten
[2]: https://bugzilla.redhat.com/show_bug.cgi?id=1705143
[3]: https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4380
[4]: https://wiki.sei.cmu.edu/confluence/display/c/FIO15-C.+Ensure+that+file+operations+are+performed+in+a+secure+directory

Supersedes: logrotate#237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants