Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 631544

Summary: sys-apps/man: root privilege escalation via "chown -R" in pkg_postinst
Product: Gentoo Security Reporter: Michael Orlitzky <mjo>
Component: AuditingAssignee: Gentoo Security <security>
Status: CONFIRMED ---    
Severity: normal CC: cardoe, chainsaw, chutzpah, hwoarang, polynomial-c, robbat2, security-audit, vapier, whissi, williamh
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Michael Orlitzky gentoo-dev 2017-09-20 16:41:06 UTC
The sys-apps/man ebuilds call "chown -R" on the live root filesystem in pkg_postinst:

  pkg_postinst() {
      einfo "Forcing sane permissions onto ${ROOT}var/cache/man (Bug #40322)"
      chown -R root:man "${ROOT}"/var/cache/man
      chmod -R g+w "${ROOT}"/var/cache/man

This can be exploited by anyone in the "man" group to gain root privileges. If a hard link is placed in /var/cache/man, then the next time sys-apps/man is upgraded or reinstalled, the "chown -R" will affect the target of the symlink, potentially making root-owned files writable by the "man" group. For example,

  1. emerge sys-apps/man
  2. su -s /bin/sh -c 'ln /etc/passwd /var/cache/man/x' man
  3. emerge sys-apps/man
  4. /etc/passwd is group-writable and root:man
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2020-04-03 23:16:28 UTC
Unrestricting and reassigning to security@ per bug #705894
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2020-04-03 23:18:24 UTC
unrestricting per bug 705894