Summary
SOCFortress CoPilot can evaluate attacker-controlled Jinja2 expressions when uploaded case-report templates are rendered by privileged report-generation workflows. A low-privilege portal user who can upload or replace a shared template may gain backend code execution, access sensitive tenant data, or affect internal services when the deployment uses vulnerable rendering paths.
SOCFortress CoPilot can evaluate attacker-controlled Jinja2 expressions when uploaded case-report templates are rendered by privileged report-generation workflows. A low-privilege portal user who can upload or replace a shared template may gain backend code execution, access sensitive tenant data, or affect internal services when the deployment uses vulnerable rendering paths.
Affected context
The issue occurs in deployments where customer users can upload, manage, or replace case-report templates, while report generation later renders those templates with non-sandboxed Jinja2 environments. Risk is increased when templates are stored globally without customer scoping, content validation is weak, HTML output is not autoescaped, and the application or document renderer has elevated operating-system or network access.
The issue occurs in deployments where customer users can upload, manage, or replace case-report templates, while report generation later renders those templates with non-sandboxed Jinja2 environments. Risk is increased when templates are stored globally without customer scoping, content validation is weak, HTML output is not autoescaped, and the application or document renderer has elevated operating-system or network access.
Exploit preconditions
- Attack surface: Case-report template upload and management endpoints, followed by DOCX or PDF report generation.
- Required access: A portal account with permissions to upload or manipulate templates; the lowest-privilege customer role may be sufficient in the reported deployment.
- Trigger point: A privileged user or automated workflow generates a report using an affected template.
- Why exploitation is possible: Uploaded template content is trusted and evaluated by non-sandboxed Jinja2 engines without adequate tenant scoping or content validation.
- Additional exposure: The PDF rendering path may permit local-file access or requests to internal services, depending on renderer configuration and runtime permissions.
- Attack surface: Case-report template upload and management endpoints, followed by DOCX or PDF report generation.
- Required access: A portal account with permissions to upload or manipulate templates; the lowest-privilege customer role may be sufficient in the reported deployment.
- Trigger point: A privileged user or automated workflow generates a report using an affected template.
- Why exploitation is possible: Uploaded template content is trusted and evaluated by non-sandboxed Jinja2 engines without adequate tenant scoping or content validation.
- Additional exposure: The PDF rendering path may permit local-file access or requests to internal services, depending on renderer configuration and runtime permissions.
Why this happens
The underlying flaw is server-side template injection caused by treating user-controlled Jinja2 template content as trusted executable logic. The application validates metadata such as a filename-derived MIME type rather than enforcing a safe template language or isolating template evaluation, then renders the content through non-sandboxed Jinja2 environments. Shared storage and insufficient authorization checks further allow one customer user to affect templates consumed by other users or privileged workflows. This maps primarily to CWE-94, Improper Control of Generation of Code, and is closely related to CWE-1336, Improper Neutralization of Special Elements Used in a Template Engine.
The underlying flaw is server-side template injection caused by treating user-controlled Jinja2 template content as trusted executable logic. The application validates metadata such as a filename-derived MIME type rather than enforcing a safe template language or isolating template evaluation, then renders the content through non-sandboxed Jinja2 environments. Shared storage and insufficient authorization checks further allow one customer user to affect templates consumed by other users or privileged workflows. This maps primarily to CWE-94, Improper Control of Generation of Code, and is closely related to CWE-1336, Improper Neutralization of Special Elements Used in a Template Engine.
Potential impact
- An attacker may execute arbitrary code with the privileges of the backend process.
- The application could be compromised if report rendering runs with elevated privileges.
- Incident records, SIEM data, and stored connector credentials could be exposed.
- An attacker could access data belonging to other tenants through globally shared templates or backend capabilities.
- The PDF renderer may disclose local files or reach internal services.
- Reports, templates, or security-operation workflows could be altered or disrupted.
- An attacker may execute arbitrary code with the privileges of the backend process.
- The application could be compromised if report rendering runs with elevated privileges.
- Incident records, SIEM data, and stored connector credentials could be exposed.
- An attacker could access data belonging to other tenants through globally shared templates or backend capabilities.
- The PDF renderer may disclose local files or reach internal services.
- Reports, templates, or security-operation workflows could be altered or disrupted.
General mitigation guidance
Mitigation should focus on eliminating executable behavior from user-controlled
templates and enforcing authorization at every template lifecycle operation.
Common defensive patterns include:
- Use a tightly restricted template language or a sandboxed renderer with a minimal, allowlisted data model.
- Prefer structured report definitions and server-controlled templates over arbitrary user-supplied template code.
- Treat template content as untrusted input and do not rely on filename extensions or MIME metadata for safety.
- Scope template storage and lookup by tenant, enforce ownership checks, and protect system defaults from replacement or deletion.
- Apply least privilege to application workers and document-rendering processes, including filesystem and network restrictions.
- Disable unnecessary local-file access, external requests, and dangerous renderer features.
- Escape output according to its target format and preserve safe defaults for HTML, DOCX, and PDF generation.
- Separate report rendering from sensitive backend services where practical and limit the data exposed to templates.
Mitigation should focus on eliminating executable behavior from user-controlled
templates and enforcing authorization at every template lifecycle operation.
Common defensive patterns include:
- Use a tightly restricted template language or a sandboxed renderer with a minimal, allowlisted data model.
- Prefer structured report definitions and server-controlled templates over arbitrary user-supplied template code.
- Treat template content as untrusted input and do not rely on filename extensions or MIME metadata for safety.
- Scope template storage and lookup by tenant, enforce ownership checks, and protect system defaults from replacement or deletion.
- Apply least privilege to application workers and document-rendering processes, including filesystem and network restrictions.
- Disable unnecessary local-file access, external requests, and dangerous renderer features.
- Escape output according to its target format and preserve safe defaults for HTML, DOCX, and PDF generation.
- Separate report rendering from sensitive backend services where practical and limit the data exposed to templates.
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying non-sandboxed Jinja2
Environmentor template rendering APIs used with user-controlled content. - Code review checks for
DocxTemplate, HTML rendering, or document conversion paths that accept uploaded templates. - Searches for template uploads validated only through filenames, extensions, or client-provided MIME types.
- Authorization review of upload, list, download, replacement, and deletion operations, especially where storage keys are not tenant-scoped.
- Runtime monitoring for unexpected template changes, report-generation activity, child-process creation, local-file access, or outbound requests from rendering workers.
- Policy enforcement requiring allowlisted template constructs, isolated rendering identities, and restricted document-converter capabilities.
- Automated security review tools can help identify dangerous template APIs and missing authorization boundaries, but findings should be validated against deployment configuration.
Organizations can look for this weakness through:
- Static analysis rules identifying non-sandboxed Jinja2
Environmentor template rendering APIs used with user-controlled content. - Code review checks for
DocxTemplate, HTML rendering, or document conversion paths that accept uploaded templates. - Searches for template uploads validated only through filenames, extensions, or client-provided MIME types.
- Authorization review of upload, list, download, replacement, and deletion operations, especially where storage keys are not tenant-scoped.
- Runtime monitoring for unexpected template changes, report-generation activity, child-process creation, local-file access, or outbound requests from rendering workers.
- Policy enforcement requiring allowlisted template constructs, isolated rendering identities, and restricted document-converter capabilities.
- Automated security review tools can help identify dangerous template APIs and missing authorization boundaries, but findings should be validated against deployment configuration.

