Why teams move PyRIT secrets into Azure Key Vault
When a team shares PyRIT across several workstations, CI runners or a CoPyRIT instance, the hardest part is getting endpoint keys to each machine without leaving plaintext copies behind. PyRIT can pull those keys from Azure Key Vault through a bootstrap entry in ~/.pyrit/.pyrit_conf, where the env_akv_ref setting points to a Key Vault secret whose value uses dotenv syntax. The keys then live in one controlled store, and each machine only needs permission to read the secret.
PyRIT reads credentials from ~/.pyrit/.env and settings from ~/.pyrit/.pyrit_conf. In a plain local setup, the .env file holds the target keys directly, which is simple for one engineer on one laptop but means every copy of that file is a secret that must be rotated, revoked and tracked by hand. The Key Vault bootstrap moves that file's contents into a vault, so rotating a key becomes one change in the vault rather than an edit on every machine.
This setup fits better when several people or pipelines run the same targets, when a CoPyRIT deployment needs to reach model endpoints, or when your security team requires that keys have an audit trail and a single revocation point. It is less suited to a solo engineer testing a disconnected model, where ~/.pyrit/.env.local is the documented fallback for quick local patches when Azure is unavailable. Before you commit, confirm with your Azure administrator which identity each machine will use to read the vault, who can change the secret, and how access is removed when someone leaves. Check the current configuration keys against the PyRIT documentation on the configuration file.
Which environment needs the Key Vault bootstrap
On a shared workstation, several operators may use the same operating system account or home directory, so a plaintext ~/.pyrit/.env is readable by everyone who can reach that account. The bootstrap lives in each user's ~/.pyrit/.pyrit_conf, where env_akv_ref points to a Key Vault secret whose value uses dotenv syntax. The configuration file reference lists the documented keys.
- Where the bootstrap lives: each operator's
~/.pyrit/.pyrit_conf, withenv_akv_refnaming the secret. - Who holds access: each named operator's Azure identity, granted read access to that secret. Confirm whether your vault uses access policies or role-based access control.
- What changes for the operator: the operator must be signed in to Azure on that workstation before PyRIT can resolve keys.
- Local patches:
~/.pyrit/.env.localis meant for quick fixes when Azure is unavailable, so remove long-lived keys from it once the vault is in use. - Shared accounts: a single shared operating system account makes vault audit records unable to separate operators. Confirm what your vault logs and who reviews it.
Check which accounts share a home directory and whether each person has a distinct Azure identity.
On CI runners, the bootstrap is created during the job from a template kept in the repository. The template holds the secret name and the vault reference, never the key value, so the repository stays free of credentials. The runner reads the secret through a non-interactive identity, so the pipeline must authenticate to Azure without a person signing in. Operators change less day to day, but failures now show up as job errors.
- Where the bootstrap lives: a
.pyrit_confwritten at job start from a repository template that containsenv_akv_refand no key values. - Who holds access: the runner's managed or workload identity, with read access limited to the PyRIT secret in that vault.
- Runner state: ephemeral runners discard their home directory after each job, so the bootstrap must be recreated every run. Persistent self-hosted runners keep files between jobs, so add a cleanup step.
- Failure handling: a missing permission or wrong secret name should stop the job with a clear error that does not print the secret value.
- Pipeline variables: avoid passing endpoint keys as pipeline variables when the vault can supply them. Confirm whether your CI platform supports federated identity to Azure.
Confirm whether your runners are ephemeral and which identity each pipeline uses to reach the vault.
CoPyRIT is PyRIT's web GUI for human-led red teaming and team collaboration. In a shared deployment, the service process reads configuration, so the bootstrap belongs with the service's own settings and identity rather than with each tester's account. Each team instance should reference its own secret so that keys for one team do not reach another team's instance. Testers use the interface and do not need to handle keys.
- Where the bootstrap lives: the configuration supplied to the CoPyRIT host or container, with
env_akv_refpointing to the secret for that instance. - Who holds access: the deployment's service identity, plus a small set of named administrators who maintain the secret. Testers should not receive direct vault access.
- Separate instances: a dedicated secret per team instance keeps each team's endpoint keys scoped to that team.
- Operator experience: testers work through the web interface and never see endpoint keys, so their only requirement is their own sign-in.
- Rotation: if the service reads configuration only at startup, rotating a key means restarting or reloading the service. Confirm this behavior for the version you deploy.
Confirm where your service reads its configuration and whether it picks up secret changes without a restart.
Secret storage options compared for PyRIT
This table compares the three ways a PyRIT setup can hold endpoint keys: a plaintext ~/.pyrit/.env file, a Key Vault bootstrap referenced from .pyrit_conf, and a ~/.pyrit/.env.local patch. Read each row to see what is stored, who can read it, and how the option fits shared workstations, CI runners and CoPyRIT. The main takeaway is that the Key Vault bootstrap is the option to standardize on, and the local patch needs an owner and a removal step.
| Option | What it stores and who can read it | Fit for CI runners and CoPyRIT |
|---|---|---|
| Plaintext ~/.pyrit/.env | Endpoint keys written directly in a file. Anyone with read access to the user profile or a copied backup can read them. | Workable for one developer. CI runners need the file placed by a pipeline step, and CoPyRIT deployments do not share it cleanly across users. |
| Key Vault bootstrap via env_akv_ref | Only a reference to a secret in ~/.pyrit/.pyrit_conf. The secret value sits in Azure Key Vault, so readers depend on vault access policies and roles. | Best fit for shared workstations and CI. Confirm the identity each runner uses can read the secret before the first run. |
| ~/.pyrit/.env.local patch | A quick local override for when Azure is unavailable. Keys sit in plaintext on the same machine and are easy to leave behind. | Not suited to CI or CoPyRIT. Use only as a temporary fallback and record who created it. |
| Who can audit access | Key Vault records access through Azure logs when diagnostics are enabled. Plaintext files leave no access trail. | Confirm diagnostic settings on the vault with your platform team before relying on them for evidence. |
| Risk of forgotten local patches | Low for the vault reference itself. A patch left in .env.local can override the vault value and keep a stale key in use. | Add a removal step to the runbook, and check for .env.local on every shared machine during review. |
| Rotation effort | Rotating a key means editing each plaintext file on each machine. | Rotating a key means updating the vault secret once, with the reference unchanged. |
How to configure the Key Vault bootstrap in PyRIT
This sequence moves PyRIT's endpoint keys out of plaintext files and into an Azure Key Vault secret that PyRIT reads at startup through a single bootstrap reference. When it is finished, PyRIT loads its endpoint keys from Key Vault and the local fallback file is no longer needed.
Create the dotenv-formatted Key Vault secret
Someone with permission to manage secrets in the vault creates a secret whose value holds the endpoint settings in dotenv syntax, one KEY=value pair per line, with the same variable names PyRIT already expects in ~/.pyrit/.env. Confirm the exact secret creation steps, naming rules and any value size limits in Azure's Key Vault documentation or with your Azure administrator before you rely on them. Check: open the secret in the portal or your approved tool and confirm the value reads back as the expected key lines, with no stray quotes or extra spaces.
Grant the PyRIT identity read access
Assign the identity that will run PyRIT, such as a user, a managed identity on a CI runner or a service identity for a CoPyRIT host, permission to read that one secret. Use the least privileged read role your vault's access model supports, and confirm the role names and assignment method with your Azure administrator, since they vary by vault configuration. Check: sign in as that identity and confirm it can read the secret but cannot list or change other secrets in the vault.
Point the configuration file at the secret
Edit ~/.pyrit/.pyrit_conf on the machine or runner that will run PyRIT and set env_akv_ref to the name of the secret created in the first step. Keep this file free of endpoint keys, since the reference is the only thing it should hold for Key Vault. Check: run a PyRIT command that reads configuration and confirm it does not report a missing or unreadable reference before any endpoint call is made.
Confirm PyRIT loads the endpoint keys
Start a PyRIT session or run a simple target check that calls an endpoint you already have access to. Confirm the call succeeds and that the key it used came from the vault rather than from ~/.pyrit/.env. If the call fails, check the identity's access, the secret name in env_akv_ref and that the value's dotenv lines use the variable names PyRIT expects. Check: the target responds, and the plaintext key file no longer holds the same key.
Remove the plaintext key from the local file
Once Key Vault loading works, delete the endpoint keys from ~/.pyrit/.env so the only copy is in the vault. Keep the file for non-secret settings if your setup needs it. Check: search the home directory's PyRIT folder for the key value and confirm it no longer appears in any plaintext file, and that a repeat PyRIT run still succeeds.
Confirm .env.local is removed after Azure works
The Configuration File documentation describes ~/.pyrit/.env.local as a way to make quick local patches when Azure is unavailable. Once the vault bootstrap runs reliably, delete ~/.pyrit/.env.local so it does not hold a second copy of keys or override vault values during later runs. Check: confirm the file is gone, then run PyRIT again and verify the endpoint still responds using only the Key Vault reference.
How PyRIT resolves keys from Key Vault at startup
PyRIT starts by reading ~/.pyrit/.pyrit_conf on the local host. The env_akv_ref key points to a secret in Azure Key Vault, and the secret's value uses dotenv syntax, so PyRIT parses it and loads the endpoint keys into the run. If Azure is unavailable, ~/.pyrit/.env.local supplies quick local patches. Check that the secret name resolves and that the parsed keys match what each target expects before a scan starts.
Startup path from the config file through Key Vault to the run, with the local fallback.
Security considerations for Key Vault-backed PyRIT
Moving endpoint keys into Key Vault shifts the risk from files on disk to the identities, configuration and vault activity around them. The cards below cover the controls your team sets and the checks to run before a shared or CI deployment relies on the bootstrap.
Who can read the secret
The bootstrap only works if the identity running PyRIT can read the secret that env_akv_ref points to, so that read permission is the real access boundary. Check which users, groups, managed identities and CI service principals hold read access on the vault and on the specific secret. Remove broad contributor or owner roles from anyone who only needs to run scans. Use one identity per runner or team, so a revoked credential does not silently break every workstation.
Keep .pyrit_conf out of source control
The .pyrit_conf file names the vault reference and other settings that show how your environment is wired. Keep it in the user profile at ~/.pyrit/ and out of repositories, shared drives and container images. If a team wants a shared template, commit a copy with placeholder values and a note on where each real value comes from. Review repositories for accidental commits of .env files before enabling the pipeline.
Remove .env.local after outages
The .env.local file exists for quick local patches when Azure is unavailable, so it often holds keys that were copied out of the vault during an incident. Once Key Vault access returns, delete the file or replace its values with the vault secret, and confirm the endpoint keys on the workstation match the vault. Treat any plaintext key left behind as exposed and rotate it. Make this step part of the incident close-out checklist.
Rotate endpoint keys in one place
With the keys stored once in the vault, rotation means updating the secret and then the consumers pick up the new value at their next load. Agree the rotation schedule with the owners of each target endpoint, and record who performs the change. Test the rotation on a non-production endpoint first to confirm that running PyRIT sessions and CI jobs read the new value. Retire the old key at the endpoint only after all runners have switched over.
Vault logging and access review
Enable diagnostic logging on the vault so secret reads and writes are recorded, and send those logs to the same store your security team uses for other sensitive systems. Review which identities read the PyRIT secrets on a regular schedule and compare the list with current team membership. Look for reads from unexpected locations or service principals that no longer have an owner. Ask your vault administrator to confirm the retention period for these logs before you rely on them as evidence.
CoPyRIT instances on a shared vault
When several CoPyRIT instances or team deployments read from one vault, a single over-permissioned identity exposes every team's endpoint keys. Give each instance its own managed identity with read access only to the secrets it needs, and separate secrets by team or environment. Confirm that a compromised instance can be cut off by disabling its identity without touching the others. Document the mapping so an administrator can see which identity reads which secret.
Questions teams ask before storing PyRIT secrets in Key Vault
How much effort does it take to move PyRIT secrets into Azure Key Vault?
The effort is mostly configuration and access work rather than PyRIT code changes. A team needs one Key Vault secret whose value uses dotenv syntax, a ~/.pyrit/.pyrit_conf entry that points to that secret through env_akv_ref, and an identity that can read the secret. The main drivers are how many endpoints and keys the team uses, whether Azure access and networking already exist, and whether the vault is new. Each extra target or model deployment adds entries to the secret and a test run to confirm it loads. Ask any partner for a written list of the vault, identity and runner steps before agreeing a scope.
Can our own team set this up without outside help?
Yes, if the team already runs Azure resources and understands Key Vault access policies or role assignments. The work is small in PyRIT terms, but it touches identity, networking and secret handling, which are where mistakes happen. A team without that background usually needs an Azure engineer to review the vault configuration and the identity model. An outside partner is most useful when the setup has to be reviewed by security or compliance teams, or when several workstations, CI runners and CoPyRIT instances must share one pattern. Whichever route you choose, write down who owns each step.
What do we need to provide before the work starts?
Three things need to be settled first. You need Azure access to a subscription or resource group where the vault will live, with permission to create or read secrets. You need a named owner for the vault who approves who can read each secret. You also need a runner identity for each place PyRIT runs, such as a managed identity for a CI runner or a user identity for a shared workstation. Confirm with your Azure administrators how these identities are created and which roles they receive, because those details depend on your tenant. Also confirm whether private networking or firewall rules apply to the vault.
How do we rotate keys, and what happens if Key Vault is unavailable?
Rotation happens in the vault. When an endpoint key changes, update the secret value and the next PyRIT run loads the new value, so no local files need editing. Keep a record of which secret feeds which target so rotations do not break a scheduled scan. For fallback, ~/.pyrit/.env.local holds quick local patches for when Azure cannot be reached. Treat it as a temporary measure: keep it out of source control, remove entries once the vault is available again, and avoid copying long-lived production keys into it. Ask your partner how the team will test the fallback path.
Does the setup change when we deploy CoPyRIT?
The principle stays the same, but the identity moves. CoPyRIT is the web GUI for human-led red teaming and team collaboration, and it runs as a service rather than on one person's workstation. Its runtime identity, not an individual's login, needs read access to the secrets it uses. Each team instance should have its own vault or clearly separated secrets, so one team's keys do not reach another team. Check the CoPyRIT deployment documentation for how its settings are supplied in your chosen hosting model before you map the secret names.
What are the main security risks if we skip Key Vault and keep plaintext files?
Plaintext files in a home directory are copied easily. They end up in backups, shell history, screenshots, cloned repositories and shared workstation profiles. Anyone who can read the file gets the endpoint key, and revoking it means finding every copy. A vault centralizes storage, gives access an audit trail through Azure controls and lets you grant read access per identity. It does not remove the need for least privilege, so the team still has to review which identities can read which secrets and remove access when people or runners change.
Which parts of the setup should our compliance team review?
Ask compliance and security reviewers to check four areas: who owns the vault, which identities can read each secret, how access is removed when people leave, and what fallback copies exist on disk. DeployOpen prepares configuration, access records and runbooks that these reviewers can inspect, but it does not issue audit reports or certifications. Independent auditors and certification bodies make those determinations. Confirm with your assessor which evidence they expect before the setup is finalized.
Limits to confirm in your environment
The Key Vault bootstrap is simple to describe but depends on details that vary by release and by how your team runs PyRIT. The cards below list the points to confirm with a test in your own environment before you move shared or CI secrets into Key Vault.
Key Vault authentication method
Confirm how PyRIT authenticates to Key Vault in the version you run: which identity source it uses, whether it reads a default credential chain, and which roles the identity needs to read secrets. Test with a non-production vault and a read-only identity first. Record the exact method in your runbook, because the answer determines how you grant access to workstations, CI runners and CoPyRIT hosts.
Configuration File docsDotenv parsing rules
The secret value is expected to use dotenv syntax, but quoting, escaping, comments, multiline values and duplicate keys can behave differently from a plain .env file. Confirm how PyRIT parses a secret that contains special characters, such as endpoint keys with equals signs or trailing spaces. A malformed value can fail silently, so check each key after loading.
Behavior when Azure is unreachable
Find out whether PyRIT stops, falls back to local values or continues with missing keys when Key Vault cannot be reached. Confirm whether ~/.pyrit/.env.local takes effect in that case and how it interacts with values pulled from the vault. Document the fallback so an engineer on a plane or in an air-gapped segment does not copy keys into plaintext files by accident.
Multiple vaults per bootstrap
Confirm whether env_akv_ref accepts references to more than one vault or secret, and how PyRIT resolves a conflict when two sources define the same variable. If your model endpoints, scorer keys and memory credentials live in separate vaults, this determines whether you need one bootstrap per environment or a shared layout. Ask the project for the supported pattern before you design vault boundaries.
Pinned runner version
Pin the PyRIT version on every workstation and CI runner, and confirm that the Key Vault bootstrap behaves the same on each. The documented release for this topic is v1.1.0, released on 4 September 2026. Check the release notes for changes to configuration loading before you upgrade, and test the bootstrap again after each pin change.
PyRIT releasesPython version support
The PyPI package supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. Confirm that the interpreter on every runner and workstation falls in that range, and that your Key Vault client libraries install cleanly on it. Mixed interpreter versions across a team often cause the bootstrap to work on one machine and fail on another.
PyRIT on PyPIWhere Key Vault secret setups usually go wrong
The most common failure is a secret value that is not valid dotenv syntax. PyRIT reads the secret named by env_akv_ref as if it were the contents of a .env file, so an unquoted value with spaces, an unescaped multi-line key, or a stray # can load partially or not at all. Before a scan, copy the secret into a scratch file outside ~/.pyrit, parse it with a dotenv parser, and confirm that every expected key is present with a non-empty value. The second failure is a stale .env.local. Its entries exist for quick local patches when Azure is unavailable, so an old endpoint key left there can mask a rotated vault value. Check the loading order in the PyRIT configuration file reference, compare the keys in .env.local with the vault secret, and delete any entry you do not intend to keep.
Committed bootstrap files are the second risk. A .env file in a repository exposes endpoint keys directly, and a committed .pyrit_conf exposes the vault address and secret name that point to them. Scan the full git history with a secret scanner, not only the working tree, and confirm that .env, .env.local and any exported copy of the bootstrap appear in .gitignore. On shared workstations, confirm that the ~/.pyrit directory is readable only by the account that runs scans. Ask your security team which secret scanning tool your CI pipeline uses and whether it runs on every push, since that control is what catches a bootstrap file after it has been committed.
Runners that cannot reach the vault fail in a way that looks like a PyRIT problem. The job needs a working identity that can read the secret, a network path to the vault, and name resolution for the vault host. Before the scan, run a read-only test from the same runner and account that will execute PyRIT. Confirm that the vault firewall or private endpoint allows the runner's network, that the identity has read access to the specific secret, and that no leftover key in the runner environment stands in for the vault value. Then confirm, in your PyRIT version, whether a failed read stops the run or falls back to .env.local. Record the test result so a failed scan can be traced to access problems before anyone looks at the target.
How DeployOpen scopes and delivers PyRIT secret storage
DeployOpen plans the Key Vault bootstrap for PyRIT around your own workstations, CI runners and CoPyRIT hosts, then builds and documents it inside your Azure tenancy. The work is fixed-scope, so the secret inventory, access model and handover are agreed in writing before any configuration changes.
How we scope
- We inventory which PyRIT targets, scorers and memory connections need endpoint keys today.
- We map which secrets belong in Key Vault and which teams or runners should read each one.
- The written scope names the vault, the bootstrap secret, the environments covered and the acceptance checks.
How we build
- We configure the bootstrap reference in the PyRIT configuration file and test it on a clean machine.
- We structure the vault secret so its dotenv-formatted value loads the endpoint settings PyRIT expects.
- We remove plaintext key files from shared locations and confirm the fallback local patch file is used only for emergencies.
How we hand over
- We deliver a runbook covering setup, rotation steps, access grants and recovery when Azure is unavailable.
- We document the access policy and the list of identities that can read each secret, for your review.
- We walk your platform and security engineers through the configuration and confirm they can rotate a key unaided.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, so vault changes follow PyRIT upgrades.
- We can retest the bootstrap after PyRIT or Azure changes and after new team members or runners are added.
- Ask for the support scope, response arrangements and change process in the written quote before you commit.

