Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 630990 - mail-filter/rmilter: privilege escalation via PID file manipulation
Summary: mail-filter/rmilter: privilege escalation via PID file manipulation
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal trivial (vote)
Assignee: Gentoo Security
URL:
Whiteboard: ~3 [noglsa]
Keywords: PMASKED
Depends on:
Blocks:
 
Reported: 2017-09-14 16:44 UTC by Michael Orlitzky
Modified: 2020-09-04 01:41 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
rmilter.initd-r3 (rmilter,674 bytes, text/plain)
2017-09-14 16:44 UTC, Michael Orlitzky
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2017-09-14 16:44:41 UTC
Created attachment 494534 [details]
rmilter.initd-r3

The init script for rmilter currently gives ownership of its PID file directory to the daemon's runtime user:

  PIDFILE=$RUNDIR/rmilter.pid
  ...
  start() {
      ebegin "Starting ${SVCNAME}"
      checkpath -d $RUNDIR -m2750 -o rmilter:rmilter

This can be exploited by the rmilter user to kill root processes, since when the service is stopped, root will send a SIGTERM to the contents of the PID file.

I've rewritten the init script to avoid that problem by running the daemon in the foreground and by letting OpenRC background it and manage its PID file. I've tried to make this compatible with the new script in bug 600578 as well, which uses a config file whose name is based on RC_SVCNAME.

Note that rmilter will still create a *second* PID file on its own that will be ignored. This is ugly but probably harmless. You can eliminate the second, useless, PID file by commenting out

  pidfile = /var/run/rmilter/rmilter.pid;

in the config file. A "sed" in src_prepare() should do the job.
Comment 1 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-06-11 21:12:58 UTC
Maintainer: Ping.
Comment 2 Dirkjan Ochtman (RETIRED) gentoo-dev 2020-06-14 20:14:08 UTC
Note that rmilter has been deprecated as of rspamd 1.6 and you should instead use the rspamd proxy feature. rmilter isn't even guaranteed to work with rspamd 1.7+. We should probably last rite this package to make people aware it's no longer being maintained, and I'm not sure it makes sense to fix this up now.
Comment 3 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-06-14 20:46:54 UTC
Thanks. CCing treecleaners.
Comment 4 Larry the Git Cow gentoo-dev 2020-08-04 02:43:50 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=050a723767e661038df740440b33f5f1982d1482

commit 050a723767e661038df740440b33f5f1982d1482
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2020-08-04 01:03:56 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2020-08-04 02:43:10 +0000

    profiles/package.mask: last-rite mail-filter/rmilter
    
    Bug: https://bugs.gentoo.org/630990
    Bug: https://bugs.gentoo.org/600578
    Signed-off-by: Sam James <sam@gentoo.org>

 profiles/package.mask | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 5 Larry the Git Cow gentoo-dev 2020-09-04 00:10:50 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7a5dc2ad5193e7b6c771ae2c36bc46573f45cbe7

commit 7a5dc2ad5193e7b6c771ae2c36bc46573f45cbe7
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2020-09-04 00:07:35 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2020-09-04 00:08:56 +0000

    mail-filter/rmilter: remove last-rited pkg
    
    Bug: https://bugs.gentoo.org/600578
    Bug: https://bugs.gentoo.org/630990
    Signed-off-by: Sam James <sam@gentoo.org>

 mail-filter/rmilter/Manifest                 |  2 --
 mail-filter/rmilter/files/rmilter.initd      | 27 -----------------
 mail-filter/rmilter/files/rmilter.initd-r1   | 25 ----------------
 mail-filter/rmilter/files/rmilter.initd-r2   | 26 ----------------
 mail-filter/rmilter/metadata.xml             | 15 ----------
 mail-filter/rmilter/rmilter-1.10.0-r1.ebuild | 45 ----------------------------
 mail-filter/rmilter/rmilter-1.10.0-r2.ebuild | 45 ----------------------------
 mail-filter/rmilter/rmilter-1.10.0.ebuild    | 45 ----------------------------
 mail-filter/rmilter/rmilter-1.9.2.ebuild     | 45 ----------------------------
 mail-filter/rmilter/rmilter-9999.ebuild      | 45 ----------------------------
 profiles/package.mask                        |  6 ----
 11 files changed, 326 deletions(-)
Comment 6 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-09-04 01:34:23 UTC
Tree is cleaned.