-
Notifications
You must be signed in to change notification settings - Fork 80
Description
When the codejail.safe_exec module is imported, it decides immediately whether to run in unsafe mode:
codejail/codejail/safe_exec.py
Line 293 in 0165d9c
| UNSAFE = ALWAYS_BE_UNSAFE or not jail_code.is_configured("python") |
This means that codejail must be fully configured before it is imported. Any module that imports this one (usually for safe_exec or SafeExecException) must itself be imported after this point. This might work if the relying code is a Django app and if the ConfigureCodeJailMiddleware is in effect, but a small change could still cause codejail to start loading in unsafe mode.
It would likely be better to have the safe_exec function decide at call-time whether to branch to not_safe_exec, as this would allow service startup to occur in any order (as long as codejail.jail_code.configure is called at some point before safe_exec starts being called).
This change could be made as part of an unsafe-mode deprecation, which would likely entail requiring an explicit opt-in for unsafe-exec (only used for unit tests) rather than defaulting to it.