You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sandbox nested persona template rendering in evaluation prompt builders #5265
Nested persona behavior strings are rendered as Jinja templates during evaluation prompt construction. The affected code paths did not consistently keep that nested rendering inside a SandboxedEnvironment.
Both prompt builders support nested rendering of persona behavior fields through render_string_filter.
In llm_backed_user_simulator_prompts.py, the outer prompt used SandboxedEnvironment, but nested string rendering created a new template from the persona string instead of reusing the sandboxed environment.
In per_turn_user_simulator_quality_prompts.py, nested persona rendering followed the same pattern and the outer environment was not sandboxed.
As a result, nested persona strings could evaluate Jinja expressions outside the intended sandbox boundary.
Expected behavior
Nested persona strings should only render through a sandboxed Jinja environment, so supported placeholders such as {{ stop_signal }} still work but unsafe attribute traversal and similar sandbox escapes do not.
Proposed fix
Reuse SandboxedEnvironment for nested persona rendering instead of creating a fresh unsandboxed template.
Use SandboxedEnvironment in the per-turn evaluator prompt builder as well.
Add regression tests that verify:
supported nested placeholders still render
unsafe nested template expressions are blocked
Validation
I have a PR prepared that:
switches both prompt builders to sandboxed nested rendering
adds regression tests for allowed interpolation and blocked unsafe access
passes tests/unittests/evaluation/simulation in clean Linux Docker
confirms in a live adk web eval run that:
malicious nested persona templates are blocked with SecurityError
safe nested placeholders proceed past prompt rendering into normal model execution
On current main, both lines print True, showing that nested persona template rendering can execute code during prompt construction.
With PR #5266, the same payload is blocked with jinja2.exceptions.SecurityError. Safe nested placeholders still work, for example name="safe {{ stop_signal }}" renders as safe STOP.
Thank you for your contribution. Your PR is currently being reviewed. Once all checks pass and the reviewer approves, it will be merged. We appreciate your patience.
Activity
llalitkumarrr commentedon Apr 14, 2026
Hello @petrmarinec ,
To help us better understand the issue, could you please provide the steps to reproduce it? Also, a minimal code would also be very helpful.
petrmarinec commentedon Apr 14, 2026
Hi @llalitkumarrr. Here is a minimal repro that does not require
adk webor an API key.Save as
repro_ssti.pyand run from the repo root:On current
main, both lines printTrue, showing that nested persona template rendering can execute code during prompt construction.With PR #5266, the same payload is blocked with
jinja2.exceptions.SecurityError. Safe nested placeholders still work, for examplename="safe {{ stop_signal }}"renders assafe STOP.I also verified locally:
Result:
18 passed.llalitkumarrr commentedon Apr 22, 2026
Hello @petrmarinec ,
Thank you for your contribution. Your PR is currently being reviewed. Once all checks pass and the reviewer approves, it will be merged. We appreciate your patience.
fix: sandbox nested persona template rendering in evaluation prompts
adk-bot commentedon Jun 19, 2026
Notification: The author has updated the issue description. Maintainers, please review.
gammer24 commentedon Jun 19, 2026
thank s to you
GWeale commentedon Aug 6, 2026
fixed in v2.4.0, nested persona strings now render through the sandboxed jinja environment in both prompt builders. shout if it still bites you.
fix: sandbox nested persona template rendering in evaluation prompts