Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 629238 - <app-misc/uptimed-0.4.0-r1: privilege escalation via PID file manipulation
Summary: <app-misc/uptimed-0.4.0-r1: privilege escalation via PID file manipulation
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High critical
Assignee: Gentoo Security
URL:
Whiteboard: B3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-28 20:16 UTC by Michael Orlitzky
Modified: 2017-08-31 22:33 UTC (History)
1 user (show)

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


Attachments
uptimed.init-r1 (uptimed,730 bytes, text/plain)
2017-08-28 20:16 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-08-28 20:16:43 UTC
Created attachment 491034 [details]
uptimed.init-r1

The init script for uptimed gives ownership of its PID file directory to the same user that the daemon runs as:

  start_pre() {
      checkpath -q -d -o uptimed ${pidfile%/*}
  }

That's currently necessary because of the way the daemon is invoked,

  start_stop_daemon_args="-u uptimed"

but it poses a small security risk: the uptimed user can write whatever he wants in that file, and later, root will call "kill" on its contents in order to stop the service.

Normally the daemon would drop privileges itself, after creating the PID file, but uptimed doesn't know how to do that. Instead, we can work around the issue by running uptimed in the foreground, and having OpenRC background it for us. Then the PID file is created as root, and we can store it in /run/uptimed.pid. Afterwards, uptimed itself runs as a restricted user.

I'm attaching an init script that seems to do the trick.
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2017-08-28 23:05:24 UTC
commit 3eaffbeb6908660dc67de8a0fb8526de7dab9154 (HEAD -> master, origin/master, origin/HEAD)
Author: Lars Wendler <polynomial-c@gentoo.org>
Date:   Tue Aug 29 01:04:03 2017

    app-misc/uptimed: Revbump to fix PID file sec issue (bug #629238).

    Thanks to Michael Orlitzky for finding the issue and providing a fixed init
    script.
    Bumped straight to stable.

    Package-Manager: Portage-2.3.8, Repoman-2.3.3
Comment 2 D'juan McDonald (domhnall) 2017-08-29 04:28:48 UTC
@
Comment 3 Christopher Díaz Riveros (RETIRED) gentoo-dev Security 2017-08-29 05:18:04 UTC
@security: please add to an existing GLSA or file a new one. 

Gentoo Security Padawan
ChrisADR
Comment 4 Aaron Bauman (RETIRED) gentoo-dev 2017-08-31 22:33:40 UTC
While the user can "escalate" privileges to that of the uptimed user the process running under root is only killing services.  This is effectively a DoS scenario.

Michael, thanks for all of the great PID file work you have been doing!