The PyRIT 0.12.1 Jinja2 template injection patch

If your team loads remote datasets into PyRIT, version 0.12.1 closes a server-side template injection path and changes how SeedPrompt templates render. This page explains what to change, in what order, and how to verify the result.

On this page

Why a PyRIT upgrade to 0.12.1 can't wait for your next release cycle

If your team runs PyRIT 0.12.0 or earlier and loads remote datasets or builds SeedPrompt values with Jinja2 syntax, you should upgrade to PyRIT 0.12.1 now rather than folding it into a later release. Version 0.12.1 is a security patch. It fixed a server-side template injection vulnerability in which the remote dataset loaders passed fetched data straight into SeedPrompt rendering, so content from a remote source could be evaluated as template code. The project encouraged all users of 0.12.0 and earlier to upgrade.

Treat this as a patch step on its own. The 1.0 and 1.1 changes to scenarios, converters, the conversation model, scoring and CoPyRIT are larger architecture work and are covered on their own pages. Do not hold the security fix until those migrations are scheduled. Pin the version you deploy, confirm which of your scripts or pipelines call the remote dataset loaders, and check whether any of them run in shared or CI environments where fetched content comes from sources you do not fully control. Those are the paths where the exposure matters most.

Before you upgrade, confirm two things with your own code rather than assuming the fix is transparent. First, all Jinja2 rendering in 0.12.1 uses a sandboxed environment, so templates that relied on unrestricted template features may no longer render as they did. Second, after 0.12.1, any SeedPrompt value that you write with Jinja2 syntax must set is_jinja_template=True to keep rendering. Search your repositories for Jinja2 placeholders in seed prompts and YAML seed files, add the flag where needed, and run those scripts against a test target. The PyRIT v0.12.1 release notes are the source to check against for the exact change.

What changed in PyRIT 0.12.1 and what each change means for your team

This table lists each change in PyRIT 0.12.1 that affects code and deployments, with its impact and the action your team needs. Read the rows in order: the vulnerability and sandboxing changes explain why the template rule exists, and the upgrade row tells you which installs are exposed. Auto-escaping is not covered here, so confirm its behavior against the release notes before you rely on it.

ChangeImpactAction needed
Jinja2 server-side template injection fix in remote dataset loadersRemote dataset loaders passed fetched data into SeedPrompt rendering, so content from a remote source could run as template code on your machine.Upgrade to 0.12.1 and review which datasets your team loads from remote sources.
All Jinja2 rendering moved to SandboxedEnvironmentTemplate rendering is restricted, so templates that relied on unrestricted Jinja2 behavior may no longer render as before.Test your scripts and seed files after upgrading and fix any rendering errors.
Upgrade encouraged for all users of 0.12.0 and earlierInstalls at 0.12.0 or earlier carry the unpatched rendering path until they move to 0.12.1.Inventory every environment, including CI runners and shared CoPyRIT hosts, that pins a PyRIT version.
SeedPrompt values with Jinja2 syntax must set is_jinja_template=TrueAfter 0.12.1, Jinja2 syntax without this flag is not rendered, so prompts may reach targets with raw template text.Find SeedPrompt values containing Jinja2 syntax and set is_jinja_template=True on each one.
Auto-escaping behaviorNot stated in the supplied release facts, so the impact on your output is unconfirmed.Check the 0.12.1 release notes for escaping behavior before changing any template.

How fetched dataset content reaches the template renderer

The path starts at a remote dataset source, which a dataset loader fetches from. The loader hands that content to SeedPrompt construction, and the rendering step is where the risk sits, because fetched text is treated as template input. In 0.12.1 all rendering goes through a SandboxedEnvironment, and templates your team wrote itself must set is_jinja_template=True to keep rendering. Check which of your prompts fall on each side of the boundary.

Fetched dataset content crosses a trust boundary before any Jinja2 rendering in PyRIT 0.12.1.

Why unsandboxed Jinja2 rendering turned loaded data into a risk

Rendering fetched content as a Jinja2 template is risky because template syntax inside data is interpreted, not treated as plain text. Before 0.12.1, remote dataset loaders passed fetched data into SeedPrompt rendering, so whatever a remote source contained could be evaluated by the template engine. That means the content source, not only the code you wrote, could influence what the renderer does. The issue is server-side: the rendering happens in the process that runs your PyRIT job, which usually has access to your model credentials, your memory database and the network paths your red team uses. Any team that loads datasets from outside its own control should treat that trust boundary as part of the risk review.

A sandboxed environment limits what template code can reach. Jinja2 offers a sandbox mode that restricts access to attributes and objects that could be used to reach beyond the template, and PyRIT 0.12.1 moved all Jinja2 rendering onto that sandboxed environment according to the v0.12.1 release notes. Sandboxing reduces what an injected expression can touch, but it is a containment layer, not a reason to trust fetched content. Auto-escaping matters separately for output handling: if rendered text is later displayed in a web view, written to a report or passed to another system, escaping controls how markup and special characters are treated at that point. Confirm which of these paths apply to your PyRIT outputs.

Confirm the exact scope of the issue against the v0.12.1 release notes and your own loader usage before deciding how urgent the upgrade is. List every place your team calls a remote dataset loader, every SeedPrompt built from fetched text, and every job that runs with production credentials. If a loader only reads data you have reviewed and stored locally, the exposure differs from a loader that pulls content from a shared or third-party source on each run. Record that assessment so the upgrade decision and the later template changes can be traced back to it.

Who changes code: remote loader users versus teams with their own templates

If your team only uses built-in datasets or remote dataset loaders, your main work is upgrading to 0.12.1 and confirming that the loaded prompts still render and score as expected. The vulnerable path was fetched data passed into SeedPrompt rendering, so the fix sits in PyRIT itself. Most teams in this group will not need to rewrite their objectives, but they should confirm this in their own runs.

  • Pin the version: Move every environment to 0.12.1 or later and record the exact version in your requirements or lock file.
  • Read the release notes: Review the v0.12.1 release notes to confirm the change covers each loader your team calls.
  • Re-run a baseline: Run a fixed set of remote-loaded prompts before and after the upgrade, then compare the rendered text and the scores.
  • Treat fetched content as untrusted: Include dataset updates in your change review, since the vulnerability came from fetched data reaching the template engine.
  • Search for custom objects: Find any SeedPrompt objects your scripts build directly. If you find any, follow the guidance in the next tab.

Check the installed version, a rendered sample from each remote source, and whether any custom SeedPrompt objects exist.

What to inventory and back up before applying the patch

Patching PyRIT to 0.12.1 is a small code change, but it touches every workflow that renders SeedPrompt templates or loads remote datasets. The cards below cover what to record, search and preserve so you can upgrade with a known starting point and compare results afterward.

Inventory every PyRIT consumer

List every script, notebook, CI job and pipeline that imports PyRIT, and record the version each one pins in its requirements file, lock file or container image. Include CoPyRIT deployments and any pyrit_scan jobs run from a scheduler. Confirm the pinned versions against the environments that actually run the code, since a laptop notebook and a production job often differ.

v0.12.1 release notes

Search for SeedPrompt and Jinja2 syntax

Search your own code for SeedPrompt construction and for Jinja2 delimiters such as {{, {% and {# in prompt strings, YAML seed files and templates. Under 0.12.1, values that use Jinja2 syntax must set is_jinja_template=True to keep rendering, so each match needs a decision: keep rendering with the flag, or treat the text as literal.

Map remote dataset loaders to workflows

Record each workflow that calls a remote dataset loader, along with the source it fetches from and who maintains that source. The patch addressed data fetched by remote loaders being passed into SeedPrompt rendering, so these are the paths where untrusted content reached the template engine. Note which loaders you can replace with local, reviewed files.

Back up the memory store and configuration

Copy the memory store, whether SQLite or Azure SQL, and the ~/.pyrit/.env and ~/.pyrit/.pyrit_conf files before changing any version. Store the credentials file with the same protection as other secrets. Confirm the exact file locations and database connection details in your own environment, because team setups often override the defaults.

Build a pinned test environment

Create a separate test environment on a Python version the PyPI package supports, which is 3.10 up to but not including 3.15. The PyRIT documentation recommends Python 3.13. Install the currently pinned version first, then 0.12.1, so you can reproduce the baseline and isolate any behavior change to the patch.

PyPI package page

Snapshot results for comparison

Export the current attack results, scores and conversation records for each workflow before upgrading. After the upgrade, rerun the same objectives against the same targets and compare outputs, scores and rendered prompts. Differences in rendered templates are the first thing to check, because they show where content that previously rendered now stays literal or fails.

How to apply the 0.12.1 patch and verify template rendering

This sequence moves a PyRIT test environment onto 0.12.1, updates any Jinja2-based SeedPrompt values, and confirms that remote datasets still load and render before the change reaches production.

  1. Pin the test environment to 0.12.1

    The engineer responsible for the PyRIT installation records the current version, then pins the test environment to 0.12.1 in its dependency file. Confirm that the Python interpreter falls inside the range the PyPI package supports, which is Python 3.10 up to but not including 3.15, and that it matches the 3.13 version the documentation recommends if your team can use it. The step is done when the install reports 0.12.1 and the interpreter version is written down in the change record.

  2. Run existing scripts on the upgraded test environment

    With 0.12.1 installed in the test environment only, run your existing PyRIT scripts, scanner jobs and scenarios as they normally run. Capture the console output, exit codes and the memory database location for each run, so that the results can be compared later. Any import or runtime error that is not related to templates should be fixed or logged before continuing. The step is done when every script completes or fails for a known, documented reason.

  3. Find SeedPrompt values that use Jinja2 syntax

    Search your repositories, YAML seed files and any code that constructs SeedPrompt objects for Jinja2 delimiters such as double curly braces or block tags. Each match is a value that will stop rendering after 0.12.1 unless you set is_jinja_template=True on it. Keep the list in a tracked file so that reviewers can see every change. The step is done when each matched value has either been updated or confirmed as plain text that should not be rendered.

  4. Set is_jinja_template for templates you own

    Developers update each SeedPrompt that uses Jinja2 syntax by setting is_jinja_template=True, which tells PyRIT to keep rendering it through the sandboxed environment. Values that came from remote dataset loaders should be reviewed, since the fix changes how fetched data is rendered and you need to know which of them actually contain template syntax. Run the test suite or a short scenario after each batch of changes. The step is done when the tests pass and the reviewed list shows no unexplained exceptions.

  5. Load remote datasets and check rendering in test

    Run your remote dataset loaders in the test environment and confirm that the data loads, that templated prompts render to the text you expect, and that prompts with no template syntax pass through unchanged. Check a sample of rendered prompts by eye, because auto-escaping can change characters that appear in content. The step is done when a reviewer has signed off on the sample and any rendering differences are documented.

  6. Compare outputs with the pre-upgrade snapshot

    Compare the rendered prompts, scorer inputs and stored results from the test run with the snapshot you recorded before the upgrade. Differences should be explained one by one, whether they come from escaping, from changed template handling or from a remote dataset that changed on its own. Do not treat a difference as acceptable until its cause is written down. The step is done when every difference has a recorded reason and no unexplained change remains.

  7. Promote to production in a controlled window

    Schedule the production change through your normal change process and deploy the pinned 0.12.1 version with the updated SeedPrompt code. Before the change, take a backup of the PyRIT memory store and the configuration files in ~/.pyrit, and keep the previous pinned version available. Confirm the rollback steps against your own packaging and deployment tooling, since no rollback procedure is supplied here. The step is done when a production smoke run matches the approved test results and the rollback point is recorded.

What makes the 0.12.1 patch take longer for some teams

This table lists the factors that change how much work the 0.12.1 Jinja2 patch creates for a given team. Read each row as a question to answer about your own setup, and treat a high count in any row as a sign to plan more testing time. The main takeaway is that the code change is usually small, while the number of SeedPrompt templates, loaders, environments and scheduled jobs is what stretches the work.

DriverWhy it mattersWhat to check
SeedPrompt values written with Jinja2 syntaxEvery value containing Jinja2 syntax must set is_jinja_template=True after 0.12.1 or it will stop rendering as expected.Search scripts, YAML seed files and pipelines for template markers and count each place a SeedPrompt is built.
Remote dataset loaders in useLoaders that fetch data and pass it into SeedPrompt rendering were the source of the injection issue, so these paths need the most review.List every remote dataset source, who owns it and whether its content is trusted or changed by third parties.
CI pipelines and scheduled jobsUnattended runs can fail or silently change results after upgrade, and they may pin an older version.Identify which jobs call PyRIT, where their version pins live and who is notified when a run fails.
Size of the memory store to back upA backup is the safe rollback point before upgrading, and larger stores take longer to copy and verify.Confirm the memory location (SQLite or Azure SQL), current size, backup method and a tested restore procedure.
Number of environmentsDevelopment, test and production each need the upgrade and its checks, and drift between them causes surprises.Confirm the installed version in each environment and the order in which changes will be promoted.
Custom CoPyRIT instances or initializersTeam-owned web instances and custom initializers may build or load templates through their own code paths.Check whether any instance or initializer constructs SeedPrompt values or loads remote datasets, and retest those paths.

What buyers ask before hiring help with the PyRIT 0.12.1 upgrade

How much effort does the PyRIT 0.12.1 patch take?

The effort depends on how much of your code builds SeedPrompt values with Jinja2 syntax and how many of those values come from remote dataset loaders. The code change itself is usually small for each affected call site: after 0.12.1, any SeedPrompt value that uses Jinja2 syntax must set is_jinja_template=True to keep rendering. The larger part of the work is finding those call sites. Effort rises with the number of scripts, the number of teams that share them, the number of custom templates, and how many workflows load data from outside your own repository. Ask for an inventory before you ask for a quote, because the inventory sets the size of the work. Once you know the call sites, you can also judge whether retesting each workflow is a short check or a longer exercise.

How long does a PyRIT 0.12.1 upgrade take?

The timeline is set by the number of affected workflows, how many owners must sign off on changes, and whether you have a working test environment where scripts can run before they touch shared red teaming setups. The release notes establish the core requirement: all users of 0.12.0 and earlier were encouraged to upgrade, and code that relies on Jinja2 rendering needs the flag after the change. No duration figure is supplied for this patch, so ask any provider to give you a schedule based on your inventory and written scope, not a generic estimate. Plan for a pause in any pipeline that relies on the old behavior until its owner has verified the output.

What does the upgrade need from our team?

The work needs three things from your side. First, read access to every repository, notebook, pipeline and ~/.pyrit configuration location where PyRIT runs, so the inventory is complete. Second, a test environment that mirrors how you load datasets, including any remote sources, so changes can be checked without touching live red teaming runs. Third, a named owner for each workflow who can confirm that the output still matches what the workflow is meant to produce. Owners matter because a template that renders differently may still run without an error. Ask who will approve changes and who will rerun the affected tests before the upgrade is closed.

Can our own engineers apply the 0.12.1 patch without a partner?

Yes, for a small codebase with clear ownership, your own engineers can usually do the work. The change is well defined in the release notes, and a team that knows its own templates can search for Jinja2 syntax in SeedPrompt values, add the flag where rendering is intended, and rerun its tests. Bring in a partner when the inventory is large, when scripts are spread across several teams with no single owner, when remote dataset loaders feed templates you did not write, or when you need an independent record of what was changed and retested for a compliance review. A partner can also take on the retest and evidence work so your engineers keep their time for product tasks.

Does DeployOpen offer fixed-scope engagements for this work?

Yes. Most DeployOpen engagements are fixed-scope, with the scope, deliverables and timeline agreed in writing before work starts. For this patch, a written scope would normally cover the inventory of affected workflows, the changes to SeedPrompt values that use Jinja2 syntax, the retest of each workflow, and a summary of what changed. A quote follows from that written scope, so the more complete your inventory and owner list, the more precise the quote. DeployOpen does not publish a price list. Ask for the scope to list each workflow, who approves changes, and which retests are included.

What cost components should we expect in a quote?

A quote for this patch usually separates the discovery work, the code changes, the retesting and the handover documentation. Discovery covers finding every affected call site. Code changes cover adding the flag where rendering is intended and removing rendering that should not happen. Retesting covers confirming each workflow still produces the expected output. Handover covers a short record of what changed and who signed off. Ask which items are one-time work and which, if any, would recur, such as ongoing support for later PyRIT releases. Ask how the quote changes if your inventory grows during discovery, and whether that change is agreed in writing before more work starts.

How do we report a suspected PyRIT vulnerability privately?

Report suspected PyRIT vulnerabilities privately through the Microsoft Security Response Center under the project's security policy. The PyRIT README points to this route, so do not open a public GitHub issue that describes an exploitable flaw. Include the PyRIT version you run, the workflow that triggers the problem, and the steps needed to reproduce it. If your concern involves remote dataset loading, say which source feeds the template. Keep your internal records of the report, including the date you sent it and the version you were running, so your security team can follow the case later.

Which parts of the upgrade are most likely to go wrong?

The most common failure is a template that still contains Jinja2 syntax but lacks the flag, so it is passed through as plain text and the workflow runs without the expected substitution. The reverse also happens: a value that was meant to be plain text is flagged and rendered. Both cases can pass a basic run while producing different prompts. Another risk is an inventory that misses scripts stored outside the main repository, such as notebooks or private pipelines. Test each workflow against known outputs, and keep the old and new results side by side for the owner to compare.

How DeployOpen works on this

DeployOpen starts by inventorying every place your PyRIT code loads remote datasets or builds SeedPrompt values with Jinja2 syntax, then agrees the upgrade in writing before work begins. The work covers the 0.12.1 change, the test evidence you keep, and the handover to your team.

How we scope

  • We list every PyRIT entry point that loads remote datasets and every SeedPrompt value containing Jinja2 syntax.
  • The written scope names the PyRIT versions in use, the target environments and the templates to be reviewed.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before any code changes start.

How we build

  • We move the affected code to PyRIT 0.12.1 and set is_jinja_template=True only where templates must still render.
  • We rerun representative seed prompt and dataset loads to confirm templates render as intended after the change.
  • We check that fetched remote data is no longer treated as trusted template source in the code paths we changed.

How we hand over

  • You receive a change record listing each modified SeedPrompt, the reason for the flag and the test results.
  • The documentation explains which templates are intended to render and how to add new ones safely.
  • Your team walks through the changes with us so the review and approval steps are clear for future updates.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers for teams that update PyRIT regularly.
  • Retainer work can cover reviews of new PyRIT releases, including the 1.0 and 1.1 changes, against your code.
  • Ask any provider to confirm how security reports and patch notices reach your team before you sign.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.