OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

run sudo commands as root

Open mickstar opened this issue 1 year ago • 6 comments

devin user can't run sudo commands which prevent it from installing software like nodejs

rather than install the sudo binary and modifying visudo file, i thought we could just do this

alternatively we could just default the docker user as root?

mickstar avatar Mar 28 '24 10:03 mickstar

This seems like it might be a little unreliable. E.g. the command could be echo 'y' | sudo apt-get install foo

There are also sometimes problems with running one command as sudo, then trying to use the result as a regular user. E.g. file ownership might be wrong.

Curious what others think--making devin a sudoer might be a more reliable way to do this. But you're right on the password requirement...

rbren avatar Mar 28 '24 14:03 rbren

That's a good point. I think including sudo in the docker image is the way to go. Regarding passwords, there's a NOPASSWD config for visudo that we will can use

mickstar avatar Mar 28 '24 14:03 mickstar

We can probably tweak the sandbox's dockerfile to make the devin user into the sudoer's group, then apply the NOPASSWD config? Not sure allowing devin user to have access to sudo will have any unintended consequences (e.g., devin creates root files in the mount directly where the outside human user cannot read).

xingyaoww avatar Mar 28 '24 15:03 xingyaoww

Only issue with sudo is that the container uses the same userspace as the host system (IIUC), so that if there were a bug allowing devin to escape the container, he'd have root on the host system. But that would involve:

  • A Docker bug allowing container escape (it happens!)
  • An attacker getting OpenDevin to execute malicious code

rbren avatar Mar 28 '24 19:03 rbren

Only issue with sudo is that the container uses the same userspace as the host system (IIUC), so that if there were a bug allowing devin to escape the container, he'd have root on the host system.

How about using user namespace with re-mapping? https://docs.docker.com/engine/security/userns-remap/

enyst avatar Mar 28 '24 23:03 enyst

Looks promising!

Honestly I think near-term it's fine to run as sudo, if that improves quality. But we should have a long-term issue open to figure this out.

rbren avatar Mar 29 '24 00:03 rbren

Sounds like we should abandon this one, and maybe turn off RUN_AS_DEVIN for everyone

rbren avatar Mar 29 '24 20:03 rbren