openedx / openedx/codejail

Simplify sudoers recommendation

Open
#230 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
479
Forks
84
Avg merge
16h 34m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the sudoers recommendation in README.rst at lines 111-113 and the cleanup context in codejail/jail_code.py at lines 333-334. Review how the documented find, pkill, Python, and AppArmor options relate, then resolve which recommendation is intended. Done means the sudoers guidance and any referenced cleanup approach consistently describe the chosen security model.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, security
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.