Slashdot Mirror


OpenBSD Gains Privilege Elevation

ocipio writes "OpenBSD's systrace now has privilege elevation support. This means binaries no longer need to be suid or sgid an longer. Applications can be executed completely unprivileged. Systrace raises the privileges for a single system call depending on the configured policy."

33 of 309 comments (clear)

  1. Re:Serious! by FordPrfct · · Score: 3, Informative

    I think you misunderstand.

    The message referenced indicates that this is a security feature, which will allow the individual system calls to be executed with escalated privileges. This is an advantage in that you do not need to have the entire binary executed with the escalated privileges, and so reducing the number of potential privilege escalation attacks.

    --
    This signature carefully hand-crafted from recycled electrons.
  2. Re:Explanation? by roukounas · · Score: 5, Informative
    Google is your friend, and the next link seems quite informative:

    systrace

  3. Re:Serious! by shird · · Score: 2, Informative

    I think you misunderstood. The parent post is clearly a joke.

    --
    I.O.U One Sig.
  4. Re:Explanation? by photon317 · · Score: 5, Informative


    It's fine grained control of privelege. This is to the basic unix concept of running as a uid and setuid what ACLs are to normal unix filesystem permissions. For a really simplistic example - with this you could run your apache binary with literally zero priveleges, like "nobody" (from start to finish, no run as root then drop privs), and the explicitly enable it to have root-like privs only for the one system call it uses to listen to port 80.

    --
    11*43+456^2
  5. Doesn't any READ ? by XTerm89D · · Score: 4, Informative

    It's not a bug, it's a feature !


    For example the Apache webserver, it needs to be started as root, in order to bind to port 80. Now this is no longer required, since a call to the new function will allow it to bind to 80 as an regular user, provided that the syscall is configged to allow that.

    Same goes for X, which now no longer needs to be run SUID.

    It probably won't be long before these mechanism is common good, but I wonder what happens if someone finds an exploit in THAT ?

    1. Re:Doesn't any READ ? by Marillion · · Score: 5, Informative

      Under the UID 0 approach, all calls needed to do something. I haven't peeked at the code, but if I were to solve the problem, I would frontload the overhead of the syscall policy evaluation to the exec() call, store the results in a bitmap field. From there, it's bit math. A if (priv & PRIV_SOMECALL) has no more overhead than if (uid==0)

      --
      This is a boring sig
    2. Re:Doesn't any READ ? by lewp · · Score: 2, Informative

      It's not a "need to know" thing. AFAIK they aren't planning on taking SUID/SGID out of OpenBSD or anything.

      If you happen to know (or happen to be willing to find) the necessary syscalls you just get the advantage of a little better security. Even then, you don't have to do it if you don't want to.

      --
      Game... blouses.
    3. Re:Doesn't any READ ? by stripes · · Score: 3, Informative
      Or you could store your own syscalls table for each process. At exec(), you init the table so that all syscalls are redirected to your handler, which then performs the overhead of checking the policy. If the syscall is allowed under the policy, then the process syscall map would be updated with the proper syscall information. Future calls to the same syscall would be passed immediately onto the kernel with no more overhead than your normal syscall mechanism.

      Cool idea, and I know FreeBSD at least supports per-process syscall tables, that is how the Linux and BSD/OS "emulation" works. However having more syscall tables does have some real overhead, or could. When you do an indirect jump (table base address plus 4 times the syscall number is an indirect jump) if the jump can't be predicted you end up flushing the pipeline. Tieing that in with other slashdot articles that is 25 pipe stages times three instructions (max) for the P-III or 75 instructions worth of work or 6 cycles time 3 (or is it two?) instructions so 18 instructions for a PPC G4.

      Having another table per process may make the branch prediction much harder since you'll have many more addresses for the branch target cache to hold. Er, maybe. It won't make a difference if the BTC has to be flushed when there is a process context changed (many CPUs have something like a PID that can be used for the different caches to reduce that kind of churn). Also if the CPU does the BTC based off of the physical address this may not be such a big deal (at least if an effort is used to share the tables).

      Modern CPUs are a pain to optimize for.

  6. Re:2 things by kamakazi · · Score: 5, Informative

    There are things that must run as root to work. The common way to allow normal users to do these things was to make them setuid, which meant that the application always runs as its owner, no matter who launched it. Yes, this can be a security hole if not configured wisely. Stuff that requires configuring network interfaces is a good example. This method allows an application to be run as joe_user, but still access privileged system calls, depending on configuration. It is less of a security hole than what is being done now.

    --
    "Proximity to wonder has blunted our perception and appreciation of it" --Tim Hartnell in 'Exploring ARTIFICIAL INTELLI
  7. Re:Sounds like a (very) good thing by jhouserizer · · Score: 5, Informative

    Actually, this type of security is pervasive throughout the _standard_ Java libraries ... not just tied to netscape or any other implementation.

    Java's one of the few programming languages that has security built in from the ground up.

    And yes, this new BSD feature is VERY similar to Java's declaritive security mechanisms.

    (Please let's not start a war of "Java is cool vs. Java sucks", I wanted to provide the above!)
  8. Re:Interesting, but ... by alannon · · Score: 5, Informative

    chroot jails are almost completely unrelated to system-call security, unless the system call is to the file-system. chroot simply allows you to change the root of the file system so that the application cannot access part of the file-system beneath it. If the process is running as root, this helps nothing, since there are many ways of accessing the complete file-system bypassing the normal means if you are root.

  9. Re:Explanation? by pnatural · · Score: 5, Informative

    What they're doing here is simple and clever. The idea is to run an executable, trap it's privileged system calls, and then create a policy file (call to uid map) from the run. After the policy is in place and the executable is run again, the system promotes the calls listed in the policy to the appropriate privilege level. Any new privileged calls generate an error, as they're most likely a security breach or some part of the executable that never got executed the first time.

    A sample apache policy is here: http://www.citi.umich.edu/u/provos/systrace/usr_sb in_httpd.

  10. Only system calls? by Virtex · · Score: 5, Informative

    This sounds similar to an idea I've floated around to a few people, except that my idea worked on library functions. The idea was to allow setuid and setgid on individual functions instead of entire programs. When you called such a function, it would run with the elevated privileges determined by the ownership of the library file itself, and when it returned, permissions would go back to what they were previously.

    The one issue I had with this was what to do if a setuid function called another function. Should the privileges be passed onto the extra function? At first thought, it seems like it should, but consider this example:

    I have a library called libprivfunctions.so. Within this library is a function to open a privileged file:

    FILE *open_priv_file(void) {
    return fopen("/etc/priv.conf", "r");
    }

    We'll say this function is set to run as a setuid root (maybe /etc/priv.conf can only be read by root). An attacker could execute a

    export LD_PRELOAD=/home/attacker/libc.so

    before running a program linked against libprivfunctions.so. This version of libc.so would have a fopen that creates a root shell. When open_priv_file() is called, it will call the falsified fopen which, if run as root, will breach the security of the system. Maybe the easiest way around this would be to disallow any LD* variables when running programs linked against setuid/setgid functions (similar to the way setuid/setgid progams work). But the logic behind this gets complicated (you don't know if you're linking against setuid functions until after you've linked. But what if that outcome was caused by one of the LD* variables?).

    I would say that allowing elevated privileges to just system calls is a good way around this problem. Hats off to OpenBSD for another sound decision.

    --
    For every post, there is an equal and opposite re-post.
  11. Finer-grained privs. Linux 2.5 has them too. +/-. by dwheeler · · Score: 5, Informative
    First, an explanation for those who wonder what this means: this addition is a method for gaining finer control over exactly what privileges a trusted program has. If the method is actually used by the system, the system could be more resistant to attack. That's because even if an attacker took control over a privileged (trusted) program, the privileges of that program would be more limited.

    Somewhat similar capabilities also exist for Linux. The Linux Security Module (LSM) effort adds the ability to insert an additional access control mechanism into a Linux kernel (without a recompile). You can then at run-time insert a modules to add finer control over privileges. Several modules exist, such as SELinux. This approach makes it easier to experiment or create your own access control policy. There are various LSM modules already available; none of them are exactly like this, but most provide finer-grain control. There are definitely technical differences, too, but describing those differences would take up WAY too much space here.

    There are definitely situations where finer control over privileges is very desirable. Which way is the best way is very much in doubt. The good thing about finer control is that you can give a program only the privileges it needs. The bad thing about finer control is that it takes more work to set up. "Learning" from program runs helps, but it doesn't fully solve the problem - there are usually many conditions that aren't triggered by simple runs yet can happen in real life.

    Anyway, this kind of capability is a good thing. It will be interesting to see what happens over the years as people try out various ways to add finer control - the trick will be to add finer control while still keeping the system easy to administrate. It's not even clear that there is a single solution.

    --
    - David A. Wheeler (see my Secure Programming HOWTO)
  12. Er, this was added to NetBSD first by perry · · Score: 5, Informative

    I really hate to say it, but:

    1) The story in no way credits Niels Provos, the author of systrace.

    2) The story does not mention that this feature was added to NetBSD first.

    I don't mean to claim "NetBSD is better" or anything, but at least say "OpenBSD and NetBSD" or "NetBSD and OpenBSD" or something, not "OpenBSD". Also, PLEASE credit the guy that did the work, eh?

  13. ...Except it didn't appear in OpenBSD first. by perry · · Score: 5, Informative

    I hate to be a bitch here, but the feature was added to NetBSD first. I don't mean to imply NetBSD is better than OpenBSD, but maybe some equal billing would have been in order? And by the way, what happened to crediting the author of the code? The work was all done by Niels Provos, who's a damn good security guy.

    1. Re:...Except it didn't appear in OpenBSD first. by Geekboy(Wizard) · · Score: 5, Informative

      Niels Provos was originaly an OpenBSD developer, and started the priv-elevation code on OpenBSD. He hasn't commited to OpenBSD in several months (current theory: fight with Theo). He commited the code to NetBSD, and Itojun commitied it to OpenBSD something like 2 days later.

      Niels also wrote systrace for OpenBSD, and ported it to NetBSD.

      You are right, he is a great security guy.

  14. Appeared in NetBSD first by jolan · · Score: 3, Informative

    Niels Provos was an OpenBSD developer until recently. He's the same guy who did the PrivSep code for OpenSSH.

    It actually appeared in NetBSD first.

    http://mail-index.netbsd.org/current-users/2002/ 10 /11/0039.html

  15. Re:Explanation? by gehirntot · · Score: 4, Informative
    Isn't this "Privilege Elevation" really just an implementation of capabilities? Given the proper capability token, the program can now access a particular priveleged resource (eg syscall).
    Regular capability systems are more coarse grained. You can have capabilities that say this application is allowed to bind to a reserved port,etc. However, with privilege elevation in systrace, you have much finer control. The privileges are just elevated for a single system call matching specified system call arguments.

    Additionally, with systrace you can reduce the privileges of binary applications without the need to add support for capabilities in the source code.

  16. Re:Why is this a good thing? by tpv · · Score: 5, Informative
    OpenBSD takes the next step ... Only they have the bravery...

    Except this change originated in NetBSD.

    --
    Read more of this story at Slashdot.Read more of this story at Slashdot.Read more of this story at Slashdot.
  17. Re:You answer your own question... by yeOldeSkeptic · · Score: 5, Informative
    Which do you think is more secure? Given a choice between having an application run as root [with all the attendant problems that this entails especially if a security problem is found in the app] versus giving the application minimal privileges [specifically all it needs to get the job done and nothing more], how could anyone think the setuid and setgid approach is better.

    setuid and setgid are not perfect and the recent spate of Linux vulnerabilities certainly speaks of the need for improvements in this area. My point is that doing away with setuid and setgid and replacing it with per system call access privileges does not seem to be the right way to increase security.

    With Posix (and Linux, which is Posix compliant) it is already possible for an application to drop it's privileges. This solves the problem of an application running its entire life as root. With the posix compliant call to setuid, an application can be setuid root only for as long as it needs to access privileged resources and can drop those privileges once it no longer needs to be root.

    However, the above article talks about an application elevating its privileges and for the kernel to grant that privilege on a system call basis. The article is short on the details but elevating the privileges of an application is certainly a very dangerous process. If an application asks the kernel to elevate its privileges, how is the kernel to decide if it should grant that request? My mind-set tells me that it should check the effective user id of the running process but then isn't this setuid and setgid again? If the kernel will grant this request by checking a list of applications that is allowed to do this, then how is this different from a kernel checking if an application is owned by root?

    I have stated my preferences for chroot jails and for a good reason. Once a system is cracked, the intruder can do with the filesystem as much as he pleases. At least with chroot jails, the intruder is restricted to the chroot directory and cleaning up the mess is easier. Yes, I know this is not a cure but I think the idea of jailing applications to a particular environment is a good idea.

    I am an old hand so my mind has petrified with an imprint of the old ways of doing things. I could be wrong, but until I am fully convinced, I will be among the voices that express caution at the idea of throwing away setuid and setgid.

    Just my half cent.

  18. Except.... by perry · · Score: 3, Informative

    I'll say it again: the change appeared in NetBSD first, so one should mention both NetBSD and OpenBSD here, and please give credit to Niels Provos, the author of systrace and thus the guy who's been doing all the hard work here.

  19. Re:You answer your own question... by Nickus · · Score: 3, Informative

    There is no need to speculate in how it works when you can just go to the webpage and have a look yourself. http://www.citi.umich.edu/u/provos/systrace/

  20. Re:What is the policy? by perry · · Score: 5, Informative

    The method employed is somewhat fiendish. A systraced program is "mastered" by a systrace daemon that gets information on all its system call activities and either thumbs up or thumbs down particular requests. (For performance reasons, things get fast pathed in many instances so the upcall doesn't have to happen.)

    Because of the way that this works, via a userland policy engine, the systrace daemon (which is user code) can use any method it likes to determine how to implement the policy. The way it is currently implemented, the systrace program reads a policy file associated with particular programs and makes decisions that way.

    There is no need for a program to authenticate to the kernel because the program itself has no knowledge of the policy and cannot evade it in any reasonable way.

    The mechanisms involved are still evolving a bit, but Niels has come up with a bunch of really good tricks here. I don't know that systrace is a finished mechanism as much as a toolkit for building new and more interesting mechanisms that are in the tradition of ACLs but much more flexible.

  21. Re:Why is this a good thing? by perry · · Score: 5, Informative

    The answer is you can't tell the kernel "I'm Apache." Obviously a mechanism that just let you do that would be trivial to evade. The kernel can easily know whether you are the apache program or not, however, because it knows the inode backing your executable -- there is no way to forge that. This is the same way the kernel knows that you have a suid bit -- it looks at the inode for what it is executing when it executes it.

    The systrace mechanism is a very nice one. Most on-system exploits these days are caused by suid programs being exploited before they give up privileges (and many don't give up privs ever). By only giving a program just the privs it needs, you can avoid having to have root privs available to the programs at all. You can't exploit privileges you never have had.

  22. Re:You answer your own question... by Carnage4Life · · Score: 5, Informative

    You are working backwards. Looking at it objectively, it is clear that a system where applications have to become superuser to perform certain tasks but can relinquish this authority is inferior to a system where superuser priveleges are never given to a process.

    Your position is understandable since this is how the Unix security model has worked for decades even though better mechanisms have been proposed but rarely caught on. For example, look at POSIX 1.E which is almost 2 decades for an example of a better model for handling systems permissions than the traditional Unix model. Recently there has been work done on FreeBSD POSIX 1.E capabilities as well as on the Linux front. This is a good indication that more and more people are disatisfied with the deficiencies of the Unix security model and its reliance on a "superuser" account for so many essential tasks.

    Lastly I don't think any Linux distro has ever been certified as POSIX compliant although many feel that doing so wouldn't be difficult.

  23. URLs would help by Anonymous Coward · · Score: 5, Informative

    The URL describing this stuff is

    http://www.citi.umich.edu/u/provos/systrace/

  24. Re:please someone explain by Observer · · Score: 5, Informative
    ... why, for example, accessing port 80 (web access) needs root access ?
    Basically, because ports used for 'well-known' services, like port 80, shouldn't be readily available to arbitary programs, because that would allow a mischievously constructed program to bind to such a port and start serving inapproriate results (or, indeed, just do nothing). The standard IP stack implementations reserve port numbers under 1000 for these well-known services, and typically require that a process attempting to bind to them has some sort of (OS-dependent) privilege. Unfortunately, under classic Unix, 'privileged' equates to root access - it's an all or nothing thing.

    Separating the various functions whose use should require privileges into catagories that can be granted individually (or in groups) to different userids is definitely a Good Thing: it probably won't eliminate the need for a super-user and a few godlike system maintainance users, but it allows the system administrators to keep the really dangerous 'own all data' and 'devour all resources' functions to be kept under tighter control than the all-or-nothing approach. (Arguably, you shouldn't even consider handling sensitive information on a platform that cannot administer privileges in a reasonably fine-grained way, but that's another argument.)

  25. Re:what is root good for at all? by Corporate+Troll · · Score: 2, Informative
    Well, you might be right.. This only works on big systems where you *can* distribute different privileges over different persons This won't work for the single IT guy that has to manage the network of a small bussiness.
    Also consider this: who decides whom should get granted what rights? Well, that person is automatically superuser, because he simply can give himself all the rights without telling anybody. The problem with a System Administrator is simply that it should be a "person of trust", if you don't trust him, you should get rid of him. It's that simple.

    I can only say: I like being a tyrant on my systems. But I'm a fair and good tyrant for I respect my users and don't go and meddle with their data.

    You can have my root account if you pry if from my cold dead hands.

  26. Re:please someone explain by Zigg · · Score: 4, Informative

    The standard IP stack implementations reserve port numbers under 1000 for these well-known services...

    In the interests of pedantry, it's actually ports below 1024.

  27. It allosw for arguments checks, also by bockman · · Score: 2, Informative
    I had the same thought ('if it only checks the access to the system calls, how can I prevent/grant the access to single files/directories/port numbers?).
    Then I went to read the actual thing here, and I found that it also checks for syscall arguments, including some sort of pattern-matching (you can even change dinamically the system call arguments, making a sort of chroot-on-the-fly).

    It looks like a promising idea. My only concerns are :
    1 - performances
    2 - setting up a policy file requires a good knowlwedge of system calls, and not many programmers (not to speak of users or sysadmins) have that. The interactive policy setup helps a little, but it is _you_ that have to say 'yes' or 'no'.

    --
    Ciao

    ----

    FB

  28. Re:Questions by Anonymous Coward · · Score: 1, Informative

    1. Is this going to be in the new 3.2 release in November?

    Yes. November 1st, actually. http://www.openbsd.org/items.html#32

    2. Do programs have to be re-written to take advantage of this feature?

    No. http://www.citi.umich.edu/u/provos/systrace/

  29. Re:ACLs on users rather than binaries? by octogen · · Score: 3, Informative

    It's not about ACLs, it's about privileges.

    There are different kinds of philosophy regarding privilege management.

    Granting privileges to binaries, authorizations to users
    Trusted Unices commonly grant privileges to binaries, but only let the process use the privilege, when the user who executes the binary has got a certain authorization.

    For example, there is one Authorized Privilege Set (APS) and one Privileged Authorization Set (PAS). You put the PV_FS_MOUNT privilege into the APS, and you put the MOUNT authorization into the PAS.
    If the user who executes the binary has a MOUNT authorization, then the process gains the PV_FS_MOUNT privilege, and the user can use the program to mount or unmount filesystems.
    If the user who executes the binary does not have a MOUNT authorization, then the process does not gain the PV_FS_MOUNT privilege, and therefore the user can't mount or unmount filesystems.
    (This explaination is a bit simplified, because you would also have to look at the limiting privilege set or limiting authorization set, but that does not matter here)
    This is how Pitbull .comPack works, which is an EAL4 (exceeding B1) kernel security addon for Solaris and AIX.

    Granting privileges to users, running processes with adopted authority
    The other way is to grant privileges to users, and then to let a binary run with the privileges of a specific user added to the privileges of the current user (Adopted Authority).

    For example you put the ALLOBJ privilege into the privilege set for user 'John', and you give some binary an adopted authority from user 'John'.
    User 'Mark', who does not have the ALLOBJ privilege, executes the binary, and the process gains (adopts) all privileges from user 'John', so user 'Mark' can run the program with the ALLOBJ privilege.
    This is how the SLIC part of OS/400 works (SLIC is the operating system kernel of OS/400, running on IBM AS/400 computers).
    [Tell me if I got something wrong here, I'm not an OS/400 expert]

    Granting privileges to users makes administration easier and it's powerful enough for almost any scenario; granting privileges to binaries makes it a bit more difficult but also more powerful, and i guess that's why it is the preferred method used by Trusted Operating Systems.