/

CVE-2026-57170

Severity:

HIGH RISK

(7.8)

Server-Side Template Injection (CWE-1336) in Trestle

CVE-2026-57170

Deferred

Vulnerability type

Category:

Server-Side Template Injection

CWE:

CWE-94, CWE-1336

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Compliance-trestle (Trestle) re-parses content from included Markdown files as Jinja2 template code in a non-sandboxed environment. If attacker-controlled OSCAL prose or component data reaches an included file, the resulting server-side template injection may enable arbitrary code execution during document generation.

Affected context

The vulnerability occurs in Trestle's custom Markdown include tags, including mdsection_include and md_clean_include, when they process content that originated from OSCAL documents or other untrusted data. It is most relevant where document-generation workflows use a regular Jinja2 environment and included Markdown content can contain template expressions. Trestle versions before 3.12.4 and versions from 4.0.0 through 4.0.3 are identified as affected by the described behavior.

Exploit preconditions

  • Attack surface: Trestle document-generation workflows using the affected Markdown include tags
  • Required access: Ability to influence OSCAL prose, component descriptions, control statements, part content, or another data source written into an included Markdown file
  • Trigger point: Rendering a host template that causes the included Markdown file to be parsed as Jinja2
  • Why exploitation is possible: Included content is compiled as template code in a non-sandboxed environment, allowing expressions to execute with the capabilities available to the rendering process

Why this happens

The underlying defect is server-side template injection caused by treating data from an included Markdown file as executable Jinja2 template source. The custom include tags pass file content back into the template parser, rather than preserving it as literal text, and the rendering environment is not sandboxed. This maps primarily to CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine, with CWE-94: Improper Control of Generation of Code describing the resulting code-execution risk.

Potential impact

  • An attacker may execute arbitrary code with the privileges of the Trestle process.
  • Document-generation hosts could be compromised.
  • Sensitive files, environment variables, or credentials may be exposed.
  • Generated compliance documents could be altered or falsified.
  • The compromised process could be used for lateral movement, depending on its permissions and network access.

General mitigation guidance

Mitigation generally focuses on keeping document content separate from executable template source.

Common defensive patterns include:

  • Treating included Markdown and OSCAL-derived content as data, not template code.
  • Avoiding re-parsing of included file contents as Jinja2 source.
  • Using a sandboxed or capability-restricted template environment where templating is genuinely required.
  • Applying strict allowlisting and context-appropriate encoding to values entering generated documents.
  • Reducing trust in externally supplied OSCAL content and validating it against an appropriate schema.
  • Running document-generation processes with least privilege, restricted filesystem access, and limited network permissions.
  • Keeping template files and generated data in separate, protected locations.

How teams detect issues like this

Detection can combine source review, automated analysis, and runtime controls:

  • Search for custom template tags that pass file contents or user-controlled strings into Jinja2 parsing or compilation APIs.
  • Review uses of Environment, template evaluation, and include handlers for missing sandboxing or context restrictions.
  • Trace OSCAL prose, component descriptions, and control fields through Markdown writers into template-rendering paths.
  • Add static-analysis rules for dynamic calls to parser or compiler APIs using data-derived strings.
  • Use code-review policies requiring explicit justification for any template evaluation of generated content.
  • Monitor document-generation jobs for unexpected template errors, unusual filesystem access, or outbound connections.
  • Automated security review tools may help identify template re-parsing and untrusted data-flow patterns.

Sources

SourceLink
github.comgithub.com/oscal-compass/compliance-trestle/commit/0f82d19bd42f9cc0f1b3acd7fc3f6dafe3b6ae10
github.comgithub.com/oscal-compass/compliance-trestle/commit/5335ff873a2a68eb7de43df029bea09cadff22fd
github.comgithub.com/oscal-compass/compliance-trestle/security/advisories/GHSA-mr95-65j8-9mxp

Frequently asked

questions

Exploitability depends on deployment design. It may be reachable remotely when an externally accessible service accepts or imports attacker-controlled OSCAL content and then invokes Trestle document generation.

The attacker generally needs a way to influence content that Trestle writes into a Markdown file subsequently processed by an affected include tag. Direct access to the host is not necessarily required if an application exposes a document-ingestion workflow.

Preserve included Markdown as literal data instead of parsing it as template source. Where templating is required, use a sandboxed, capability-restricted environment and tightly control the values available during rendering.

Separate templates from generated content, validate and constrain external document data, review dynamic template evaluation paths, and run document-processing jobs with minimal privileges and restricted access.

Find out what's already
exploitable in your codebase.