Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 628602 - app-admin/mms-agent: privilege escalation via PID file manipulation
Summary: app-admin/mms-agent: privilege escalation via PID file manipulation
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B4 [ebuild]
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-22 13:16 UTC by Michael Orlitzky
Modified: 2021-02-08 09:42 UTC (History)
3 users (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-08-22 13:16:08 UTC
The init script for mms-agent gives ownership of the PID file directory to the same user that the daemon runs as:

  start_pre() {
    checkpath -d -m 0750 -o "${user}":"${group}" "${run_dir}"
    cd /opt/mms-monitoring-agent
  }

As a result, the $user can write whatever he wants into the PID file. Later, that may be exploitable: when the service is stopped, root will call "kill" on the contents of that file.

But there's good news: there's no need for the call to "checkpath" above. With command_background=true, OpenRC creates the PID file as root:root, and the checkpath call can be deleted if you store the PID file directly in /run. That is, if you delete the $run_dir variable, and set pidfile=/run/${RC_SVCNAME}.pid

Some other minor improvements to consider while you're touching the init script:

  1. Update SVCNAME to the more-modern RC_SVCNAME.

  2. Use "command_user" for the user/group instead of start_stop_daemon_args.

  3. Right now you have command="./mongodb-mms-monitoring-agent &>${logfile}"
     in order to save stderr and stdout to $logfile. I believe that you
     can use the --stderr and --stdout options of start-stop-daemon
     (through start_stop_daemon_args) to achieve the same thing.
Comment 1 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-06-11 05:25:35 UTC
Maintainer: Ping.
Comment 2 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2020-10-16 18:14:23 UTC
Ping
Comment 3 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2021-01-25 19:09:33 UTC
Hasn't been touched by maintainer since just before this bug was opened. I guess if no one is there this should be treecleaned. No revdeps, a couple of other bugs open.
Comment 4 Ultrabug gentoo-dev 2021-02-08 09:42:05 UTC
masked, due for removal in #769509