Testing whether a PyRIT target will write malware or exploit content
PyRIT's Cyber scenario tests whether a target can be induced to generate malware or exploitation content, using both single-turn and multi-turn attacks. Run it before a model or coding assistant ships, or before your organization approves one for internal use, when you need evidence that the system resists requests for working malicious code. The scenario is one of the AIRT scenarios in PyRIT's documentation, alongside harm-category scenarios such as RapidResponse, Psychosocial and Scam, so it answers one specific question: will the target produce cyber-harm output when pushed. It does not cover every security risk a coding assistant carries, such as insecure code it writes for legitimate tasks or secrets it exposes, and those need separate checks.
Single-turn attacks send one prompt per objective, which tests the target's first-response behavior. Multi-turn attacks run a conversation in which an adversarial model rephrases, reframes and escalates across several exchanges, which tests whether safeguards hold once the request is broken into steps or wrapped in a plausible role. The documentation describes both modes for this scenario, so ask your PyRIT provider or the scenario reference which techniques and objectives are included in your installed version before you describe coverage to a reviewer. Also confirm which target you are testing: a bare model, a system prompt with tool access, and a coding agent behind an IDE each produce different results and different evidence.
Before the first run, decide what counts as a finding for your organization. PyRIT reports scored outcomes, but the scenario does not set a pass or fail threshold for you, and no threshold should be taken from this page. Agree the acceptance criteria, the owner who reviews flagged conversations, and whether results will be retested after each model or prompt change. Keep the memory database for each run, since that record is what a security reviewer or auditor will ask to see.
Which targets suit a coding assistant versus a general model
A model API is the simplest target to test. The team needs API access to the model, credentials stored where PyRIT reads them, and a registered target entry in PyRIT configuration that the scenario can call by name. Because the request goes straight to the model, the result shows how the model itself responds to malware and exploit objectives, with no application logic in between.
- Endpoint access: confirm the key, region and model version the scenario will call, and record them in the run labels.
- Registered target: the target must be registered in PyRIT configuration before
pyrit_scancan reference it. - System prompt boundary: if the team wants to test the model's default behavior, send no system prompt. If the production deployment uses one, use the same prompt so results match production.
- What the test shows: whether the bare model produces malware or exploitation content under single-turn and multi-turn attacks.
- What it does not show: safeguards added by your application, such as content filters or tool restrictions.
Confirm with the provider which safety layers apply to the API endpoint you call and which sit only in the consumer product.
A custom HTTP or WebSocket application is your own service wrapping one or more models. The team must provide a reachable endpoint, the request and response format, and authentication the test client can use from its network. PyRIT must be told how to send prompts and read replies, and the target must be registered in PyRIT configuration under a name the scenario can select.
- Endpoint access: a test identity with the same permissions as a real user, not an admin shortcut that skips application checks.
- Registered target: define the request template and response parsing in configuration, then register the target by name.
- System prompt boundary: the application's own prompt, routing and tool logic are part of what is being tested, so leave them in place.
- What the test shows: whether the application as deployed produces malware or exploit content, including effects of its guardrails and orchestration.
- What it does not show: the behavior of the underlying model when called directly, which needs its own run.
Confirm whether the endpoint keeps session state between turns, since multi-turn attacks depend on it.
A web chat UI is tested through Playwright, which drives a browser against the interface a user would see. The team must supply a login the test can use, the page address, and selectors or steps that locate the input box and the response area. The web app target must be registered in PyRIT configuration like any other target, and the scenario then runs prompts through the browser.
- Endpoint access: a test account with the role your users have, plus any single sign-on steps the browser must complete.
- Registered target: record the browser setup and the element locators in configuration so runs stay repeatable after UI changes.
- System prompt boundary: the chat product's system prompt and any retrieval or plugin behavior are in scope, so test with them enabled.
- What the test shows: the behavior a user can reach through the interface, including presentation-layer filters.
- What it does not show: how the same model responds through its API, or whether the interface logs and stores outputs safely.
Expect locator updates after each UI release and check that responses are captured in full before scoring.
A coding assistant is the target most likely to be asked for exploit code, so the team must define what the test covers before it runs. Access usually means an API or an IDE integration that the test can reach, and a system prompt or agent instruction set that governs its behavior in your environment. Register the target in PyRIT configuration in the same way as other targets, and decide whether the assistant's tools, such as file access or command execution, are enabled during the test.
- Endpoint access: use the same model, extension and organization policy your developers use, with a test identity.
- Registered target: capture the assistant version and configuration in the target entry so results can be compared across releases.
- System prompt boundary: include the agent or repository instructions your developers receive, and note any that are missing.
- What the test shows: whether the assistant writes malware or exploit material under the conditions your developers use.
- What it does not show: whether generated code is safe to run, which requires separate review.
Agree with the assistant owner which tool permissions are on during the run, and document the answer with the results.
Scenario options and when each fits
This table compares the run choices a team controls when it runs the Cyber scenario: attack depth, first-run dataset size, the scorer and memory labels. Read each row as a decision with a cost on one side and coverage on the other. The main takeaway is that a first run should be small and single-turn, with multi-turn coverage added once the scorer and labels are trusted.
| Option | When it fits | Trade-off |
|---|---|---|
| Single-turn attacks | A first run, or a quick check after a model or system prompt change, to see whether direct requests for malware or exploit code get through. | Lower request volume and easier to read, but misses attacks that build context over several turns. |
| Multi-turn attacks | Testing whether a coding assistant or chat model can be walked toward exploitation content through gradual escalation or persona framing. | Broader coverage of realistic misuse, but each objective costs more requests and needs an adversarial model. |
| Small first-run dataset | Confirming the target, credentials, scorer and memory setup work before a full assessment. Ask the vendor or check the documentation for the dataset size options in your version. | Fast feedback and low cost, but a clean result says little about the wider objective set. |
| Full objective dataset | A baseline for an assessment you will repeat or cite as evidence, once the setup has been validated on a small run. | Better coverage and comparability over time, with higher request volume, longer runtimes and more retry handling. |
| Scorer choice | Use the scorer your team can explain to a reviewer. Confirm which scorers the Cyber scenario uses by default in your PyRIT version before relying on its verdicts. | A scorer that flags code too eagerly inflates findings, while one that misses it hides exploitation content. Spot-check a sample of verdicts by hand. |
| Memory labels per run | Separating a baseline run, a post-fix retest and each release candidate so results can be compared and traced to a specific build. | Adds a little setup discipline. Without labels, results from different targets or versions are hard to tell apart in memory. |
Setting up the Cyber scenario run
This sequence takes a team from a clean machine to a verified Cyber scenario run against a registered target, with each step confirmed before the next begins. The output is a first set of results stored in PyRIT memory that the team can read and trust as a baseline.
Choose a supported Python version
The platform engineer or security engineer who will run the scan selects the interpreter first. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so use 3.13 unless your environment cannot provide it. Confirm the version with
python --versionin the shell where PyRIT will run, and record it in the run notes so later scans use the same interpreter.Install PyRIT with pip
Create a virtual environment on the chosen interpreter and install the package from PyPI with
pip install pyrit. Use the package name shown on the project page and the PyRIT documentation for version 1.1.0. Check the install by runningpyrit_scan --helpand confirming the command prints its usage text without import errors. If the command is not found, the virtual environment is probably not active.Place credentials in the environment file
The person who holds the model keys creates
~/.pyrit/.envand adds the credentials for the target under test, such as the API key and endpoint for the model or application. Keep this file readable only by the account that runs scans, and do not paste keys into shell history or tickets. Confirm the file exists with restricted permissions and that PyRIT starts without printing a missing-credential error during the next step.Set run configuration in the settings file
Create
~/.pyrit/.pyrit_confto hold non-secret settings such as the memory location and the defaults your team agrees on. Keep values that identify the environment here and secrets in.env. Confirm the settings load by running the list command in the next step and checking that the memory location it reports matches the path you set.Register the target under test
Add the model or application you will test as a registered target, using the target type your system needs, such as an OpenAI-compatible endpoint or a custom HTTP endpoint. Name it clearly, since the name appears in memory and in every result. The owner of the system should confirm the endpoint and that the test account has only the access the assessment needs. Confirm registration by listing targets and seeing the new name with its type.
List scenarios and targets
Run the list commands in pyrit_scan to confirm the Cyber scenario is available in your installed version and that your target appears in the target list. Note the exact scenario name as printed, because the run command must match it. If the Cyber scenario is missing, check the installed version against the release notes before going further, since the scenario set can change between releases.
Run a small first pass
Start the Cyber scenario against the registered target with a dataset limit so the first run covers only a few objectives. The security engineer watches the console for errors, rate-limit messages and any authentication failures, then lets the run finish. Confirm the run completed and printed a summary of objectives attempted. Keep the limit in place until the output and memory are verified, then widen it in a later run.
Read results from memory
Open the stored conversations and scores for the first run from PyRIT memory, which is kept in SQLite by default in this setup, and check that each objective has a recorded attempt, a response and a score. Look for objectives that failed to run, which indicate configuration problems rather than model behavior. The run is complete when every attempted objective is traceable in memory to its target and scenario label.
Handling malware-generating test output safely
A Cyber scenario run is designed to make a target produce malicious code, so the test artifacts are sensitive in their own right. The cards below cover the places that content can leak: memory, logs, CI output, credentials and retention, plus how to report a flaw in PyRIT itself.
Treat memory as sensitive
PyRIT stores conversations and results in SQLite or Azure SQL, so every attack prompt and every model reply that contains functional code lands in that store. Treat the memory database as a restricted repository, not a convenience file. Confirm where the database file lives on each runner, who can read it, and whether it is included in backups or sync tools.
AIRT Scenarios docsKeep content out of CI logs
A pipeline job that prints scorer output or conversation text can publish exploit code to every person with log access, and often to artifact stores that outlive the build. Configure the pipeline to record only scenario names, counts and pass or fail status. Check that verbose or debug flags are off on shared runners before any Cyber scenario runs.
Restrict target credentials
The scenario needs credentials for the target and often for an adversarial or scoring model as well. Store them in ~/.pyrit/.env or a secrets manager, never in the repository, and give the test identity only the model access it needs. Use a separate test deployment with no production data, and rotate keys after assessments are finished.
Control who can run scans
Limit who can launch Cyber scenarios and who can open the outputs, because launching a scan is what generates the sensitive content. Use separate workspaces or memory files per team, and record which operator ran each scenario. Review access lists when people change roles or leave the assessment.
Set a retention rule
Decide before the first run how long attack memory, exports and findings are kept, and who approves deletion. Keep only the evidence needed for the finding, such as the prompt, the verdict and a minimal excerpt, and purge the rest on a fixed schedule. Confirm this rule with your legal and security owners, since retention requirements vary by organization and jurisdiction.
Report PyRIT flaws privately
If testing reveals a vulnerability in PyRIT itself, do not open a public issue. The project asks for private reports through the Microsoft Security Response Center under its security policy, which is described in the project README. Include the PyRIT version, the scenario and the steps to reproduce, but leave out live exploit payloads until the maintainers confirm a channel.
PyRIT on GitHubHow a Cyber scenario run moves through PyRIT
A run starts when an operator invokes pyrit_scan against a registered target in the client's own environment. The scenario hands its objectives to the attack strategies, which send single-turn or multi-turn prompts to the target and collect each response. Scorers then judge every response for malware or exploitation content, and the conversations and scores are written to memory in SQLite or Azure SQL. Check that the target and memory stay inside the boundary you control, and that the scorer output is what you review.
Data flow of a Cyber scenario run inside the client's environment.
Questions teams ask before running the Cyber scenario
Can our internal team run the PyRIT Cyber scenario on its own?
Yes, a team with Python experience and access to the target can install PyRIT and run the Cyber scenario with pyrit_scan, provided someone owns the target configuration, the scoring setup and the review of results. PyRIT is an open-source framework under the MIT license, so there is no license fee to pay. The harder parts are not the install. They are deciding which objectives and techniques count as in scope, setting up scoring you can defend, and reading flagged outputs with the right expertise. Teams without an existing AI security function often bring in a partner for the first run and then take over the routine runs.
What drives the cost of a Cyber scenario assessment?
The main cost components are people time, model usage and the infrastructure used for testing. People time covers target setup, scenario configuration, reviewing flagged outputs and writing the findings. Model usage is driven by the number of requests sent to the target, the attacker model that generates multi-turn prompts, and the scorer model that judges each response. Dataset size and the number of techniques multiply these requests, so a broad multi-turn run costs far more to execute than a small single-turn run. Ask any provider to separate one-time setup from recurring run costs, and to state which model calls are billed to you directly.
How long does a first Cyber scenario run take?
Duration depends on the size of the scope, not on a fixed number of days. A first run is usually longer than later runs because the team must confirm the target behaves as expected, tune the dataset and agree how outputs will be judged. The main variables are the number of objectives, whether multi-turn attacks are included, how many requests the target can handle at the concurrency you allow, and how long human reviewers need to read flagged exchanges. Start with a small dataset to measure throughput, then scale. Ask for a written timeline that ties each phase to the agreed scope.
What do we need to provide before the assessment starts?
You need to provide working access to the target, the credentials it requires and a clear scoring policy. Target access means an endpoint or application the test environment can reach, ideally a non-production deployment that mirrors the model or coding assistant in use. Credentials should be issued for the test, scoped to the target and stored in a secrets manager, not in shared files. The scoring policy defines what counts as malware or exploitation content, which reviewers judge borderline cases, and how results are handled. Finally, name the person who signs off on scope before testing and the person who accepts the findings.
Who reviews flagged outputs, and how much reviewer time should we expect?
A qualified security reviewer should read flagged exchanges, because automated scorers can misclassify both harmless security discussion and genuinely harmful code. Reviewer time scales with the number of flagged results, the complexity of multi-turn conversations and how many borderline cases the scoring policy leaves open. Reviewers need the authority to mark a result as a finding, dismiss it or escalate it. Handle the outputs as sensitive material: restrict access to the review workspace and avoid copying generated code into tickets or chat channels.
Does a Cyber scenario run prove a model is safe?
No. A Cyber scenario run shows whether the attacks you selected produced malware or exploitation content against the target during that test. It does not prove the absence of other weaknesses, and results depend on the dataset, techniques, scorers and model version tested. Treat a clean run as a bounded result, record the configuration used, and repeat the run after model, prompt or safeguard changes. Compliance teams can use the records as part of their evidence, but DeployOpen does not issue audit reports or certifications, and independent auditors make those determinations.
How do we handle the generated malware content safely?
Plan handling rules before the first run. Keep memory databases and exported conversations in a restricted location with access logging, label runs so reviewers can find them, and avoid pasting generated code into shared documents, tickets or job logs. Make sure no generated code is executed, and keep the test environment isolated from production networks and credentials. Ask your provider to describe how they store, redact and delete results at the end of the engagement, and confirm that the answer matches your data handling policy.
Reading Cyber scenario results without overclaiming
Treat every Cyber scenario result as a lead for human review, not a verdict on the model. A scored conversation marked as a success means the scorer flagged a response, and the scorer can be wrong in both directions. Before you record a finding, open the conversation and confirm what the target actually produced. Separate three cases: a refusal, a response that declines the harmful part but offers general explanation, and a response that contains code or steps. Within the third case, check whether the code compiles, runs, or does anything beyond what is already public. Partial or non-functional output, such as pseudocode, broken scripts or a stub with placeholders, is a weaker finding than working exploitation content, and your write-up should say which it is. Scorer configuration is a separate question, so confirm which scorer produced each label and whether it is an LLM judge, a content classifier or custom logic, as described in the PyRIT scoring documentation.
Record each reviewed finding with the labels that identify the run, including the scenario name, target, date, attack technique and the memory label for the build or test batch. Keep the conversation IDs so a reviewer can reproduce the exchange from memory. Store the reviewer's decision next to the automated score, because a disagreement between the two is itself useful evidence about scorer quality. Do not describe a clean run as proof that a model cannot produce malware or exploit content. A clean run shows only that the chosen objectives, techniques, scorer and sample size did not trigger the scorer. Record the limits explicitly: which dataset was used, how many objectives were run, which multi-turn strategies were included, and which were skipped. Ask your security team to confirm what coverage they expect before the result is cited in a risk decision or external review.
How DeployOpen scopes and delivers AI red teaming with PyRIT
DeployOpen runs PyRIT's Cyber scenario as part of a written, fixed-scope AI security review, testing whether a model or coding assistant produces malware or exploitation content under single-turn and multi-turn attacks. Each engagement ends with documented findings, fixes and a retest, delivered inside the client's own environment.
How we scope
- Agree in writing which models, coding assistants or endpoints the Cyber scenario will target and who owns each one.
- Define the objectives, datasets, single-turn and multi-turn techniques, and the scorers that decide whether an attack succeeded.
- Record the test environment, credential handling and where PyRIT memory will be stored before any attack runs.
How we build
- Configure PyRIT in the client's infrastructure with targets registered and secrets kept out of shared configuration files.
- Run the Cyber scenario in stages, starting with a limited dataset so the client can review scorer behavior before full runs.
- Record every conversation and scored result in PyRIT memory so each finding can be traced back to the exact prompt and response.
How we hand over
- Deliver a findings report that lists each malware or exploitation result, its attack type, severity and reproduction steps.
- Provide recommended fixes for the model, system prompt, filters or tool permissions, with the owner for each action.
- Retest the fixed configuration with the same scenario and objectives, then document what changed and what remains open.
How we support
- Ongoing support, scenario upgrades and continuous testing are available as a retainer after the initial engagement ends.
- Ask any provider to confirm which PyRIT version, scorers and datasets are covered, since these change between releases.
- Agree in the written scope who reruns the Cyber scenario after model updates, and how results are shared with your security team.

