Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 631142 - <net-analyzer/prometheus-1.8.0: privilege escalation via PID file manipulation
Summary: <net-analyzer/prometheus-1.8.0: 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:
Depends on:
Blocks:
 
Reported: 2017-09-16 18:17 UTC by Michael Orlitzky
Modified: 2017-10-26 01:28 UTC (History)
1 user (show)

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


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-16 18:17:30 UTC
The init script for prometheus gives ownership of its PID file directory to the prometheus $user:

  start_pre() {
      checkpath -d -m 0755 -o "${user}":"${group}" "${pidfile%/*}"
  }

That can be exploited by $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 controlled by $user).

Fortunately, the call to checkpath above is superfluous, and the PID file is already created as root. The vulnerability can be avoided by deleting start_pre() and then setting

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

at the top of the init script.

Some unrelated suggestions:

  1. Update the deprecated SVCNAME to RC_SVCNAME.
  2. Use the command_user variable instead of passing --user and --group to
     start-stop-daemon.
  3. The

       user=${user:-default}

     construct can also be written

       : ${user:=default}

  4. Changing $user and $group won't work because the log file permissions
     will be wrong. If it's all the same, you might just hard-code those
     variables to "prometheus".
  5. One of "need net" and "after net" is redundant.
Comment 1 Manuel Rüger (RETIRED) gentoo-dev 2017-10-26 01:15:52 UTC
All vulnerable versions should be removed.