Summary
Open Notebook v1.8.3 suffers from insufficient user input sanitization in user-created transformations, enabling server-side template injection (SSTI).
An authenticated application user can craft malicious template input that is evaluated on the server, leading to arbitrary Python code execution and potentially full OS command execution inside the Docker container.
Affected context
The vulnerability exists in Open Notebook deployments that allow users to define or configure custom transformations rendered through a server-side templating engine.
When user-controlled transformation expressions are processed without strict validation or escaping, the template engine interprets them as executable code.
This typically affects environments where Open Notebook runs inside a Docker container and exposes transformation features to authenticated users or automation.
Exploit preconditions
- Attack surface: Application web interface or API for creating/updating user transformations
- Required access: Valid user access capable of defining or modifying transformations (no need for shell access)
- Trigger point: Rendering or evaluating user-defined transformation templates on the server side
- Why exploitation is possible: User input is directly embedded into a server-side template context without adequate sanitization, validation, or use of a safe expression language, allowing execution of template expressions that can escape into arbitrary Python code and OS commands
Why this happens
The core issue is improper input validation (CWE-20) combined with the powerful capabilities of the server-side templating engine.
User-controlled transformation strings are treated as trusted template code and passed into the rendering engine without enforcing a strict, limited syntax or escaping untrusted constructs.
In this pattern, the template engine offers access to objects, attributes, or helper functions that can be chained to execute arbitrary Python code, ultimately enabling execution of OS commands inside the container.
The vulnerability reflects a broader class of SSTI problems where presentation-layer templating is mixed with business logic and direct user input.
Potential impact
- Execution of arbitrary Python code within the Open Notebook process
- Execution of OS commands inside the Docker container hosting the application
- Reading or modification of data accessible to the application (notebooks, datasets, configuration)
- Potential pivot to other internal services reachable from the container
- Abuse of the container's network access for further attacks or data exfiltration
General mitigation guidance
Effective mitigation focuses on decoupling user input from executable template logic and constraining what the template engine can do:
- Restrict user-defined transformations to a safe, declarative expression language or pre-defined operations rather than raw template code.
- Apply strict input validation and allowlisting for transformation syntax, rejecting any constructs outside a narrow, documented grammar.
- Disable or sandbox dangerous template engine features, such as access to internals, object attributes, or arbitrary function calls.
- Ensure untrusted data is always treated as data, not code, by using automatic escaping and avoiding direct concatenation into templates.
- Run the application with least-privilege OS and container permissions to reduce the blast radius of a potential compromise.
How teams detect issues like this
Organizations can approach detection by combining code-centric and behavior-centric techniques:
- Use static analysis or linters to flag direct injection of user input into template render calls or dynamic evaluation APIs.
- During code review, scrutinize any feature that lets users define "templates," "expressions," or "transformations," verifying that input is constrained and not evaluated as arbitrary code.
- Implement application-layer monitoring to detect unusual template errors or stack traces that reference internal objects or evaluation failures.
- Analyze container and application logs for suspicious transformation content, unexpected subprocess execution, or sudden spikes in error responses when transformations are rendered.

