Skip to content

Server-Side Template Injection (SSTI) in mode/context prompt rendering → RCE on project activation, bypassing `trusted_project_path_patterns`

Critical
MischaPanch published GHSA-pp25-4cg4-qcr9 Aug 9, 2026

Package

pip serena-agent (pip)

Affected versions

<= 1.6.1

Patched versions

1.7.0

Description

Summary

Serena renders per-project mode/context prompt fields as Jinja2 templates using a non-sandboxed jinja2.Environment(). A project can pull in an attacker-authored mode file via a path-like added_modes entry in its .serena/project.yml, and that mode's prompt string is compiled and rendered during system-prompt construction on project activation. Because the environment is unsandboxed, the prompt string can carry a standard Jinja SSTI gadget and achieve arbitrary code execution in the Serena process, on stock defaults (LSP backend, desktop-app context), with no network, no authentication, and no tool call.

Crucially, this path is not covered by trusted_project_path_patterns / is_trusted() — the control Serena built specifically to stop untrusted projects from executing code (it gates activation_command and ls_specific_settings). We empirically confirmed that on an untrusted project (trusted_project_path_patterns = []), activation_command is correctly blocked while this SSTI still executes. It is therefore a bypass of Serena's own untrusted-project protection, not the documented "the repository being worked on is trusted" assumption.

Severity

Critical

CVE ID

No known CVE

Weaknesses

No CWEs

Credits