Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] User eix-sync permissions problem
Date: Tue, 11 Feb 2014 05:41:39
Message-Id: 52F9B807.4070306@gmail.com
In Reply to: Re: [gentoo-user] User eix-sync permissions problem by Walter Dnes
1 On 11/02/2014 03:23, Walter Dnes wrote:
2 > On Tue, Feb 11, 2014 at 12:28:43AM +0000, Kerin Millar wrote
3 >> On 10/02/2014 23:57, Walter Dnes wrote:
4 >>>
5 >>> What's the point, if you still have to run as root (or su or sudo) for
6 >>> the emerge update process?
7 >>
8 >> It's the principle of least privilege. Is there any specific reason for
9 >> portage to fork and exec rsync as root? Is rsync sandboxed? Should rsync
10 >> have unfettered read/write access to all mounted filesystems? Can it be
11 >> guaranteed that rsync hasn't been compromised? Can it be guaranteed that
12 >> PORTAGE_RSYNC_OPTS will contain safe options at all times?
13 >>
14 >> The answer to all of these questions is "no". Basically, the combination
15 >> of usersync and non-root ownership of PORTDIR hardens the process in a
16 >> sensible way while conferring no disadvantage.
17 >
18 > If /usr/portage is owned by portage:portage, then wouldn't a user
19 > (member of portage) be able to do mischief by tweaking ebuilds? E.g.
20 > modify an ebuild to point to a tarball located on a usb stick, at
21 > http://127.0.0.1/media/sdc1/my_tarball.tgz. This would allow a local
22 > user to supply code that gets built and then installed in /usr/bin, or
23 > /sbin, etc.
24 >
25
26 Yes, you can do that. You can also rm with gainful abandon all over the
27 place and wreak havoc like that. There are many attack vectors involving
28 user doing dumb things, and no software is ever going to deal fully with
29 user stupidity or mischief. Modifying an ebuild is no difference
30 attack-wise to putting it in a local overlay, and you can already do that.
31
32 What software security attempts to provide you is protection against
33 unexpected side-effects like a malformed path (eg unquoted spaces) in an
34 rm statement run as root, or bad guys out there banging on the door.
35
36 Once an attacker can run yoru shell, it's basically game over at that
37 point wrt security and just a matter of time. So you have a choice
38 between syncing as a regular user or syncing as root, there are pros and
39 cons to each. Experience shows that in the general case the former
40 offers more and better protection. But, if the latter really does suit
41 your specific needs, then you have the choice to do it that way.
42
43 You don't *have* to follow recommendations in man pages at all, but it's
44 highly recommended you be well informed when making your personal choice.
45
46
47
48 --
49 Alan McKinnon
50 alan.mckinnon@×××××.com