Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 630898 - <mail-filter/amavisd-new-2.11.1-r3: privilege escalation via PID file manipulation for amavisd-snmp
Summary: <mail-filter/amavisd-new-2.11.1-r3: privilege escalation via PID file manipul...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-13 14:34 UTC by Michael Orlitzky
Modified: 2019-03-10 04:00 UTC (History)
2 users (show)

See Also:
Package list:
mail-filter/amavisd-new-2.11.1-r3
Runtime testing required: ---
stable-bot: sanity-check+


Attachments

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 14:34:27 UTC
The amavisd-snmp init script gives ownership of its PID file directory to the "amavis" user:

  start_pre() {
      update_command
      checkpath -d -o amavis /run/amavis
  }

This is exploitable by the "amavis" user to kill root processes, because when the service is stopped, root will send a SIGTERM to the contents of that PID file.

Fortunately, the call to "checkpath" above is unnecessary:

  $ ls /run/amavis/amavisd-snmp.pid 
  -rw-r----- 1 root root 6 2017-09-13 10:30 /run/amavis/amavisd-snmp.pid

So for a fix, I recommend setting

  pidfile="/run/${RC_SVCNAME}.pid"

and then deleting the call to "checkpath".
Comment 1 Larry the Git Cow gentoo-dev 2018-11-26 00:24:36 UTC
The bug has been referenced in the following commit(s):

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

commit 8635dce998732f7f82cc6c51bd0a7014c5e6ae6a
Author:     Michael Orlitzky <mjo@gentoo.org>
AuthorDate: 2018-11-22 03:10:18 +0000
Commit:     Michael Orlitzky <mjo@gentoo.org>
CommitDate: 2018-11-26 00:17:56 +0000

    mail-filter/amavisd-new: new revision to clean up auxiliary init scripts.
    
      * Two new service scripts for amavisd-snmp-agent{,-zmq}. Prior, both
        of these programs were installed, but had only a single service
        script which tried to figure out what to do at runtime. The new
        way is cleaner, doesn't rely on bashisms (bug 630896), and fixes
        a security issue (bug 630898).
    
      * A new OpenRC service script for amavis-mc. This fixes an
        unreported (to Gentoo, anyway) security issue. This program can
        create its PID file only after dropping privileges, which makes it
        unsafe for OpenRC to later "kill" it. The new script runs the
        program in the foreground and lets OpenRC (safely) handle the
        bookkeeping.
    
    Closes: https://bugs.gentoo.org/630896
    Bug: https://bugs.gentoo.org/630898
    Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
    Package-Manager: Portage-2.3.51, Repoman-2.3.11

 .../amavisd-new/amavisd-new-2.11.1-r2.ebuild       | 198 +++++++++++++++++++++
 mail-filter/amavisd-new/files/amavis-mc.initd-r1   |  18 ++
 .../files/amavisd-snmp-subagent-zmq.initd          |  26 +++
 .../amavisd-new/files/amavisd-snmp-subagent.initd  |  25 +++
 4 files changed, 267 insertions(+)
Comment 2 Andreas K. Hüttel archtester gentoo-dev 2019-01-26 01:29:05 UTC
Please do stabilize (also blocks glibc-2.28)
Comment 3 Michael Orlitzky gentoo-dev 2019-01-26 02:09:21 UTC
(In reply to Andreas K. Hüttel from comment #2)
> Please do stabilize (also blocks glibc-2.28)

*thumbs up*
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2019-01-31 22:17:49 UTC
x86 stable
Comment 5 Rolf Eike Beer archtester 2019-02-03 11:00:42 UTC
sparc stable
Comment 6 Mikle Kolyada (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2019-02-07 10:48:16 UTC
amd64 stable
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2019-02-09 20:02:10 UTC
hppa stable
Comment 8 ernsteiswuerfel archtester 2019-02-17 17:08:35 UTC
Looking good on ppc64.

# cat amavisd-new-630898.report 
USE tests started on So 17. Feb 17:16:03 CET 2019

FEATURES=' test' USE='' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav courier dkim -ldap mysql -postgres -qmail razor -snmp -spamassassin -zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav -courier dkim ldap mysql postgres qmail razor -snmp -spamassassin -zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav courier dkim ldap mysql postgres qmail -razor snmp -spamassassin -zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav -courier -dkim ldap -mysql -postgres -qmail razor snmp -spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='-clamav -courier -dkim ldap mysql postgres qmail razor snmp -spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav courier -dkim -ldap -mysql -postgres -qmail -razor -snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='-clamav -courier dkim ldap -mysql -postgres -qmail -razor -snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='-clamav courier -dkim ldap mysql -postgres -qmail -razor -snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav courier dkim -ldap -mysql -postgres -qmail -razor snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav courier dkim ldap -mysql postgres qmail -razor snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='-clamav -courier -dkim ldap -mysql postgres -qmail razor snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
USE='clamav -courier -dkim -ldap mysql -postgres qmail razor snmp spamassassin zmq' succeeded for =mail-filter/amavisd-new-2.11.1-r3
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2019-02-17 17:51:52 UTC
ppc64 stable thanks to ernsteiswuerfel!
Comment 10 Andreas K. Hüttel archtester gentoo-dev 2019-02-24 01:36:43 UTC
All arches done
Comment 11 Michael Orlitzky gentoo-dev 2019-02-24 02:01:40 UTC
Security: Andreas also cleaned up the old vulnerable versions.
Comment 12 Larry the Git Cow gentoo-dev 2019-02-24 02:34:40 UTC
The bug has been referenced in the following commit(s):

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

commit 072fd49134ed3c404a44e0cb8eb564b3b00f9cd9
Author:     Michael Orlitzky <mjo@gentoo.org>
AuthorDate: 2019-02-24 02:06:39 +0000
Commit:     Michael Orlitzky <mjo@gentoo.org>
CommitDate: 2019-02-24 02:33:35 +0000

    mail-filter/amavisd-new: remove now-unused files.
    
    Bug: https://bugs.gentoo.org/630898
    Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
    Package-Manager: Portage-2.3.51, Repoman-2.3.11

 mail-filter/amavisd-new/files/amavis-mc.initd  | 17 ----------
 mail-filter/amavisd-new/files/amavisd.initd-r1 | 44 --------------------------
 mail-filter/amavisd-new/files/amavisd.service  | 22 -------------
 3 files changed, 83 deletions(-)