Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 630884 - mail-filter/dspam: privilege escalation via PID file manipulation
Summary: mail-filter/dspam: 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 normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-13 12:05 UTC by Michael Orlitzky
Modified: 2020-09-04 01:41 UTC (History)
5 users (show)

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


Attachments
dspam.initd-r1 (dspam,485 bytes, text/plain)
2017-09-13 12:05 UTC, Michael Orlitzky
no flags Details
dspam.confd-r1 (dspam,269 bytes, text/plain)
2017-09-13 12:06 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-13 12:05:50 UTC
Created attachment 494348 [details]
dspam.initd-r1

The init script for dspam gives ownership of its PID file directory to the "dspam" user:

  checkpath -q -d -o dspam:dspam -m 0755 "${PIDDIR}" || return 1

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

I've rewritten the init script to work around this by running in the foreground, and by letting OpenRC push the process into the background and manage its PID file.

I'm attaching the init script and conf.d file (which no longer has a PIDFILE setting), but there is one change that needs to be made to the ebuild as well: dspam tries to write its own PID file, even when it's running in the foreground. The default location that it tries to use does not exist, and so the daemon will fail to start unless you change that path. A "sed" or something similar can be used in the ebuild to set

  ServerPID		/tmp/dspam.pid

in dspam.conf. That location should exist and be writable on every installation. (The ServerPID is completely ignored, the *real* PID file is managed by OpenRC.)
Comment 1 Michael Orlitzky gentoo-dev 2017-09-13 12:06:25 UTC
Created attachment 494350 [details]
dspam.confd-r1
Comment 2 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-06-19 07:35:41 UTC
CCing treecleaner. This appears to be unmaintained, and hasn't had a maintainer since net-mail@. Related package www-apps/dspam-web has also had an open version bump request since 2013.
Comment 3 Larry the Git Cow gentoo-dev 2020-08-04 02:43:46 UTC
The bug has been referenced in the following commit(s):

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

commit d171af00bde657b42eead2f34beab6cc60a72f63
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2020-08-04 01:19:26 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2020-08-04 02:43:10 +0000

    profiles/package.mask: last-rite mail-filter/dspam
    
    Bug: https://bugs.gentoo.org/630884
    Bug: https://bugs.gentoo.org/713404
    Bug: https://bugs.gentoo.org/707274
    Bug: https://bugs.gentoo.org/692436
    Bug: https://bugs.gentoo.org/490322
    Bug: https://bugs.gentoo.org/626474
    Signed-off-by: Sam James <sam@gentoo.org>

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

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=591c43d3d90dd3aa1752e8a90b49cc8467058a4b

commit 591c43d3d90dd3aa1752e8a90b49cc8467058a4b
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2020-09-04 00:07:50 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2020-09-04 00:09:19 +0000

    mail-filter/dspam: remove last-rited pkg
    
    Bug: https://bugs.gentoo.org/692436
    Bug: https://bugs.gentoo.org/630884
    Bug: https://bugs.gentoo.org/626474
    Bug: https://bugs.gentoo.org/490322
    Bug: https://bugs.gentoo.org/707274
    Bug: https://bugs.gentoo.org/713404
    Bug: https://bugs.gentoo.org/665910
    Bug: https://bugs.gentoo.org/520844
    Signed-off-by: Sam James <sam@gentoo.org>

 mail-filter/dspam/Manifest                         |   1 -
 mail-filter/dspam/dspam-3.10.2-r2.ebuild           | 221 --------------------
 mail-filter/dspam/dspam-3.10.2-r3.ebuild           | 223 ---------------------
 .../dspam-3.10.2-mysql8-my_bool-typedef.patch      |  13 --
 mail-filter/dspam/files/dspam.confd                |   7 -
 mail-filter/dspam/files/dspam.cron-r4              |   5 -
 mail-filter/dspam/files/dspam.initd                |  44 ----
 mail-filter/dspam/files/dspam.logrotate            |  10 -
 mail-filter/dspam/metadata.xml                     |  35 ----
 profiles/package.mask                              |   1 -
 10 files changed, 560 deletions(-)