Summary
DataGerry's DocAPI template feature can render attacker-controlled Jinja2 content in a non-sandboxed environment. An authenticated attacker with base.docapi.template.add permission may be able to execute operating system commands when a stored template is rendered.
Affected context
The vulnerability affects DataGerry deployments where DocAPI templates can be added through POST /rest/docapi/template and later rendered through GET /rest/docapi/template/<id>/render/<object_id>.
It becomes risky when an attacker can store template content that is subsequently rendered in a non-sandboxed Jinja2 environment. The reported impact can be especially severe in default Docker deployments, where the web process may run as root.
Exploit preconditions
- Attack surface: DataGerry's DocAPI template creation and rendering endpoints
- Required access: An authenticated account with
base.docapi.template.addpermission to store template content - Trigger point: A stored template is rendered through the DocAPI render endpoint
- Why exploitation is possible: Attacker-controlled Jinja2 content is evaluated in a non-sandboxed environment, potentially allowing command execution as the web process user
Why this happens
The underlying issue is server-side template injection, mapped to CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine. Template content supplied through an attacker-influenced field is treated as executable Jinja2 template logic rather than inert data, and is rendered without an effective sandbox boundary. CWE-79 is also associated with the reported vulnerability, but the described root cause is template injection.
Potential impact
- An attacker may execute operating system commands as the DataGerry web process user.
- Application data or runtime resources could be accessed or altered, subject to the process's privileges.
- In default Docker deployments where the web process runs as root, compromise could have elevated consequences within the container.
- A compromised application could be used to affect connected services or data.
General mitigation guidance
Defensive patterns focus on preventing untrusted content from being interpreted as template code and limiting the consequences if template rendering is abused:
- Prefer fixed, trusted templates and pass user-controlled values as data rather than composing template source from them.
- Use sandboxing or restricted template engines where dynamic templates are a necessary feature, and constrain accessible objects and functions.
- Apply strict authorization and review controls to template creation and modification.
- Run the web process with least privilege; avoid root execution in containers and restrict access to host and service resources.
- Validate and constrain template inputs, while treating validation as a supplementary control rather than a substitute for safe rendering.
How teams detect issues like this
- Use static analysis to identify template rendering of user-controlled fields and dynamic construction of template source.
- Review DocAPI template creation and render flows for authorization gaps, unsafe Jinja2 configuration, and access to powerful objects or functions.
- Monitor template creation and modification events, render activity, and unexpected child processes launched by the web service.
- Enforce policies that prohibit non-sandboxed rendering of untrusted templates and require least-privilege runtime configurations.
- Automated code review tools may help flag risky template APIs and data flows.

