Summary
A sandbox escape in openssl_encrypt versions before 1.4.0 exposes Python type objects through restricted exec() builtins. An attacker who can provide code to the isolated executor may traverse Python's class hierarchy and reach system functions, potentially executing arbitrary operating-system commands.
Affected context
The vulnerability occurs in deployments that use the IsolatedPluginExecutor to run Python code in a restricted execution environment. It becomes risky when attacker-controlled or insufficiently trusted code reaches the executor and the restricted builtins still expose Python objects that can reveal broader runtime capabilities.
Exploit preconditions
- Attack surface: The IsolatedPluginExecutor's restricted Python execution path
- Required access: Ability to supply or influence code executed by the isolated executor
- Trigger point: Evaluation of attacker-controlled Python expressions or statements
- Why exploitation is possible: Exposed Python type objects can provide access to the class hierarchy and subsequently to system-level functionality despite the intended sandbox restrictions
Why this happens
The underlying bug is an incomplete restriction of Python execution capabilities. Although the executor limits the available builtins, it leaves object and type relationships reachable through the runtime, allowing code to navigate from exposed objects to classes and subclasses with privileged behavior.
This maps to CWE-95: Improper Neutralization of Directives in Dynamically-Evaluated Code, because dynamically evaluated input can access execution-relevant Python features that the sandbox was intended to exclude.
Potential impact
- An attacker may execute arbitrary operating-system commands
- The application process could be compromised
- Sensitive data accessible to the executor may be disclosed
- Attackers could alter files, processes, or runtime configuration
- The host or surrounding services could be affected depending on process privileges
General mitigation guidance
Mitigation generally focuses on avoiding the execution of untrusted Python code in-process and reducing the capabilities available to any required execution environment.
Common defensive patterns include:
- Prefer declarative plugin interfaces or isolated, reviewed operations over dynamic code execution
- Use a hardened execution boundary that does not rely solely on restricted exec() builtins
- Remove object, type, reflection, and import paths that are not essential to the execution contract
- Run executor processes with dedicated identities, minimal filesystem access, and restricted network permissions
- Treat plugin code and execution inputs as untrusted, and enforce explicit allowlists and resource limits
- Apply security policies that prevent sandboxed workloads from obtaining unnecessary host or service privileges
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying exec(), eval(), dynamic compilation, and custom Python sandbox implementations
- Code review signals involving exposed object references, type traversal, reflection, imports, or unrestricted callable access
- Tests that verify prohibited runtime objects and system interfaces are unreachable from the restricted environment
- Policy enforcement requiring dynamic code execution to occur in separately isolated, least-privileged workers
- Runtime monitoring for unexpected child processes, shell invocation, filesystem changes, and outbound connections from executor processes
Automated security review tools may help identify dangerous evaluation APIs and incomplete sandbox boundaries, but should be supplemented with manual design review.

