Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 628548 - app-admin/glance: privilege escalation via PID file manipulation
Summary: app-admin/glance: 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 normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-21 19:12 UTC by Michael Orlitzky
Modified: 2017-08-23 02:30 UTC (History)
2 users (show)

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


Attachments
init update (diff.diff,923 bytes, patch)
2017-08-22 23:57 UTC, Matthew Thode ( prometheanfire )
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2017-08-21 19:12:04 UTC
The init script for glance gives ownership of the PID file directory to the same user that the daemon runs as:

  start_pre() {
    checkpath --directory \
              --owner ${GLANCE_USER:-glance}:${GLANCE_GROUP:-glance} \
              --mode 0755 ${GLANCE_RUN:-/var/run/glance}
  }

As a result, the GLANCE_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 absolutely no reason for the call to "checkpath" above. With command_background=yes, OpenRC creates the PID file as root:root, and the whole start_pre() function can be deleted if you store the PID file directly in /run.

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

  1. Update $SVCNAME to $RC_SVCNAME.
  2. Utilize command_user for the user/group instead of start_stop_daemon_args
  3. Update to /run from /var/run
Comment 1 Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2017-08-22 23:57:55 UTC
Created attachment 490180 [details, diff]
init update

look good?
Comment 2 Michael Orlitzky gentoo-dev 2017-08-23 00:15:04 UTC
> pidfile=/var/run/glance/${RC_SVCNAME}.pid

/var/run/glance won't usually exist without the call to "checkpath", but the PID file will be created as root, so

  pidfile=/run/${RC_SVCNAME}.pid

should work fine (/var/run is a symlink to run these days).

Otherwise, looks good.
Comment 3 Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2017-08-23 02:30:34 UTC
thanks, in 14.0.0-r1 and 2017.1.9999