VAITP Dataset

← Back to the dataset

CVE-2026-61707

Unsanitized Jinja2 template upload leads to RCE via report generation.

  • CVSS 9.0
  • CWE-94
  • Input Validation and Sanitization
  • Remote

SOCFortress CoPilot focuses on providing a single pane of glass for all your security operations needs. Prior to 0.1.76, in the reported deployment, case-report templates uploaded by `customer_user`, the lowest-privilege portal role, are later executed by non-sandboxed Jinja2 engines when an admin or analyst generates a report. The `/case-report-template/upload` route in `backend/app/incidents/routes/db_operations.py` validates only the filename-derived MIME type, not the template content. Templates share a global store without customer_code scoping, and `customer_user` can also list, download and delete them, allowing an attacker to replace a legitimate default template under the same name. In `backend/app/incidents/services/reports.py`, `render_document_with_context` uses `DocxTemplate` without a sandbox; in `backend/app/incidents/services/reports_pdf.py`, `render_html_template` uses a non-sandboxed `Environment` without autoescaping. Normal privileged requests to `POST /api/incidents/report/generate-report-docx` or `/generate-report-pdf` therefore evaluate attacker-controlled Jinja expressions as Python on the backend. The reported deployment executes commands as root, exposing all tenants' incident and SIEM data and stored connector credentials. The HTML/PDF wkhtmltopdf renderer additionally permits local-file reads and requests to internal services. This issue is fixed in version 0.1.76.

CVSS base score
9.0
Published
2026-10-29
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
Jinja2

Solution

Upgrade SOCFortress CoPilot to version 0.1.76 or later, which patches the insecure template handling and adds proper sandboxing.

Vulnerable code sample

import os
from jinja2 import Environment, FileSystemLoader

def render_html_template(template_name: str, context: dict) -> str:
    """
    Load a user‑uploaded Jinja2 template and render it with the provided context.
    """
    # VULNERABLE: uses non‑sandboxed Jinja2 environment allowing code execution
    env = Environment(
        loader=FileSystemLoader(os.path.join(os.getcwd(), "templates")),
        autoescape=False,
        enable_async=False,
    )
    template = env.get_template(template_name)
    return template.render(**context)

Patched code sample

import os
from jinja2 import SandboxedEnvironment, FileSystemLoader

def render_html_template(template_name: str, context: dict) -> str:
    """
    Load a user‑uploaded Jinja2 template and render it with the provided context.
    """
    # FIX: use sandboxed environment to prevent execution of arbitrary code
    env = SandboxedEnvironment(
        loader=FileSystemLoader(os.path.join(os.getcwd(), "templates")),
        autoescape=True,
    )
    template = env.get_template(template_name)
    return template.render(**context)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • fix(security): sandbox case-report template rendering (GHSA-7q83-228r-wfh5) (#936) (socfortress/CoPilot)
    backend/app/incidents/routes/db_operations.py, backend/app/incidents/routes/db_operations.py · delete_case_report_template_endpoint, backend/app/incidents/routes/db_operations.py · upload_case_report_template_endpoint, backend/app/incidents/services/reports.py, backend/app/incidents/services/reports.py · render_document_with_context, backend/app/incidents/services/reports_pdf.py, backend/app/incidents/services/reports_pdf.py · convert_html_to_pdf, backend/app/incidents/services/reports_pdf.py · render_html_template

Cite this entry

@misc{vaitp:cve202661707,
  title        = {{Unsanitized Jinja2 template upload leads to RCE via report generation.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-61707},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-61707/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.