Summary
compliance-trestle contains a server-side template injection vulnerability in the trestle author jinja command. Recursive re-evaluation causes attacker-controlled data inserted into a trusted template to be interpreted as template code, which may enable arbitrary command execution with the privileges of the running process.
Affected context
The vulnerability affects workflows that use the trestle author jinja command to render compliance content, such as SSP documents or Lookup Tables. It becomes risky when attacker-controlled values are included in data rendered by a trusted template and the rendered output is recursively compiled and evaluated as a new template.
Exploit preconditions
- Attack surface: The
trestle author jinjatemplate-rendering command - Required access: Ability to influence data fields consumed by a trusted template
- Trigger point: Recursive parsing and rendering of previously rendered output
- Why exploitation is possible: Data that was intended to remain plain text is reinterpreted as template logic during a subsequent rendering pass
Why this happens
The underlying bug is recursive re-compilation and re-rendering of output generated by a template engine. This breaks the intended trust boundary between trusted template code and untrusted data, allowing expressions embedded in data values to be evaluated as executable template content.
This maps primarily to CWE-94: Improper Control of Generation of Code, because attacker-controlled content can influence executable behavior. It is also closely related to CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine, because template syntax in data is not safely treated as literal content.
Potential impact
- Arbitrary commands may execute with the privileges of the running process
- Compliance authoring workflows could be compromised
- Sensitive files, credentials, or environment data could be accessed
- Generated compliance artifacts may be altered or poisoned
- The host or build environment could be used for further compromise
General mitigation guidance
Mitigation generally focuses on preserving the separation between trusted templates and untrusted data.
Common defensive patterns include:
- Rendering untrusted values as data only, without recursive template evaluation
- Treating rendered output as inert text rather than compiling it again
- Applying strict template-engine sandboxing and capability restrictions where supported
- Validating and constraining data fields before rendering
- Limiting process privileges, filesystem access, and network permissions
- Separating authoring, rendering, and execution environments
- Keeping template-processing components aligned with maintained security fixes
How teams detect issues like this
Organizations can look for:
- Static-analysis findings involving recursive template compilation or rendering
- Code paths that pass rendered output back into a template engine
- Review signals showing that data fields and template source share the same evaluation path
- Tests verifying that template syntax supplied through data remains literal
- Policy checks requiring sandboxed rendering and restricted process privileges
- Runtime monitoring for unexpected child processes or command execution during document generation
Automated code-review and dependency-analysis tools may help identify unsafe template-engine usage, but should be supplemented with focused tests for recursive rendering behavior.

