Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify sudoers recommendation #230

Open
timmc-edx opened this issue Feb 19, 2025 · 0 comments
Open

Simplify sudoers recommendation #230

timmc-edx opened this issue Feb 19, 2025 · 0 comments

Comments

@timmc-edx
Copy link
Contributor

The codejail docs currently recommend the following sudoers file:

<SANDBOX_CALLER> ALL=(sandbox) SETENV:NOPASSWD:<SANDENV>/bin/python
<SANDBOX_CALLER> ALL=(sandbox) SETENV:NOPASSWD:/usr/bin/find
<SANDBOX_CALLER> ALL=(ALL) NOPASSWD:/usr/bin/pkill

There are a few warts here:

  • Allowing the app user to run find as the sandbox user is equivalent to allowing the app user to run anything as the sandbox user, because find allows running arbitrary code.
  • SETENV is set for both python and find, but it doesn't appear to be necessary for either. (In fact, the recommended AppArmor profile then disallows propagating the environment to the python execution.)
  • The app user is allowed to call kill as any user, not just the sandbox user.

Given that the app user has strictly more capabilities than the sandbox user in the first place, it might make more sense to just have this sudoers file:

<SANDBOX_CALLER> ALL=(sandbox) NOPASSWD:ALL

Alternatively, if we want to restrict arbitrary code execution as the sandbox user to always be under AppArmor confinement, we might want something like this, and then use the sandboxed python executable for any cleanup, allowing us to get rid of the find call:

<SANDBOX_CALLER> ALL=(sandbox) NOPASSWD:<SANDENV>/bin/python
<SANDBOX_CALLER> ALL=(sandbox) NOPASSWD:/usr/bin/pkill
@timmc-edx timmc-edx moved this to Backlog in Arch-BOM Feb 19, 2025
@timmc-edx timmc-edx removed the status in Arch-BOM Feb 19, 2025
@robrap robrap moved this to Backlog in Arch-BOM Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant