Slashdot Mirror


Bug In Most Linuxes Can Give Untrusted Users Root

Red Midnight and other readers brought to our attention a bug in most deployed versions of Linux that could result in untrusted users getting root access. The bug was found by Brad Spengler last month. "The null pointer dereference flaw was only fixed in the upcoming 2.6.32 release candidate of the Linux kernel, making virtually all production versions in use at the moment vulnerable. While attacks can be prevented by implementing a common feature known as mmap_min_addr, the RHEL distribution... doesn't properly implement that protection... The... bug is mitigated by default on most Linux distributions, thanks to their correct implementation of the mmap_min_addr feature. ... [Spengler] said many other Linux users are also vulnerable because they run older versions or are forced to turn off [mmap_min_addr] to run certain types of applications." The register reprints a dialog from the OpenBSD-misc mailing list in which Theo De Raadt says, "For the record, this particular problem was resolved in OpenBSD a while back, in 2008. We are not super proud of the solution, but it is what seems best faced with a stupid Intel architectural choice. However, it seems that everyone else is slowly coming around to the same solution."

29 of 281 comments (clear)

  1. First post by wisty · · Score: 5, Insightful

    But you don't know if I didn't just hack the servers ;)

  2. Patch by tomtomtom · · Score: 5, Informative

    For those who just want to know how to fix it, you need to apply this git commit to your kernel tree and then either recompile and reboot or apply the patch using ksplice.

    1. Re:Patch by Xonea · · Score: 5, Informative

      Or, if you want to wait for your vendor patch, set vm.mmap_min_addr manually, if it hasn't been set by your vendor already - the only distribution I have where this is necessary is debian.

      You can either do
      # sysctl -w vm.mmap_min_addr = 65536
      and redo that every reboot or do

      # echo "vm.mmap_min_addr = 65536" > /etc/sysctl.d/mmap_min_addr.conf
      # /etc/init.d/procps restart
      and be done with it.

    2. Re:Patch by gbarules2999 · · Score: 3, Funny

      That fix is kind of a pain because you have to use Windows. I've found a much more logical fix here.

  3. sysctl vm.mmap_min_addr by MrMr · · Score: 3, Informative

    If the result is non-zero the vulnerability doesn't exist.
    'Most deployed versions of linux'?.
    So far only some unpatched RHEL versions allow this local exploit, even the Centos rip-off doesn't have it.

  4. Re:Isn't this a dupe? by Xonea · · Score: 5, Informative

    Nope, it is a new one, but the same old bugfix still works.

    Just type sysctl -w vm.mmap_min_addr=4096 in your box (or any other number > 0) and you are safe.

  5. Re:Another story that isnt a story by Xonea · · Score: 3, Informative

    It says that it was only fixed " in the upcoming 2.6.32 release candidate of the Linux kernel" - hence everything before that is vulnerable.

    But the bug is not exploitable on ubuntu, because they set vm.mmap_min_addr > 0 by default.

  6. standard author/exploiter response? by Gopal.V · · Score: 5, Insightful

    I'm not a real security guy, but my experiences with security bug reporting shows that nearly all such subtle bugs are pooh-poohed by the original authors till the exploit writer resorts to petulant scaremongering. I'm not sure which one is to blame for either one's behaviour.

    All of these attacks IIRC require you to be able to mmap() page zero. Which is why mmap_min_addr is almost never set low enough in a decently protected OS. But the fact is that the exploit is a valid bug for a system which hasn't got that set to 4k. And there is a valid root exploit using pulseaudio (*ouch*) as a vector.

    Linus might have been right in saying setuid is a 'vulnerability', but to call it a design flaw is wrong. Setuid is not a design flaw, it is a trade-off - needed for something as simple as 'ping' to function (yeah, ping's got setuid, check it).

    Being able to exploit a setuid binary after mmap'ing page zero with executable shell code, via a phpbb vulnerability which is exposed because of lack of php filtering is like saying ... "look, having arranged these six dominoes, I only need to push *one* over".

    I'm not denying either of them aren't right in their own way - but invariably original author vs security researcher sets up a very immature exchange of insults (and the ego of both types don't help either).

    1. Re:standard author/exploiter response? by Late+Adopter · · Score: 3, Insightful

      The only way to remove the setuid requirement from ping (apart from making your system thoroughly insecure) is to allow messages to be sent and received on raw sockets opened by non-root only if they're ICMP ECHO messages (I'm not aware of any other ICMP messages that it's useful for user code to send).

      That's absolutely not the only way. You can make raw sockets accessible via a node in /dev, which you can assign to a group, control membership in, and setuid/setgid a NON-root user to "ping".

      A *lot* of system resources are controlled in this manner (dri, sound, disks). I still don't think it's a sufficiently versatile security model (cf my comment on sandboxing), but it's a good place to start.

  7. And? by FlyingBishop · · Score: 5, Interesting

    Torvalds:

    That does not look like a kernel problem to me at all. He's running a setuid program that allows the user to specify its own modules. And then you people are surprised he gets local root?

    Am I missing something? Torvald's reply actually sounds pretty reasonable to me here. It might be nice if this exploit could be patched, but it seems a little preposterous to me that you could make that work in a way that doesn't leave an exploit. I'd say you need to be locking down your suid binaries more, not blaming kernel management.

    1. Re:And? by kscguru · · Score: 3, Informative
      http://en.wikipedia.org/wiki/Security_theater

      Torvalds is absolutely correct, the whole issue is idiotic and isn't really an "exploit" because it doesn't result in ANY privilege escalation. (You must be root to run an exploit that gives you, um, root!) However, ego-starved security people get to jump up and down thumping their chests about how they h@x0r3d an extremely common Linux distribution and get their names splashed all over the press. Yeah, and instead of mmapping NULL, you can just 'insmod /my/evil.ko' and get the same effect. Sigh.

      Those of us who know anything about security just ignore these "researchers". There are far more important bugs - even far more important security bugs - than a root-to-root non-issue. I'll happily patch my system with the next set of kernel updates, but I don't intend to grab it any sooner. It's more important to me that my system stay up and avoid regressions than fix a root-can-get-root non-exploit.

      --

      A witty [sig] proves nothing. --Voltaire

  8. Re:obvious troll is obvious. by blueskies · · Score: 3, Insightful

    OS persons would be jumping about like grass-hoppers that THIS could never happen in OS software...The Many Eyes theory looks weak...

    You misunderstand then. It's not the point that it could never happen, but that it gets found and fixed. This bug was found in the absence of proof of concept code unlike the reverse situation.

  9. Re:Somebody fill me in.. by Daniel_Staal · · Score: 3, Funny

    It's not Linus and Theo, it's Theo and everybody.

    And yes, it's dueling egos. Theo is a very good coder, and OpenBSD is an amazing system, but Theo should stop talking to the public. It never helps. (Even when he's right, which he usually is when the discussion involves something technical.)

    --
    'Sensible' is a curse word.
  10. Re:Isn't this a dupe? by gzipped_tar · · Score: 3, Informative

    This is from Fedora running kernel 2.6.30 with minimal customization (almost default, and no tweaking related to this one):

    $ cat /proc/sys/vm/mmap_min_addr
    65536

    The devs seem to be doing an adequate job to mitigate this problem.

    --
    Colorless green Cthulhu waits dreaming furiously.
  11. Re:Bishop bashing bonobos by babblefrog · · Score: 5, Funny

    I thought Masturbating Monkey was Ubuntu 10.10?

  12. Re:Isn't this a dupe? by tayhimself · · Score: 4, Informative

    This solution works, please see the links below. However I would reccomend seing what your settings are on your system
    $ sysctl -n vm.mmap_min_addr to find what your setting is.
    On Ubuntu 8.04 LTS servers (including Xen kernels) and on 9.10 desktops it is 65536. Not a big deal.
    http://wiki.debian.org/mmap_min_addr
    https://lists.ubuntu.com/archives/ubuntu-devel/2008-July/025805.html
    http://www.securityfocus.com/bid/26831/info

  13. What's the deal with the masturbating monkeys? by Johnny+Loves+Linux · · Score: 5, Funny

    I read Theo's comments and he's going on an on about Torvald's fixation with masturbating monkeys. Then some member of the openBSD crowd even offers a link to purchasing "your very own" **masturbating monkey** http://www.wellcoolstuff.com/Merchant2/graphics/00000001/20-Apr-07-05.jpg

    Then I read Torvald's comment about the Linux exploit, with Torvald referring to the openBSD developers as being __like__ a "bunch of masturbating monkeys".

    Ok, so is this like some kind of secret code used among OS kernel developers? Like saying "my shoe is blue but the cow is hungry" really means "Oh man, this code is leaking memory and crashing my system"? Or is this some kind of secret initiation thing, where in order to truly become a member of the OS development club, you have to first ... masturbate a monkey??!! Can somebody explain it, or maybe do some investigative reporting on this?

  14. Re:Isn't this a dupe? by eparis · · Score: 5, Informative

    No, this isn't the same bug. People confuse two issues. I wrote the mmap_min_addr protections to try to mitigate the effects of a certain class of common kernel bugs which exist because of design choices by Intel. That class of bugs can be summed up as NULL pointer usage. Every time someone finds a new NULL pointer usage bug we get the same story. RHEL (and any system with SELinux enabled) did not have protections for mapping the 0 page by local authenticated users, but did have protections for network facing daemons and the like. Other distros had protections for the local authenticated user but weaker protections for network facing daemons. The mmap_min_addr protections have since been enhanced in SELinux systems such that they have stronger protections, both for local authenticated users and for network facing daemons. My old comments from the first time this came up are at http://eparis.livejournal.com/

    But the key to remember is that mmap_min_addr implementation is not the bug that allows elevation of privilege. In this case it was a very very old bug in the implementation of pipes. Previously Spender and friends have found bugs in performance counters (one which was actually much worse as it didn't fit into the very narrow class which might be mitigated by mmap_min_addr), in network sockets, and other places. These are the bugs which cause this to be a new story. Once he finds the real bugs he applies some of the same basic techniques (plus a whole lot of thought) to create an exploit. If the Linux kernel was bug free we wouldn't need mmap_min_addr. If mmap_min_addr was bug free (over the years Spender has found multiple problems with my work) this class of bugs would be just a bit less devastating.

    Everyone in the kernel development community needs to think of invalid pointer bugs as a larger security threat then they currently do. The lesson here, keep your systems patched.

  15. Re:Ubuntu not necessarily safe by eparis · · Score: 3, Informative

    Installing the wine package on ubuntu automatically sets mmap_min_addr to 0. The default install will have it set higher. Solution, remove wine.

  16. Re:Isn't this a dupe? by 0123456 · · Score: 4, Informative

    Ubuntu sets this to zero if you have wine installed.

  17. Re:Ubuntu not necessarily safe by eparis · · Score: 5, Informative

    A patched kernel will fix this particular bug, but as long as wine is installed and mmap_min_addr is being set to 0 you have no protections for the next bug. Unless wine can be changed (which some smart people have told me it can't), there's nothing you can do except accept a higher security risk on your system.

    Here's a fun tag line, "Windows applications can even make Linux less secure!"

  18. So it's a windows bug by Anonymous Coward · · Score: 5, Funny

    So it's a windows bug.

  19. Re:Bishop bashing bonobos by Anonymous Coward · · Score: 4, Funny

    Exactly, right before Nymphomaniac Nightingale

  20. Re:What design choice? by eparis · · Score: 5, Informative

    My understand in a short and simple answer: before the x86_64 architecture revolution it was possible to effectively have a separate virtual memory space for the kernel and userspace. With x86_64 segmentation was removed.

    Intel i686 processors had a pretty big performance hit if you used functionality since there was a TLB flush on every kernel trap. I don't believe many kernels made use of it. The PaX security patch set could and Red Hat's 4g/4g split kernels did (RH called them hugemem kernels, although I don't suggest them to anyone as they had their own issues.) The AMD Opteron processors actually had tagged TLBs so they didn't have to flush and performance didn't suffer nearly as badly.

    In any case, with x86_64 that ability is simply gone. SPARC is often named as an architecture which doesn't suffer from this specific class of bugs since it always had completely separate kernel space and userspace virtual memory. I heard rumour their might be a brilliant solution that will hopefully come from the PaX/grsecurity team, but I don't believe anything has materialized just yet.

  21. Re:I'd rather pay $400 for bugs likes this by MikeBabcock · · Score: 4, Insightful

    Lets compare apples to apples. Lets say you have an out-of-maintenance version of Linux (which would be some of the intermediate releases not in use by major distros) and your distro won't be patching you. You have the option of paying someone a lot less than $400 to back-port this patch to your kernel version or doing it yourself.

    Now lets say you have an unsupported version of Windows (like NT 3.51) and you find out there's a major security hole in Vista dating right back to 3.51. How are you going to get that fixed? If you answer "by upgrading" then use the same answer with Linux.

    The whole point of FOSS is that you're never stuck, you can always just do it yourself or pay someone to do it for you, the vendor can't lock you out of the code running on your systems.

    Of course, if you run a maintained version of any Enterprise Linux I'd put good bets down that they'll be patched shortly. If you spun your own distro, then you made the choice to maintain it yourself anyway.

    --
    - Michael T. Babcock (Yes, I blog)
  22. Re:Same Exploit from July? by rabtech · · Score: 4, Interesting

    What do you mean Windows requires it to work like this? On Windows accessing a NULL pointer is always an exception, no process is ever allowed to map the bottom page of memory. This has been true since Windows has existed. So in fact it is only Windows systems that are immune to this class of exploit because writing programs and kernel code vulnerable to it leads to an immediate crash.

    If you wanted to specify this invariant on Linux you could, you'd just break some existing apps that depend on it. Ironically, it seems that Wine depends on this behavior.

    --
    Natural != (nontoxic || beneficial)
  23. Re:Isn't this a dupe? by Senjutsu · · Score: 3, Informative

    Because Wine needs access to the bottom 64k of memory in order to run 16-bit DOS programs

  24. Re:Bishop bashing bonobos by drinkypoo · · Score: 4, Funny

    ...Orgasmic Orangutan...

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  25. Re:What design choice? by eparis · · Score: 4, Informative

    Most people expect that dereferencing a NULL pointer will result in some sort of fault. If you map the virtual page 0 and then do this you don't get a fault. Remember that NULL==0.
    mmap(0, ..., MAP_FIXED...
    char *p = NULL;
    *p = 'a';

    address 0 now contains the letter 'a' and the program does not fault.

    The idea is that if you do the mmap in userspace, fill that area with specially crafted information, then cause the kernel to hit a bug in the software (in this case a pipe) which dereferences a NULL pointer, you can make it operate on data you control. This is due to the fact that userspace and kernel operate in the same virtual address space. Sometimes (often?) this means you can take over the box.

    mmap_min_addr tries to address this problem by disallowing a program from mapping the low virtual address space. That means it ONLY affects the class of bugs that involve a NULL pointer. If it's a corrupt pointer instead a NULL pointer mmap_min_addr is totally useless. For either class of bugs hardware segmentation could help. It wouldn't be a security panacea, but it would eliminate the need for the specific hacks which both Linux and BSD use.