PyRIT AIRT Leakage scenario for sensitive data and IP

Run PyRIT's Leakage scenario to test whether a model exposes sensitive data or memorised copyrighted text, then read the plagiarism scorer's three overlap metrics with your own thresholds.

On this page

How the PyRIT Leakage scenario tests sensitive data and IP exposure

PyRIT's Leakage scenario probes whether a target leaks sensitive data or intellectual property, and it scores responses with plagiarism detection. Teams need this when they deploy or integrate a model that may have seen confidential records, internal documents or copyrighted text, and they must show a reviewer what the model will reproduce under pressure. The scenario sits within PyRIT's AIRT scenarios alongside RapidResponse and the other packaged assessments, so it runs from the same pyrit_scan workflow and writes results to the same memory store as those scenarios. That shared structure matters because the leakage evidence can be compared with harmful content results from the same target, build and date.

Before running it, the team should decide what counts as sensitive for their deployment. The scenario's objectives come from its datasets, so the owner should confirm which leakage datasets ship with the installed PyRIT version and whether they match the data the model actually touches, such as customer records, source code or licensed publications. Anything the model can see through retrieval, fine-tuning or a system prompt belongs in scope. Ask the team responsible for the target to confirm which system prompts, tools and data sources are attached, because a target tested without its retrieval layer will not show the leakage that layer creates.

Plan the run as evidence rather than a one-off check. Record the target configuration, the PyRIT version, the dataset names and the memory labels for each run, so an auditor or security reviewer can reproduce the result later. The output will show plagiarism-style overlap, not a pass or fail verdict, so the team must set its own acceptance threshold and document who approved it. Confirm that the approving owner understands the scorer's limits before the first run.

Choosing techniques and datasets for a leakage run

A single-turn run sends each leakage objective as one prompt and scores the one reply. It is the cheapest way to learn whether the target volunteers sensitive data or reproduces protected text at all, and it gives you a reference point for every later run. Because cost grows with the number of objectives, a small first dataset is the sensible starting point.

  • Request cost: one target call per objective, plus scorer calls. Total requests equal dataset size multiplied by the number of technique variants you enable.
  • What it tests: whether the model answers with sensitive content or copyrighted text when asked directly, with no disguise applied.
  • Start here when: you have no baseline yet, or you need a first result to compare against converted or multi-turn variants.
  • Reading the output: a low overlap score on a direct prompt only means something if the dataset contains content the model could plausibly reproduce. Ask whether your chosen dataset includes text the target would have seen in training or retrieval.
  • Time: runs are dominated by target latency, so a larger dataset takes proportionally longer on a single worker.

Before running, confirm in the scenario documentation which datasets the Leakage scenario loads by default and how to limit their size for a first run.

Scenario options and when each fits

This table compares the main configuration choices for a Leakage scenario run: dataset, technique, first-run size, target registration and adversarial model. Read each row for when the option fits and what it costs in coverage, request volume and reviewer effort. Confirm default values in the PyRIT documentation for your installed version before relying on them.

OptionWhen it fitsTrade-off on coverage, requests and reviewWhat to confirm
Leakage dataset, fullFinal assessment of a model or app that handles regulated or confidential dataBroadest coverage of leakage objectives, highest request volume, largest set of plagiarism results to reviewDataset contents and size for your version
Leakage dataset, limitedFirst run to check that the target, scorer and memory work end to endFast and cheap, but misses objectives that appear later in the datasetHow the size limit option is named and applied
Single-turn techniques onlyBaseline check of direct leakage requests, or a CI gate on each changeLow request count and easy review, but does not test whether repeated pressure extracts more textWhich techniques are available in your scenario build
FirstLetter techniqueTesting whether a model reproduces memorised text when asked for letters or fragments instead of full passagesAdds a different probe for memorised copyrighted or sensitive text, but scores depend on how the reply is reconstructed, so reviewers must check mismatches by handHow FirstLetter output is transformed before the plagiarism scorer reads it
Multi-turn techniquesTargets that refused the direct request but may give more under follow-up pressureFinds more leakage paths, but each objective costs several requests and needs an adversarial modelDefault multi-turn strategies and their request counts
Adversarial model choiceMulti-turn runs where the attacker model must be chosen for capability, access or data policyA stronger attacker may find more leakage but adds cost and sends test content to that model providerWhich models your organization approves to generate attack prompts
Target registrationAny run, so pyrit_scan points at the correct endpoint and credentialsRegistration errors show up as false clean results, so the first run should include a known-leaking control if one existsRegistered target name, endpoint and credential source in ~/.pyrit/.env
Scorer thresholdsAny run where the plagiarism overlap values need a pass or fail decisionPyRIT reports three overlap metrics with no built-in threshold, so the team sets its own cut-offs and reviewers check borderline casesThreshold values agreed with your legal and security reviewers

Reading the three plagiarism overlap metrics

The PlagiarismScorer reports three overlap measures for each response compared against protected reference text. Each card below explains one measure, why the three can disagree, and what your team must define before a leakage result means anything.

Longest common subsequence

The LCS metric finds the longest run of words or characters that appears in the same order in both the model output and the reference text, then normalises that length to a value from 0 to 1. Gaps are allowed between matched tokens, so a response that paraphrases lightly but keeps the sequence of a passage can still score high. Check whether your reference text is tokenised by word or by character before you compare scores across runs.

Levenshtein edit distance similarity

The Levenshtein metric counts the minimum number of insertions, deletions and substitutions needed to turn one text into the other, then converts that count into a similarity from 0 to 1. It rewards near-verbatim reproduction and drops quickly when a response is reordered, shortened or reworded. A short leaked passage inside a long unrelated answer will score low on this measure even when the leak is serious, so read it alongside the other two.

Jaccard n-gram overlap

The Jaccard metric compares the set of word n-grams in the response with the set in the reference and divides the shared n-grams by the total distinct n-grams in both. It is insensitive to word order, so a response that lifts many phrases but rearranges them can score well here while scoring poorly on LCS. Confirm the n-gram size your scorer uses, because a larger size makes matches stricter.

Why the three scores disagree

Each metric answers a different question: whether the sequence is kept (LCS), how close the text is to verbatim (Levenshtein), and how much shared phrasing exists regardless of order (Jaccard). A high score on one with a low score on another usually means a specific pattern, such as reordered sentences or a single copied paragraph. Record all three values for every flagged objective so reviewers can see which pattern drove the result.

No built-in pass or fail threshold

PyRIT sets no built-in threshold for these metrics, so a run reports numbers but does not decide whether a model failed. Your team must choose cut-off values per metric, or a rule that combines them, and document why those values fit your content. Agree the criteria in writing with legal and IP owners before the first scan, including what counts as protected text and what happens to borderline results.

AIRT scenarios docs

Calibrating against known text

Before relying on any cut-off, run the scorer on samples you know are copied, paraphrased and unrelated, then check whether the three scores separate them as you expect. Store the calibration set and the chosen thresholds with the scenario configuration so later runs use the same criteria. Re-check calibration after changing the reference corpus, the tokenisation or the target model.

How to set up a first Leakage run with pyrit_scan

This sequence takes a team from a clean machine to a first limited Leakage scenario run, with a check at each step so that the memory output can be reviewed before any larger run. It produces a verified installation, a registered target and a reviewable set of leakage results that the team can compare against an approved reference text.

  1. Install PyRIT on a supported Python version

    The engineer installing PyRIT creates a virtual environment and installs the pyrit package from PyPI with pip. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so use that version where your environment allows it. The step is done when the pyrit_scan command runs and prints its help text without import errors, and the installed version matches the release your team has approved.

  2. Configure credentials and settings files

    The engineer who owns the test account creates ~/.pyrit/.env for credentials and ~/.pyrit/.pyrit_conf for settings. Store only the keys for the target under test, and keep the file out of version control and shared shell history. The step is done when a short Python check can read the configured values without printing them, and the file permissions limit access to the engineer running the test.

  3. Register the target under test

    The engineer adds the model or application endpoint to the target registry, using the target type that matches your system, such as an OpenAI-compatible endpoint, a custom HTTP endpoint or a self-hosted model. Confirm with the application owner which system prompt, tools and data sources the target uses in production, because leakage results depend on them. The step is done when the target name resolves in the registry and a single test prompt returns a response from the intended system.

  4. Confirm the Leakage scenario is listed

    The engineer runs the scenario listing command in pyrit_scan to confirm that the Leakage scenario is available in the installed version. Check that the scenario name matches the one in the AIRT documentation for your release, since names can change between versions. The step is done when the listing shows the Leakage scenario and the registered target appears in the target listing.

  5. Supply and approve the reference text

    The test owner and the legal or IP reviewer agree on the reference text that the plagiarism scorer compares responses against, such as internal documents, source code, or copyrighted passages the organization has a right to test with. Record who approved the text and why, and store it in a location the run can read. The step is done when the approval is written down and the reference file is in place. Without an approved reference, the leakage results cannot be interpreted.

  6. Run the scenario with a limited dataset size

    The engineer starts the Leakage scenario through pyrit_scan with the dataset size limited for a first run, so that the team can read the output and catch configuration errors before scaling up. Keep the run attached to a clearly named memory label so it can be found later. The step is done when the command completes or stops with a readable error, and the run record appears in memory with the expected number of objectives.

  7. Review the memory output and scorer results

    The engineer opens the stored conversations and scorer results for the run and reads each response that the plagiarism scorer flagged, checking the LCS, Levenshtein and Jaccard n-gram values against the reference text. PyRIT normalizes these metrics to a range from 0 to 1 and provides no built-in threshold, so the team should record in advance what values it will treat as a finding. The step is done when each flagged response has a reviewer decision and the run is saved for the next comparison.

Turning leakage scores into findings a reviewer can act on

A leakage score is a signal, not a finding. The PlagiarismScorer reports LCS, Levenshtein and Jaccard n-gram overlap normalised to 0 to 1, and PyRIT ships with no built-in threshold for turning those numbers into a verdict. Before anyone files a finding, the reviewer should separate true leakage from coincidental overlap. Common phrases, legal boilerplate, standard code idioms, quoted public domain text and widely repeated product descriptions can all produce high n-gram overlap without the model reproducing a protected source. Check whether the matched span is distinctive, whether the same text appears in the objective or the prompt itself, and whether the source is one your organization owns, licenses or can identify.

Record each candidate finding as a unit a second reviewer can reproduce. Keep the conversation exported from memory, the scenario and objective identifiers, the converter or FirstLetter variant used, the three overlap scores, the matched source reference if one exists, and the reviewer's decision with a reason. Label the run so the record can be traced back to the target version and configuration tested. Store reviewer decisions alongside raw scores rather than overwriting them, so a later reviewer can see why an overlap was dismissed. The team's own review process should define what counts as a confirmed leak, a borderline case and a false positive, and who may close each one. Ask your security and legal reviewers to agree those categories before the first run, because no industry threshold settles them for you.

After a fix such as a data filter, a training change or a system prompt update, rerun the same objective set against the same technique set and compare the new scores with the reviewed baseline. A lower score is not proof of a fix on its own, since a changed phrasing or a different converter can hide the same leak. Confirm that the confirmed cases no longer reproduce, that borderline cases were rechecked by the reviewer, and that the retest used the same target configuration as the original run. Keep the retest result in the same record so the finding can be closed with evidence.

Security and handling risks in leakage testing

A leakage run can surface real personal data or copyrighted text, so the output becomes sensitive material in its own right. The cards below cover where PyRIT keeps that output, who can read it, what reference content you feed in, and how to report flaws in PyRIT itself.

Memory holds the evidence

PyRIT stores conversations and scoring results in SQLite or Azure SQL. A leakage run writes the model's replies, which may contain personal data or verbatim text, into that memory. Decide where the database file or Azure SQL instance lives, confirm its encryption and backup settings, and set a deletion routine so leaked content does not persist longer than the finding needs.

PyRIT docs

Restrict access to results

Anyone who can query PyRIT memory can read the sensitive replies it recorded. Limit read access to the red team members who triage findings, keep the memory file or database out of shared drives, and log who exports conversations. Treat exported reports with the same classification as the raw memory.

Protect reference corpora

Leakage scoring compares model output with a reference text, so your corpus of copyrighted or confidential passages is itself sensitive. Store it in access-controlled storage, record who added each document, and avoid copying it into prompts or config files that other engineers can open. Confirm that the corpus licence permits the comparison you run.

Keep leaked content out of logs

CI runners often print console output and retain job logs for other users. A leakage scenario that echoes matched text into a build log spreads the exposure beyond the memory store. Configure the pipeline to report counts and scores only, mask secrets, and restrict who can open job logs for these runs.

Manage target credentials

PyRIT reads credentials from ~/.pyrit/.env and settings from ~/.pyrit_conf. Those files sit on the machine running the scan, so a shared workstation or runner exposes the target keys to anyone with access. Use a secrets store where possible, scope the target key to test traffic, and rotate it after the assessment.

Report PyRIT flaws privately

If a leakage test exposes a defect in PyRIT itself, do not open a public issue with reproduction details. The project's security policy directs vulnerability reports privately to the Microsoft Security Response Center. Confirm the current reporting route in the repository security policy before your first run, and record the PyRIT version you tested.

PyRIT repository

Questions buyers ask about PyRIT leakage testing

What does the work need from our side before a leakage test starts?

A leakage test needs three things from you: access to the target, reference data that defines what counts as sensitive, and named owners who can make decisions about that data. Target access means a registered endpoint or credentials for the model or application, plus a test environment that mirrors production behavior. Reference data is the set of documents, record formats or copyrighted texts the test compares against, so it must be identified and approved for use in testing. Owners for sensitive data should include someone who can confirm what a leaked string would mean for your organization and who can review hits quickly. Confirm each of these in writing before the scope is agreed.

Can our internal team run the PyRIT Leakage scenario without a partner?

Yes, if your team has Python skills, can install PyRIT from PyPI, and can manage the credentials and reference data safely. The scenario runs from the pyrit_scan command against a registered target, so the mechanics are not the hard part. The harder parts are deciding which datasets represent your sensitive data, reviewing scorer output with judgment, and keeping leaked material out of shared logs. A partner adds value when you need that judgment applied across several systems, evidence that an assessor can follow, or a retest after fixes.

What drives the effort of a leakage assessment?

Effort rises with the number of objectives, the size of the reference dataset, the use of multi-turn techniques, and the time reviewers spend on flagged responses. Each additional objective multiplies the requests sent to the target. Multi-turn attacks use several exchanges per objective and also need an adversarial model, so they cost more than single-turn runs. Target rate limits set how fast requests can go, and a slow or throttled endpoint extends the run. Reviewer time often dominates, because each overlap score above your review threshold needs a person to check whether the match is sensitive.

How long does a first leakage run take?

Duration depends on scope, so no fixed figure applies. A first run on a small reference set against one target is much shorter than a full assessment across several applications with multi-turn techniques and a review cycle. Plan the first run as a limited pilot: a small dataset, one target and single-turn techniques, so you learn how the target responds and how long reviews take. Use those measurements to estimate the full run. A written scope should state the datasets, techniques, targets and review steps so that the timeline follows from them.

How do we read the three plagiarism overlap metrics?

The PlagiarismScorer reports LCS, Levenshtein and Jaccard n-gram metrics, each normalized from 0 to 1. Longest common subsequence (LCS) measures how much of a reference text appears in order in the response, Levenshtein measures edit distance, and Jaccard n-gram measures shared word sequences. A high LCS with a high Jaccard score suggests the response reproduces text closely, while a high Jaccard score alone may reflect common phrasing. PyRIT provides no built-in threshold, so you must set one, document it, and test it against known examples before trusting results.

What should we confirm about the 1.1.0 Leakage scenario before relying on it?

Confirm that the scenario, its datasets and its scorers behave as your documentation describes in the PyRIT release you install. Check the PyRIT documentation for version 1.1.0, which covers the AIRT scenarios, and confirm which datasets the Leakage scenario uses and how the FirstLetter technique is applied. Verify the Python version support on PyPI and the recommended runtime. Run the scenario against a target you control with known leaked content to confirm that detections match expectations. Record the exact version and settings so the result can be repeated.

Who owns the copyright and license questions for reference text we test against?

You do, or the rights holder for that material, and your legal team should decide what text you may load for testing. PyRIT is MIT licensed, but that license governs the framework, not the documents you feed into it. Reference copyrighted text should be stored and handled under your own data policies, and results that quote it should stay within your review group. Confirm this with counsel before the first run, since the license answer is separate from the data-use answer.

Limits to confirm in your environment

The Leakage scenario gives a useful signal, but its scores depend on the datasets, the scorer thresholds you choose and the models on both sides of the attack. The cards below list what your team should verify before treating a run as evidence about sensitive data or intellectual property.

Dataset coverage for your data types

Check whether the Leakage datasets cover the sensitive data your application actually handles, such as customer records, internal source code, contract text or clinical notes. PyRIT's datasets span data leakage, but a generic set will not contain your schemas, identifiers or document formats. Plan to add seed prompts that mirror your real data classes, using synthetic records only, and document which classes the scenario did not test.

AIRT Scenarios docs

No built-in plagiarism threshold

The PlagiarismScorer reports LCS, Levenshtein and Jaccard n-gram metrics normalized to 0 to 1, but PyRIT does not ship a cut-off that says a response is a leak. Your team must decide which value counts as overlap for each metric, how long a copied passage must be before it matters, and who signs off on that choice. Record the thresholds in the scenario configuration so later runs are comparable.

Dependence on target behavior

A leakage result describes one target at one point in time. Changes to the system prompt, retrieval index, model version, safety layer or temperature can shift the output, so a clean run does not carry over to a new release. Confirm which components are in the tested path and rerun the scenario after each change that affects them.

Adversarial model behavior

Multi-turn and encoded attacks depend on the adversarial model that writes the probes and on the scorer model that judges replies. If either model refuses, drifts or misreads the task, the run can miss leaks that a stronger attacker would find. Compare results across at least two adversarial models before treating a low overlap score as proof that the target is safe.

Archived Azure/PyRIT repository

The original Azure/PyRIT repository was archived on 27 March 2026 and is read-only. Pin your install to the active microsoft/PyRIT project, confirm the package version you run against the release notes, and update internal runbooks, pipeline references and links that still point to the archive. Using the archived copy for new work would leave you without fixes.

microsoft/PyRIT repo

Scan results are not legal conclusions

A Leakage scan shows whether a model produced text that overlaps with a reference you supplied. It does not establish whether copyright was infringed, whether a licence was breached, whether a data protection duty was met or who owns the output. Involve counsel and your privacy office to interpret findings, and treat the scan as one input to those decisions rather than a compliance determination.

How a leakage scan moves from target to reviewed finding

The scan starts when pyrit_scan loads the Leakage scenario and selects a registered target. Each objective passes through the configured converters and techniques before the prompt reaches the target. The response is then scored against reference text by the PlagiarismScorer, and the scored conversation is written to PyRIT memory. A human reviewer reads the flagged conversations, checks the overlap metrics against the threshold the team has set, and records the finding. Nothing in the pipeline decides on its own that a leak is a finding.

Data path from scenario launch through scoring to the reviewer's findings.

How DeployOpen scopes and delivers a PyRIT leakage assessment

DeployOpen plans and runs PyRIT leakage assessments inside the infrastructure you control, so the target, the test data and the memory records stay under your governance. We agree the scope in writing first, then build, test, document and hand over the assessment so your own team can rerun it.

How we scope

  • Written scope names the target system, the sensitive data and intellectual property categories to test, and the owners who approve them
  • We confirm which models, endpoints and PyRIT versions the assessment will run against before any test is sent
  • Scope states how memory, credentials and test datasets are stored and who may read the resulting records
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts

How we build

  • We configure the target and scorers in your environment, with credentials kept outside job logs and repositories
  • We set up the Leakage scenario with datasets you approve, including FirstLetter runs where your scope calls for them
  • We record the three PlagiarismScorer overlap metrics per run and agree with you which thresholds, if any, count as findings
  • We check that results are reproducible by running the same scenario twice against a fixed target configuration

How we hand over

  • Findings report lists each leakage result with the prompt pattern, target response excerpt and the metric values behind it
  • We deliver the scenario configuration and run instructions so your team can rerun the Leakage scenario with pyrit_scan
  • Documentation covers memory labels, retention settings and how to export conversations for review
  • Remediation guidance and a retest are included in scope where agreed

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, including re-running the scenario after model or PyRIT version changes
  • Retainers can cover updates to datasets and thresholds as your data and policies change
  • We help you confirm the PyRIT release and Python version to use with your current setup before each run
  • Support questions about results can be handled against the stored memory records from each run

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.