Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 631140 (CVE-2017-20147) - net-analyzer/smokeping: privilege escalation via PID file manipulation
Summary: net-analyzer/smokeping: privilege escalation via PID file manipulation
Status: RESOLVED FIXED
Alias: CVE-2017-20147
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B3 [glsa+]
Keywords:
Depends on: 651212 651646
Blocks:
  Show dependency tree
 
Reported: 2017-09-16 18:01 UTC by Michael Orlitzky
Modified: 2022-09-25 13:56 UTC (History)
2 users (show)

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


Attachments
smokeping-2.6.11-r1.ebuild (smokeping-2.6.11-r1.ebuild,4.10 KB, text/plain)
2017-09-16 18:01 UTC, Michael Orlitzky
no flags Details
smokeping.init.5 (smokeping.init.5,1.32 KB, text/plain)
2017-09-16 18:02 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-16 18:01:56 UTC
Created attachment 494768 [details]
smokeping-2.6.11-r1.ebuild

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

  start() {
      checkconfig || return 1

      checkpath -d -m 0755 -o smokeping:smokeping /run/smokeping
      ...

This can be exploited by the "smokeping" user to kill root processes, since when the service is stopped, root will send a SIGTERM to the contents of the PID file (which are under the control of the "smokeping" user).

Since smokeping cannot drop privileges itself, there is no way to safely use the PID file that it creates: to run as a restricted user, we need start-stop-daemon to execute smokeping as a restricted user, after which it's already to late.

I've rewritten the init script to work around this by passing "--nodaemon" to smokeping, and by letting OpenRC background it and manage its PID file. Since smokeping insists on writing a PID file (it won't start otherwise), I've modified the ebuild to stick the unsafe PID file in /var/lib/smokeping. Now that /run/smokeping is unused, the tmpfiles.d entry is no longer needed.
Comment 1 Michael Orlitzky gentoo-dev 2017-09-16 18:02:21 UTC
Created attachment 494770 [details]
smokeping.init.5
Comment 2 Michael Orlitzky gentoo-dev 2017-09-16 18:05:07 UTC
One more thing: I dropped the line,

  checkpath -d -m 0755 -o smokeping:smokeping /var/cache/smokeping

because /var/cache/smokeping doesn't appear in the config anywhere (and apparently systemd doesn't need it). If I messed that up, just add it back.
Comment 3 D'juan McDonald (domhnall) 2017-10-03 06:58:57 UTC
@maintainer(s), ebuild provided, please call for stabilization when ready, thank you.

Gentoo Security Padawan
Daj Uan (jmbailey/mbailey_j)
Comment 4 Aaron Bauman (RETIRED) gentoo-dev 2017-10-20 02:43:11 UTC
(In reply to jmbailey from comment #3)
> @maintainer(s), ebuild provided, please call for stabilization when ready,
> thank you.
> 
> Gentoo Security Padawan
> Daj Uan (jmbailey/mbailey_j)

the ebuild would need to be in the tree first.
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2018-02-06 06:38:55 UTC
(In reply to Michael Orlitzky from comment #1)
> Created attachment 494770 [details]
> smokeping.init.5

It looks like this new init.d script does not fix bug #602652.
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2018-02-08 19:44:54 UTC
(In reply to Jeroen Roovers from comment #5)
> (In reply to Michael Orlitzky from comment #1)
> > Created attachment 494770 [details]
> > smokeping.init.5
> 
> It looks like this new init.d script does not fix bug #602652.

That said, I have added it in 2.7.1.
Comment 7 nic 2018-03-26 20:08:51 UTC
--nodaemon breaks event logging to syslog bug #651212
Comment 8 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-06-18 00:55:56 UTC
Maintainer(s): Ping.
Comment 9 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-08-14 19:01:55 UTC
commit eeb4da5e8fa5e420eaa8756e1ab144d2799d1108
Author: John Helmert III <ajak@gentoo.org>
Date:   Sun Aug 14 13:58:42 2022 -0500

    profiles: last rite net-analyzer/smokeping

    Signed-off-by: John Helmert III <ajak@gentoo.org>
Comment 10 Larry the Git Cow gentoo-dev 2022-09-18 21:23:37 UTC
The bug has been referenced in the following commit(s):

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

commit 2310b0cd4914c79b2e8f3cb424259bb6e635a195
Author:     John Helmert III <ajak@gentoo.org>
AuthorDate: 2022-09-18 21:16:58 +0000
Commit:     John Helmert III <ajak@gentoo.org>
CommitDate: 2022-09-18 21:16:58 +0000

    net-analyzer/smokeping: treeclean
    
    Bug: https://bugs.gentoo.org/631140
    Signed-off-by: John Helmert III <ajak@gentoo.org>

 net-analyzer/smokeping/Manifest                  |   1 -
 net-analyzer/smokeping/files/79_smokeping.conf   |  15 ---
 net-analyzer/smokeping/files/smokeping.conf      |   1 -
 net-analyzer/smokeping/files/smokeping.init.5    |  56 ---------
 net-analyzer/smokeping/files/smokeping.service   |  10 --
 net-analyzer/smokeping/metadata.xml              |  12 --
 net-analyzer/smokeping/smokeping-2.7.3-r1.ebuild | 143 -----------------------
 profiles/package.mask                            |   5 -
 8 files changed, 243 deletions(-)
Comment 11 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-09-19 18:06:09 UTC
GLSA request filed, CVE pending
Comment 12 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-09-25 13:39:56 UTC
GLSA released, all done!
Comment 13 Larry the Git Cow gentoo-dev 2022-09-25 13:56:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/data/glsa.git/commit/?id=43b264c01a53f702e49274e4685d2a50c5d40ca2

commit 43b264c01a53f702e49274e4685d2a50c5d40ca2
Author:     GLSAMaker <glsamaker@gentoo.org>
AuthorDate: 2022-09-25 13:34:27 +0000
Commit:     John Helmert III <ajak@gentoo.org>
CommitDate: 2022-09-25 13:42:20 +0000

    [ GLSA 202209-08 ] Smokeping: Multiple vulnerabilities
    
    Bug: https://bugs.gentoo.org/602562
    Bug: https://bugs.gentoo.org/631140
    Signed-off-by: GLSAMaker <glsamaker@gentoo.org>
    Signed-off-by: John Helmert III <ajak@gentoo.org>

 glsa-202209-08.xml | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)