Privilege Separation In Condor


Published on

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Privilege Separation In Condor

  1. 1. Privilege separation in Condor Bruce Beckles University of Cambridge Computing Service
  2. 2. What is privilege separation? <ul><li>Isolation of those parts of the code that run at different privilege levels </li></ul>root Condor daemons Condor job <ul><li>No privilege separation: </li></ul>root Condor daemons Condor job <ul><li>Privilege separation: </li></ul>
  3. 3. The principle of least privilege <ul><li>Code only ever runs at the minimum level of privilege required for its current task </li></ul>root Condor daemons <ul><li>Violation of principle of least privilege: </li></ul><ul><li>Not in violation of principle of least privilege: </li></ul>root Condor daemons Condor asks root to perform privileged action Upon completion of action control returns to Condor
  4. 4. How do we do this? <ul><li>User context switching: </li></ul>root context switching daemon Condor daemons <ul><li>GNU userv allows one process to invoke another (in either the same or a different user context) in a secure fashion when only limited trust exists between them (see http:// / ). </li></ul>Condor job
  5. 5. Who does what? <ul><li>Execute nodes: </li></ul><ul><ul><li>Change ownership of any file ( CAP_CHOWN capability) </li></ul></ul><ul><ul><li>Switch to any user context ( CAP_SETUID capability) </li></ul></ul><ul><ul><li>Send signals to any process ( CAP_KILL capability) </li></ul></ul><ul><li>Submit nodes: </li></ul><ul><ul><li>Switch to any user context ( CAP_SETUID capability) </li></ul></ul><ul><ul><li>Send signals to any process ( CAP_KILL capability) </li></ul></ul><ul><li>Central manager: </li></ul><ul><ul><li>No privilege switching required (unless GSI authentication is being used, in which case need to be able to switch to any user context ( CAP_SETUID capability)) </li></ul></ul><ul><ul><li>(Note that if you have the ability to switch to any user context you effectively have the ability to send signals to any process.) </li></ul></ul>
  6. 6. Details – Central manager <ul><li>Unless using GSI authentication, Condor daemons don’t need to run as root , so… </li></ul><ul><li>… don’t run them as root …(!) </li></ul><ul><li>If using GSI: </li></ul><ul><ul><li>Flawed security paradigm, so… </li></ul></ul><ul><ul><li>…waste of time trying to make the system more “secure” until underlying paradigm is “fixed”… </li></ul></ul>
  7. 7. Details – Execute node root uservd wrapper script signal handler Condor job condor_startd Condor cron job kill –KILL -1 condor_starter &quot;Rogue&quot; process stdout stderr Send signal to Condor job Change file ownership fork() Condor job Change file ownership
  8. 8. Details – Execute node <ul><li>No Condor daemon or process runs as root </li></ul><ul><li>Condor passes job to our wrapper script </li></ul><ul><li>Our script installs a signal handler to intercept Condor’s signals to the job </li></ul><ul><li>Our script changes the ownership of the job’s files (via userv) as necessary at beginning and end of job </li></ul><ul><li>Our script fork() ’s a userv process which runs the job in a different (also non-privileged) user context </li></ul><ul><li>On receipt of a signal from Condor, our script calls userv to send the signal to the job </li></ul><ul><li>userv uses pipes to pass the job’s standard output and standard error back to our script (and so to Condor) </li></ul><ul><li>A cron job (using Condor’s STARTD_CRON mechanism) runs once a minute to make sure that if there is no job executing then there are no processes running in our dedicated “Condor job” user context </li></ul>
  9. 9. What does this gain us? <ul><li>If there is a vulnerability in Condor then the entire machine is not compromised as a result. </li></ul><ul><li>We do not have any Condor processes, whose real user ID is root , listening to the network. </li></ul><ul><li>Much greater control over the job’s execution environment – could run the job chroot ’d if desired. </li></ul><ul><li>Our wrapper script can examine the job and make more sophisticated decisions about whether or not to run it (restrict to local executables, etc.) </li></ul><ul><li>We now have a “hook” for executing arbitrary tasks on job completion , a feature “ordinary” Condor lacks. </li></ul><ul><li>If a Condor job leaves behind any processes running after job completion they will be killed – normally, Condor only does this properly if specially configured (EXECUTE_LOGIN_IS_DEDICATED). </li></ul>
  10. 10. What do we lose? <ul><li>Can no longer suspend jobs (cannot catch SIGSTOP) </li></ul><ul><li>We now need to handle passing the job environment variables, setting resource limits and scheduling priority, etc., which Condor would normally handle </li></ul><ul><li>Condor can no longer correctly distinguish between the load Condor processes and Condor jobs are putting on the machine, and the load generated by other processes </li></ul><ul><li>Information returned by Condor about the job’s CPU utilization, etc. is incorrect </li></ul><ul><li>Cannot work with GSI authentication </li></ul><ul><li>Does not yet work with Condor’s Standard universe (although this may not be difficult to fix) </li></ul><ul><li>Adds of the order of 5 seconds to job execution time </li></ul>
  11. 11. Details – Submit node <ul><li>If not using “strong” authentication (Kerberos, etc.), can use a similar technique </li></ul><ul><li>If using strong authentication then this won’t work: </li></ul><ul><ul><li>condor_shadow processes need to run as the submitting user, but… </li></ul></ul><ul><ul><li>… machine credentials need to not be accessible to ordinary users… </li></ul></ul><ul><ul><li>Damn! </li></ul></ul><ul><li>So… </li></ul>
  12. 12. Fully privilege separated architecture (1) IPC e.g. Unix domain sockets root context switching daemon Condor daemon Network network listener daemon credential on filesystem chroot() dedicated condor user dedicated different user Request privileged services as needed
  13. 13. Fully privilege separated architecture (1) – details <ul><li>Requires extensive changes to Condor code </li></ul><ul><li>No Condor daemon or process runs as root </li></ul><ul><li>User context switching daemon provides services to Condor components that would otherwise need a higher level of privilege </li></ul><ul><li>Long running Condor daemons that communicate with the network are privilege separated “OpenBSD-style”: </li></ul><ul><ul><li>Split into two components that run in different user contexts: one that exclusively handles network communication, one that does everything else </li></ul></ul><ul><ul><li>Network component chroot() ’d to somewhere “safe” </li></ul></ul><ul><ul><li>Components communicate via some form of IPC mechanism (e.g. Unix domain sockets) </li></ul></ul><ul><ul><li>Allows authentication credentials to be protected but still used for authentication (network component acts as a relay between other component and the remote daemon) </li></ul></ul>
  14. 14. Fully privilege separated architecture (2) IPC &quot;network socket&quot; root context switching daemon Condor daemon (long running) Network network listener daemon credential chroot() dedicated condor user dedicated different user Condor daemon (short running) IPC possibly different user context, e.g. user who submitted job e.g. condor_shadow
  15. 15. Fully privilege separated architecture (2) – details <ul><li>For “short” running Condor daemons ( condor_starter , condor_shadow , etc): </li></ul><ul><ul><li>Typically instantiated by a long running daemon </li></ul></ul><ul><ul><li>Parent daemon could set up secure network channel which child then inherits </li></ul></ul><ul><ul><li>This gives the child a session key </li></ul></ul><ul><ul><li>When session key is due to expire (or if re-negotiation of secure channel is required): </li></ul></ul><ul><ul><ul><li>Use session key to “authenticate” to parent daemon </li></ul></ul></ul><ul><ul><ul><li>Now act as a relay for passing authentication messages between remote daemon and parent daemon to re-negotiate secure channel </li></ul></ul></ul>
  16. 16. Future work <ul><li>Architecture described on the last two slides is just a proposal </li></ul><ul><li>Details may (will!) change as design evolves… </li></ul><ul><li>Some form of privilege separation should appear in the Condor 6.9 development series </li></ul>
  17. 17. Further Details <ul><li>See: </li></ul><ul><li>Implementing privilege separation in the Condor ® system (2005): </li></ul><ul><li> </li></ul>