openedx / openedx/codejail

Codejail cannot run without a user set

Aperta
#162 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
479
Fork
84
Merge medio
16h 34m
PR unite (30g)
2

Descrizione

If codejail is not configured with a user to run commands as, jailed code execution will fail. Effectively, this makes the user config option mandatory rather than optional.

This probably hasn't come up much because most users would configure it with a user. One possibility is to just make the option mandatory.

Details:

jail_code.py builds up a list to pass to subprocess.Popen. This is run as a command with arguments, rather than a shell command string. However, one of the arguments is 'TMPDIR=tmp', a construction to set an environment variable for a process in Bash. TMPDIR=tmp python ... works fine in Bash, but subprocess.Popen(['TMPDIR=tmp', 'python', ...]) does not work because TMPDIR=tmp is not a valid executable.

The reason it works with a user configured is that the command array will then first be prefixed with ['sudo', '-u', user]. The sudo command interprets the remainder of its arguments as a shell string rather than a command and arguments.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da jail_code.py e controlla come viene assemblato l’elenco dei comandi prima che subprocess.Popen lo esegua, soprattutto quando non è configurato alcun user. Riproduci l’esecuzione in ambiente isolato con l’opzione user non impostata, quindi determina se la soluzione prevista consiste nel correggere la costruzione del comando o nel rendere user obbligatorio. Il lavoro è completato quando il comportamento scelto funziona in modo coerente ed è coperto dai test esistenti pertinenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
security
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
50/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.