Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 628544 - <app-admin/consul-0.8.4-r1: privilege escalation via PID file manipulation
Summary: <app-admin/consul-0.8.4-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
: Normal normal
Assignee: Gentoo Security
URL:
Whiteboard: ~3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-21 18:52 UTC by Michael Orlitzky
Modified: 2017-09-01 12:50 UTC (History)
2 users (show)

See Also:
Package list:
=app-admin/consul-0.8.4-r1
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-21 18:52:43 UTC
The init script for consul gives ownership of the PID file directory to the same user that the daemon runs as:

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

As a result, the consul 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. 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. Can the OpenRC "stopsig" variable be used to eliminate stop() ?
  4. "after net" is redundant in light of "need net"
Comment 1 Christopher Díaz Riveros (RETIRED) gentoo-dev Security 2017-09-01 01:46:22 UTC
@Maintainers: Please let us know when the tree is clean from vulnerable versions.

Gentoo Security Padawan
ChrisADR
Comment 3 Aaron Bauman (RETIRED) gentoo-dev 2017-09-01 12:50:03 UTC
(In reply to Zac Medico from comment #2)
> Fixed init script in revbump to 0.8.4-r1:
> 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=0328499a524ab06a762ddfc3547df030586c7642
> 
> Removed vulnerable versions:
> 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=b1b7284d66c74f53588365eb310a9e80796e857f

Thanks, Zac!