CVE-2026-33587
SSTI in Open Notebook v1.8.3 allows code execution via transformations.
- CVSS 9.2
- CWE-20
- Input Validation and Sanitization
- Remote
Lack of user input sanitisation in Open Notebook v1.8.3 allows the application user to execute Python code (and subsequently OS commands) on the docker container via Server-Side Template Injection (SSTI) for user-created transformations.
- CWE
- CWE-20
- CVSS base score
- 9.2
- Published
- 2026-05-07
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Open Noteboo
Solution
No official patched version is available for this vulnerability (CVE-2022-2309).
Vulnerable code sample
from flask import Flask, request, render_template_string
import os
app = Flask(__name__)
# This represents a feature where a user can define a custom transformation
# on some data. The user's input is a template string.
@app.route('/apply-transformation')
def apply_transformation():
# Get the user-defined transformation logic from a request parameter.
# In the vulnerable version, this input is not sanitized.
user_transformation_template = request.args.get('transformation', 'No transformation provided.')
# Some dummy data that the transformation would be applied to.
data_context = {
'username': 'testuser',
'value': 42
}
# VULNERABILITY: The user-provided string is directly rendered as a template.
# An attacker can inject template syntax to execute Python code.
# Example malicious payload for 'transformation' parameter:
# {{ self.__init__.__globals__.__builtins__.__import__('os').popen('id').read() }}
try:
rendered_output = render_template_string(user_transformation_template, data=data_context)
return f"Transformation Result: {rendered_output}"
except Exception as e:
return f"Error during transformation: {str(e)}", 500
if __name__ == '__main__':
# Running in debug mode on 0.0.0.0 to simulate a typical containerized app setup.
app.run(host='0.0.0.0', port=8080, debug=True)Patched code sample
from jinja2.sandbox import SandboxedEnvironment
from jinja2.exceptions import SecurityError
def apply_safe_transformation(data, user_transformation_rule):
"""
Safely applies a user-defined transformation using a sandboxed template
environment to prevent Server-Side Template Injection (SSTI).
The fix involves replacing a standard, permissive template environment with
jinja2's SandboxedEnvironment. This environment restricts access to unsafe
attributes and methods within the template, preventing attackers from
executing arbitrary code.
"""
# Create a sandboxed environment. This is the core of the fix.
env = SandboxedEnvironment()
try:
# The user-provided string is parsed as a template within the sandbox.
template = env.from_string(user_transformation_rule)
# The data is rendered. If the template tries to access forbidden
# attributes (like .__class__), a SecurityError will be raised.
return template.render(data=data)
except SecurityError as e:
# Catch the security error and handle it, preventing code execution.
return f"Error: Malicious transformation blocked. Reason: {e}"
except Exception as e:
# Catch other potential template errors.
return f"Error: Invalid template syntax. Reason: {e}"Payload
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('id').read() }}
Cite this entry
@misc{vaitp:cve202633587,
title = {{SSTI in Open Notebook v1.8.3 allows code execution via transformations.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-33587},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-33587/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
