Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 122951 - sys-apps/coreutils: privilege escalation with FEATURES="maketest"
Summary: sys-apps/coreutils: privilege escalation with FEATURES="maketest"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Other
: High critical (vote)
Assignee: Gentoo Security
URL:
Whiteboard: A1 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-15 12:13 UTC by Joshua Pettett
Modified: 2006-02-20 09:44 UTC (History)
1 user (show)

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


Attachments
Automated exploit of privilege escalation vulnerability (coreutils test vulnerability exploit.pl,5.91 KB, text/plain)
2006-02-15 12:23 UTC, Joshua Pettett
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Pettett 2006-02-15 12:13:15 UTC
Compile tests for coreutils are world editable but run by root, allowing for local privilege escalation during test phase of emerge.  While exposure is limited, I think the implications are serious.  Will attach example exploit.
Comment 1 Joshua Pettett 2006-02-15 12:23:18 UTC
Created attachment 79866 [details]
Automated exploit of privilege escalation vulnerability

This perl script is designed to automatically exploit the coreutils emerge operation (assuming it's run with FEATURES="maketest") and present an unprivileged user with a root shell.

WARNING: THIS SCRIPT *WILL* DAMAGE YOUR SYSTEM'S SECURITY AND MAY WREAK HAVOC.
Comment 2 SpanKY gentoo-dev 2006-02-15 19:39:09 UTC
i dont get it

portage marks $WORKDIR as 700

how are non-root users supposed to get into that ?
Comment 3 Joshua Pettett 2006-02-15 20:24:22 UTC
(In reply to comment #2)
> i dont get it
> 
> portage marks $WORKDIR as 700
> 
> how are non-root users supposed to get into that ?
> 

Perhaps this?

coreutils-5.93.ebuild, line 98: chmod a+rx "${WORKDIR}"
Comment 4 Tavis Ormandy (RETIRED) gentoo-dev 2006-02-16 02:14:40 UTC
base-system, please comment
Comment 5 SpanKY gentoo-dev 2006-02-16 06:06:06 UTC
that would do it

simply adding a `chmod -R go-w ${WORKDIR}` should fix it
Comment 6 Thierry Carrez (RETIRED) gentoo-dev 2006-02-16 12:42:15 UTC
adjusting severity.
Comment 7 SpanKY gentoo-dev 2006-02-17 04:29:32 UTC
fixed in cvs now
Comment 8 Thierry Carrez (RETIRED) gentoo-dev 2006-02-18 03:28:58 UTC
In fact this doesn't need a GLSA...

The idea being, this happens only when you emerge the thing. Now, next time people upgrade coreutils, the vulnerability won't be there. There is no point in forcing people to do that (now safe) upgrade now. Those that have already a "vulnerable" coreutils installed are not vulnerable to anything now that it has been installed... And will be safe next time they upgrade.

We call this the "python-updater" precedent.
If everyone agrees we'll open this bug and close it without GLSA.

Joshua, many thanks for bringing this to our attention.
Comment 9 Stefan Cornelius (RETIRED) gentoo-dev 2006-02-18 03:31:32 UTC
Sounds reasonable, I agree.
Comment 10 Tavis Ormandy (RETIRED) gentoo-dev 2006-02-18 03:44:00 UTC
Makes sense, I agree.
Comment 11 Joshua Pettett 2006-02-18 13:16:39 UTC
(In reply to comment #8)
> Joshua, many thanks for bringing this to our attention.

Glad to be of service.  Thanks to all devs for working on this.

Some follow-up thoughts:

In the unlikely event that someone reemerges coreutils before resyncing (e.g. change in USE flags, or revdep-rebuild?), their system will still be vulnerable.  In not saying this warrants a GLSA, but I think it's something to keep in mind.

While I believe that the current fix to this bug is sufficient, I find it disconcerting that there were world-writable directories in the first place, especially since these didn't occur when I played with compiling the unpatched source straight from GNU.  This raises a few questions in my mind: What makes the tests' directories world-writable, and could whatever that is still introduce a race condition or another vulnerability, either now or in the future?  Are there other similar packages with the same or similar vulnerabilities?

Finally, it looks the current fix for this bug makes bug 122149 obsolete.
Comment 12 SpanKY gentoo-dev 2006-02-18 13:36:13 UTC
> While I believe that the current fix to this bug is sufficient, I find it
> disconcerting that there were world-writable directories in the first place,
> especially since these didn't occur when I played with compiling the unpatched
> source straight from GNU.

that's because you probably extracted the tarball as a non-root user ... the permissions arent fully restored as a non-root user, just as root

look at the output of `tar vvvtf coreutils-5.94.tar.bz2`
Comment 13 Thierry Carrez (RETIRED) gentoo-dev 2006-02-20 09:44:50 UTC
OK then, closing and opening.