LWN: Comments on "Anatomy of a user namespaces vulnerability"
http://lwn.net/Articles/543273/
This is a special feed containing comments posted
to the individual LWN article titled "Anatomy of a user namespaces vulnerability".
hourly2Setting protected *links
http://lwn.net/Articles/546215/rss
2013-04-05T21:11:17+00:00mathstuf
<div class="FormattedComment">
You could also drop a file in /etc/sysctl.d/99-jed.conf file instead of conflicting with package manager-controlled files.<br>
</div>
Setting protected *links
http://lwn.net/Articles/545529/rss
2013-04-02T06:23:49+00:00Duncan
<div class="FormattedComment">
<font class="QuotedText">> # cat /proc/sys/fs/protected_hardlinks</font><br>
<font class="QuotedText">> 0</font><br>
<font class="QuotedText">> </font><br>
<font class="QuotedText">> Where to enable this option permanently?</font><br>
<p>
Assuming fedora has the common sysctrl initscript/unitfile, along with the associated /etc/sysctrl.d/* and/or /etc/syctrl.conf, you'd set it there (omitting the /proc/sys bit as that's the normal working dir for this unit/script).<br>
<p>
As I follow upstream kernel development reasonably closely on both LWN and independently (running a custom configured Linus git kernel), I saw the feature introduced for kernel 3.7, and added entries to my sysctrl.conf file appropriately (JED are my initials, used to distinguish my own modifications, $>> is the non-root version of the last line of my custom-set $PS1 bash prompt (#>> would indicate root, appearing as green on red so there's no mistaking it):<br>
<p>
$>>grep protected /etc/sysctl.conf <br>
# JED: protected sticky/tempdir symlinks/hardlinks (kernel 3.7+)<br>
fs.protected_symlinks = 1<br>
fs.protected_hardlinks = 1<br>
<p>
<p>
Duncan<br>
<p>
</div>
Complexity
http://lwn.net/Articles/544371/rss
2013-03-25T18:46:32+00:00luto
Chrooting to an empty, unwritable directory, closing fds and dropping privileges denies useful filesystem access. A kernel that suddenly changes that is not okay and should be fixed.
(And that's one of the bugs I found. Guess I might as well make the whole thing public.)
Complexity
http://lwn.net/Articles/544312/rss
2013-03-25T11:00:27+00:00talex
<div class="FormattedComment">
<font class="QuotedText">> why should you be able to install new software on the system without the permission of the admin of that system?</font><br>
<p>
That's just the way Linux works. Any user can cause executable files to be written to their home directory, and can then run them. But, like most people, I am the admin of my computer, so I don't need to ask anyone's permission to install software.<br>
<p>
<font class="QuotedText">> if 0install needs to run tar as root to install it's applications, and you don't want to trust tar as root, then you shouldn't trust it. untar the files as the user and then change their permissions afterwords.</font><br>
<p>
0install doesn't run tar as root. It runs it as my normal user. But that's still more privileges that I'd like to give it.<br>
<p>
For example, let's say I'm installing OpenTTD. Currently, 0install downloads the archive as my user (talex), unpacks it, verifies it, and runs it. OpenTTD does not gain root privileges on my system, but it does run with my user privileges. I'd like to restrict it further so that, for example, it can't read or write to my home directory (or anywhere except it's own data directory).<br>
<p>
<font class="QuotedText">> But namespaces are intended to replace chroot, so you would not be likely to use chroot and namespaces together.</font><br>
<p>
So, what is the replacement for chroot in the new namespaces world then? Should I unmount all existing filesystems and mount something new over the real root? I'm not sure how to do that.<br>
</div>
Complexity
http://lwn.net/Articles/544306/rss
2013-03-25T10:17:29+00:00dlang
<div class="FormattedComment">
why should you be able to install new software on the system without the permission of the admin of that system?<br>
<p>
if 0install needs to run tar as root to install it's applications, and you don't want to trust tar as root, then you shouldn't trust it. untar the files as the user and then change their permissions afterwords.<br>
<p>
And if you think that users should be able to change the ownership of files to be other users without requiring some sort of privilege, you just don't understand the concepts.<br>
<p>
<p>
Namespaces makes it possible to escape from a chroot, because they let the user become root inside a changeroot.<br>
<p>
But namespaces are intended to replace chroot, so you would not be likely to use chroot and namespaces together.<br>
<p>
now, once distros start enabling all these namespaces by default, they end up weakening the security of anything that's using chroot, but if a distro is doing that, the distro should be changing the programs to be locked down via namespaces limitations instead<br>
<p>
nobody should be using Fedora in production, it's bleeding edge, and exposing this sort of security problem where namespaces interact badly with each other and with other features is exactly the sort of bleeding that such a distro produces.<br>
</div>
Complexity
http://lwn.net/Articles/544299/rss
2013-03-25T09:42:03+00:00talex
<div class="FormattedComment">
<font class="QuotedText">> Root can mount things inside the chroot, create device files, etc and so it's possible for someone to escape out of a chroot after they become root.</font><br>
<p>
As I understand it: with user namespaces, *anyone* can escape from a chroot. At least, that seemed to be the case when I tested it (I was experimenting with using namespaces to sandbox some aspects of 0install:<br>
<a href="http://thread.gmane.org/gmane.comp.file-systems.zero-install.devel/6805/focus=6807">http://thread.gmane.org/gmane.comp.file-systems.zero-inst...</a> )<br>
<p>
<font class="QuotedText">> If these namespaces could only be setup by root, we would not really be any worse off, but since people are so fascinated by the "my admin won't let me do X, so I'm going to figure out a way to do it anyway" problem that they are giving too much power to non-root users.</font><br>
<p>
The problem with that (only making security features available to root) is that then prorgammers can't use them. For example, 0install needs to unpack archives it downloads. Since tar may contain bugs, we'd like to run tar in a restricted environment (e.g. a chroot where /home doesn't exist). If that requires root, then 0install itself has to be setuid, which is not good.<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/544247/rss
2013-03-24T17:47:47+00:00rahulsundaram
<div class="FormattedComment">
It is enabled in Fedora 19 by default and I am not sure there is a list of options documented that can be enabled in general. If they were, they probably would be there by default anyway.<br>
<p>
<p>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/544243/rss
2013-03-24T16:40:18+00:00meyert
<div class="FormattedComment">
Is there actually a list of options that better where enabled in Fedora, from a security point of view? like this other one I know about:<br>
<a href="https://fedoraproject.org/wiki/Features/SELinuxDenyPtrace">https://fedoraproject.org/wiki/Features/SELinuxDenyPtrace</a><br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/544242/rss
2013-03-24T16:38:08+00:00meyert
<div class="FormattedComment">
So, why isn't this set to "enabled" on current Fedora 18?<br>
<p>
# cat /proc/sys/fs/protected_hardlinks<br>
0<br>
<p>
Where to enable this option permanently?<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/544224/rss
2013-03-24T11:36:16+00:00kleptog
<div class="FormattedComment">
Given the complexity of the feature, it's unfortunate no-one specialising in making such exploits offered to test or tested the code prior to it being shipped.<br>
<p>
It would of course be cynical to suggest that it's because finding exploits in released kernels gets more credits that finding exploits in code under development.<br>
</div>
Complexity
http://lwn.net/Articles/544009/rss
2013-03-22T18:41:34+00:00dlang
<div class="FormattedComment">
<font class="QuotedText">> The problem with chroot, as I was told, is that it is not and has never been a security mechanism.</font><br>
<p>
It depends on how you define 'security mechanism'<br>
<p>
chroot has always provided security in that processes in a chroot in that it prevented that process from accessing any files outside that chroot.<br>
<p>
This doesn't mean that this security couldn't be bypassed (if you could get root inside the chroot), but if you did not have root in the chroot, it helped.<br>
<p>
for example, if a server had a vulerability that allowed it to access arbitrary files on the filesystem, putting it in a chroot can be very useful.<br>
</div>
Complexity
http://lwn.net/Articles/543902/rss
2013-03-22T08:48:44+00:00jezuch
<div class="FormattedComment">
<font class="QuotedText">> the problem with chroot has been that it's not perfect.</font><br>
<p>
The problem with chroot, as I was told, is that it is not and has never been a security mechanism.<br>
</div>
Complexity
http://lwn.net/Articles/543884/rss
2013-03-21T22:58:27+00:00dlang
<div class="FormattedComment">
the problem with chroot has been that it's not perfect.<br>
<p>
Root can mount things inside the chroot, create device files, etc and so it's possible for someone to escape out of a chroot after they become root.<br>
<p>
I've never bought into the 'this makes chroot worthless' mantra, it may only slow an attacker, but slowing an attacker can still be valuable.<br>
<p>
<p>
<p>
If these namespaces could only be setup by root, we would not really be any worse off, but since people are so fascinated by the "my admin won't let me do X, so I'm going to figure out a way to do it anyway" problem that they are giving too much power to non-root users.<br>
<p>
If you admin doesn't want to let you do something, go use a different box (including one where you are the admin), don't engineer a way around the admin's restrictions.<br>
</div>
Complexity
http://lwn.net/Articles/543883/rss
2013-03-21T22:49:22+00:00wahern
<div class="FormattedComment">
chroot does reduce the attack surface, considerably.<br>
<p>
No more setuid issues.<br>
<p>
No more /tmp race conditions.<br>
<p>
No more /dev.<br>
<p>
No more /proc.<br>
<p>
No more /sys.<br>
<p>
No more playing with named pipes or unix domain sockets owned by privileged processes.<br>
<p>
I'll never understand the attitude of "chroot isn't enough; let's instead add a layer of incredibly complex policy, and tens of thousands of lines of new code to the kernel". Yeah.. that's much better....<br>
<p>
It wasn't but a few years ago that one could confidently say that Linux shook the bugs out of simple stuff like file permissions, including setuid linker issues, and run-of-the-mill data races. Now we're adding a whole new set of incredibly complex subsystems and interfaces, and _willingly_ putting everybody through the grinder all over again.<br>
<p>
<p>
</div>
Complexity
http://lwn.net/Articles/543862/rss
2013-03-21T21:05:04+00:00dgc
<div class="FormattedComment">
<font class="QuotedText">> Maybe he's talking about debug file systems or tools that are available</font><br>
<font class="QuotedText">> for certain file systems like XFS that let you manipulate the inodes</font><br>
<font class="QuotedText">> of a filesystem directly?</font><br>
<p>
File handles are the problem. And when combined with interfaces like bulkstat, you've got a capability to find, open and *invisibly modify* any file in the filesystem regardless of namespace restrictions...<br>
<p>
<a href="http://oss.sgi.com/archives/xfs/2013-03/msg00382.html">http://oss.sgi.com/archives/xfs/2013-03/msg00382.html</a><br>
<p>
-Dave<br>
</div>
Complexity
http://lwn.net/Articles/543819/rss
2013-03-21T16:52:34+00:00butlerm
<div class="FormattedComment">
<font class="QuotedText">> Root by virtue of having privileged access can do whatever it wants to any file</font><br>
<p>
Isn't "root" now an ambiguous term? Don't we now have local root and global or system root? We certainly don't want local root to have privileges to do things like open arbitrary files by inode number. For filesystems the local root mounted or owns perhaps, but certainly not with regard to filesystems mounted by system root or other local root users.<br>
<p>
Unless the idea is to adopt the convention that "root" always refers to system root, and never to local root without further qualification, any such reference is likely to lead to some considerable degree of confusion. This thread is a perfect example.<br>
</div>
Complexity
http://lwn.net/Articles/543785/rss
2013-03-21T14:36:45+00:00dpquigl
<div class="FormattedComment">
I'm actually confused as to what his statement is to begin with. Root by virtue of having privileged access can do whatever it wants to any file assuming you don't bring capabilities or other access controls into the picture. Saying root has access to read/write to any inode or change any attributes is a vacuous statement since root can open any file in the filesystem read/write to begin with by virtue of being root. You don't need special APIs for that you just use open. Maybe he's talking about debug file systems or tools that are available for certain file systems like XFS that let you manipulate the inodes of a filesystem directly?<br>
</div>
Complexity
http://lwn.net/Articles/543732/rss
2013-03-21T10:48:51+00:00Tobu
chroot doesn't reduce the attack surface much because there's still the whole kernel, but I wouldn't call it a loophole. It's just a user namespaces forerunner, which should be combined with seccomp or similar if one wants a strong security boundary. suid on the other hand is an attractive nuisance: a simple design, but every privileged process that uses it has to be paranoid about its entire environment.
Complexity
http://lwn.net/Articles/543718/rss
2013-03-21T07:42:47+00:00lkundrak
<div class="FormattedComment">
I'm curious, which ones they are?<br>
</div>
Typos and such
http://lwn.net/Articles/543713/rss
2013-03-21T05:41:16+00:00epa
<div class="FormattedComment">
The comment form lets you choose plain text or HTML. It should also let you choose 'comment' or 'correction'. If a correction is posted when the LWN staff are not around it can be displayed with the comments until an editor has the chance to act on it.<br>
</div>
Complexity
http://lwn.net/Articles/543711/rss
2013-03-21T05:33:08+00:00dgc
<div class="FormattedComment">
Yup, consider that there are some filesystem APIs that allow root to have r/w access to all inodes and their attributes in a filesystem because they bypass the filesystem namespace altogether...<br>
<p>
-Dave.<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543697/rss
2013-03-21T00:57:55+00:00dlang
<div class="FormattedComment">
I also wonder about these 'odd' combinations.<br>
<p>
One thing I've found is that any time I tend to think "there's no reason for anyone to use _that_ combination", someone ends up running into a case where it's exactly the right thing to use.<br>
<p>
You almost need these things to be configurable. The problem is in figuring out how to do that without imposing unacceptable overhead in every fork() call.<br>
<p>
I wonder if the 'traditional' flags and combinations could be whitelisted into a very fast special case, and combinations that use the new flags/features branch off to a more flexible/detailed set of checks that may be a bit slower.<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543696/rss
2013-03-21T00:13:19+00:00butlerm
<div class="FormattedComment">
Wouldn't the combination of CLONE_NEWUSER and about half of the other CLONE_xxx options lead to potential security risks as well? After all one may request that processes in two completely different security contexts should share things they probably shouldn't - signal handlers, thread groups, memory spaces, SYS V semaphores, and so on.<br>
<p>
It is hard to see how most of that could possibly be useful in such a combination, and some of it looks positively dangerous. And if that is the case, wouldn't the conservative option be to disable the combination of CLONE_NEWUSER with everything that isn't recognized as necessary and/or useful? <br>
<p>
Perhaps it might also be worthwhile to consider renaming the CLONE_xxx options to clearly indicate which options actually clone things, which ones share things, and which ones create new things. With aliases for backward compatibility of course.<br>
<p>
</div>
Typos and such
http://lwn.net/Articles/543694/rss
2013-03-20T23:05:32+00:00corbet
It's been a while since we've needed to remind folks of the line of text right above the comment box:
<p>
<blockquote>
Please <b>do NOT post typos</b> in the article as comments, send them to lwn@lwn.net instead.
</blockquote>
<p>
The alternative is to clutter the comment stream with stuff that persists long after the error is fixed and benefits nobody.
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543693/rss
2013-03-20T22:57:06+00:00adler187
<div class="FormattedComment">
Also, grammar issue in the last sentence before "The Fix" section:<br>
<p>
"... user namespaces are unlikely to enable user namespaces in the kernels that they ship."<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543692/rss
2013-03-20T22:51:36+00:00Celest
<div class="FormattedComment">
Typo: user namespaces are unlikely to enable user namespaces -> the first "user namespaces" should be replaced by "distributors" I suppose.<br>
<p>
Great article. I really enjoy reading exploit walkthrough especially this one since it relates to namespace. Thanks!<br>
</div>
Complexity
http://lwn.net/Articles/543690/rss
2013-03-20T22:35:43+00:00smurf
<div class="FormattedComment">
Complexity is not the root problem.<br>
<p>
The root problem is that previously, once you gained root you had the master keys to the whole system. Game over. Now, anybody can create their personal little sandbox and you need to vet *every* activity to make sure that it doesn't spill over. That's something that Linux historically didn't do (no need); no wonder that a few cases which fell through the cracks.<br>
<p>
… and chroot() has a history of being a security loophole anyway.<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543681/rss
2013-03-20T21:48:48+00:00mkerrisk
<div class="FormattedComment">
<font class="QuotedText">> Typo in the first sentence: March 13th, not Feb 13th.</font><br>
<p>
Fixed.<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543678/rss
2013-03-20T21:45:12+00:00luto
<div class="FormattedComment">
If you enjoy thinking about security, please look at this stuff. It's really neat, but there is certainly lots of room for bugs.<br>
<p>
(I'll publicly post at least two more of varying severities once there are patches.)<br>
</div>
Anatomy of a user namespaces vulnerability
http://lwn.net/Articles/543671/rss
2013-03-20T21:28:02+00:00spender
<div class="FormattedComment">
Typo in the first sentence: March 13th, not Feb 13th.<br>
<p>
-Brad<br>
</div>