Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 631004 - <dev-util/clair-2.0.1: privilege escalation via PID file manipulation
Summary: <dev-util/clair-2.0.1: 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 minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: ~3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-14 19:37 UTC by Michael Orlitzky
Modified: 2017-09-24 13:49 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-14 19:37:04 UTC
The init script for clair gives ownership of its PID file directory to its runtime user:

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

This can be exploited by that runtime 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 unnecessary: when OpenRC creates the PID file, it does so as root. So the vulnerability can be fixed by setting,

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

and deleting the start_pre() function.

Some other unrelated improvements:

  1. Change the deprecated $SVCNAME to $RC_SVCNAME.
  2. Use command_user instead of --user and --group in start_stop_daemon_args.
  3. One of "need net" and "after net" is redundant
  4. The ebuild runs,

       fowners ${PN}:${PN} /var/log/${PN}

     but the init script gives you the ability to switch users. If the
     user and group are ever switched, the ownership information on
     /var/log/clair will be wrong. Unless there's a good reason for it,
     I would settle on user=group=clair and leave it unconfigurable.
Comment 1 Manuel Rüger (RETIRED) gentoo-dev 2017-09-19 16:16:45 UTC
Thanks, fixed in:

commit 561022e669b16cf3a4c509f2aa9155db129ac9bc (HEAD -> master, origin/master, origin/HEAD)
Author: Manuel Rüger <mrueg@gentoo.org>
Date:   Tue Sep 19 18:16:02 2017 +0200

    dev-util/clair: Remove old
    
    Package-Manager: Portage-2.3.8, Repoman-2.3.3

commit 6f4dd6b9fba7d6951317298878eef5754e8ec882
Author: Manuel Rüger <mrueg@gentoo.org>
Date:   Tue Sep 19 18:15:21 2017 +0200

    dev-util/clair: Version bump to 2.0.1
    
    Package-Manager: Portage-2.3.8, Repoman-2.3.3
Comment 2 Christopher Díaz Riveros (RETIRED) gentoo-dev Security 2017-09-19 23:39:25 UTC
(In reply to Manuel Rüger from comment #1)
> Thanks, fixed in:
> 

Thank you Manuel.

Gentoo Security Padawan
ChrisADR