Red teaming Microsoft 365 Copilot with PyRIT before or after rollout
A security or compliance team that must assess Microsoft 365 Copilot before rollout, or after users already have it, can use PyRIT's PlaywrightCopilotTarget to send adversarial prompts through the same web interface people use. The target is built for testing Microsoft's Copilots and currently supports M365 Copilot and consumer Copilot. It can attach to an existing Edge session that someone has already signed in to, started with remote debugging enabled, so the tests run under a real user's identity and entitlements rather than a separate API key. That identity choice matters: the answers you get reflect what that account can reach in your tenant, so the test account should be one that represents the population you are assessing.
This is a browser-driven method, not an API. It shows you how Copilot responds to attacks in the interface your users see, including prompt injection attempts and attempts to pull content the signed-in user should not expose. It does not show you how Copilot behaves across every connector, plug-in, Graph permission or tenant policy, and it cannot confirm that a refusal reflects a control rather than model behavior that changes between sessions. Treat a clean run as a sample, not a guarantee. Confirm with your Microsoft account team which Copilot features and admin settings are in scope, and record the tenant configuration alongside each run so the results can be compared later.
Plan the test around two decisions before anyone runs a script. First, choose whether the session is a dedicated test account with a known set of documents and permissions, or a pilot user with production data, since the second raises data handling and consent questions. Second, decide how results will be reviewed, because each attempt needs its prompt, the response and the timestamp kept in a form a reviewer can follow. The PyRIT example must run as a standalone Python script, not in Jupyter, so plan the runner and log location in advance. Confirm your organization's approval for automated browser activity against a corporate Microsoft 365 tenant before the first run.
What you need before the first Copilot run
Before PyRIT can drive Copilot, four things must be in place: the framework installed in a suitable Python environment, a test account that is licensed and approved, a browser session that PyRIT can attach to, and sign-off from the people who own the tenant. Each card below covers one of these, and the checks that prevent a stalled first run.
Install PyRIT from PyPI
Install the pyrit package with pip into a dedicated virtual environment. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13. Pin the version you tested so a later release does not change target behavior between assessment rounds. Confirm the version against the release notes before you start, since the project has had breaking changes between releases.
A licensed test account
The target is a logged-in session, so the account used must hold a Microsoft 365 Copilot license or access to consumer Copilot, depending on which Copilot you are assessing. Use a dedicated test identity with only the data permissions the test needs, not a user with broad access to mail, files and sites. Check what that account can reach, because Copilot answers reflect the content the signed-in user can see. Confirm with the tenant owner whether test accounts are permitted and how they must be named and recorded.
Edge with remote debugging
The Playwright Copilot target can attach to an existing Microsoft Edge session that was started with remote debugging enabled. Start Edge with the debugging port set, sign in to Copilot with the test account, and confirm the page loads before PyRIT connects. Keep that browser profile separate from your daily browsing profile so that test sessions, cookies and history stay isolated and easy to remove after the assessment.
Playwright Copilot target docsA standalone script environment
The Playwright Copilot example will not run in Jupyter notebooks, so plan to run the assessment as a standalone Python script from a terminal or CI job. Keep credentials and settings in the locations PyRIT reads, ~/.pyrit/.env and ~/.pyrit/.pyrit_conf, rather than hard-coding them in the script. Store the script under version control so the exact prompts, targets and scorers used in each run can be reproduced later.
Network path and browser access
Confirm that the machine running the script can reach Copilot and that the browser session is not blocked by conditional access, device compliance or proxy rules that would interrupt sign-in or trigger prompts mid-run. Test the path from the same host and network you will use for the full run. Ask the network team whether the traffic is inspected or logged, because the assessment itself will generate a large volume of requests to a production service.
Tenant owner approval
Before the first run, agree the scope with the tenant owner in writing: which Copilot is in scope, which accounts and data may be queried, the test window, and who receives the results. Confirm the tenant's acceptable use and testing policy, because some organizations restrict automated access to Copilot or require notice to their cloud provider before testing. Treat these as items to confirm with your organization, not as assumptions the assessment can make on its own.
How to connect PyRIT to a logged-in Copilot session
This sequence connects PyRIT's Playwright Copilot target to a dedicated, logged-in Edge session so a single benign prompt can travel from a standalone script to Copilot and back into PyRIT memory. Each step ends with a check, so the team knows which layer failed if something breaks.
Prepare a dedicated test identity
The security or AI platform lead creates a separate test account for Microsoft 365 Copilot or consumer Copilot, distinct from any personal or executive account. Confirm with the Microsoft 365 administrator that the account holds the Copilot license, the permissions, and the data access you intend to test, and that it is covered by your acceptable use terms for automated testing. Done means you have written down the account name, the Copilot surface it will use, and the approval from the owner of that tenant or account.
Start Edge with remote debugging enabled
The tester launches Microsoft Edge with remote debugging turned on, using a dedicated browser profile so that the session does not mix with daily browsing. PyRIT's Playwright Copilot target attaches to this existing browser session rather than logging in itself, so the debugging port must be open on the machine running the script. Check that the browser opens normally and that the debugging endpoint responds on the local host before going further.
Log in and confirm the Copilot page loads
In the debugging browser, the tester signs in with the test identity, completes any multi-factor prompts, and opens the Copilot chat page for the surface being tested. Confirm that the chat input box is visible, that the test account shows as signed in, and that a new conversation starts without an error or consent banner blocking input. If a sign-in prompt, conditional access challenge, or policy notice appears on later runs, resolve it manually in this browser before running PyRIT again.
Configure PyRIT credentials and settings
The tester creates the PyRIT user directory and places any required credentials in ~/.pyrit/.env, and sets team-wide defaults such as memory location and logging in ~/.pyrit/.pyrit_conf. Keep the file out of source control and restrict its permissions to the tester's account. Confirm the configuration loads by running a short Python import and printing the memory location, so the team can see the settings PyRIT picked up before any Copilot traffic is sent.
Write a standalone script for the target
The tester writes a Python script that instantiates PlaywrightCopilotTarget, pointed at the Copilot surface under test and at the attached Edge session, then wraps it in a basic prompt conversation. The example in the PyRIT documentation does not run in Jupyter, so the code must live in a standalone .py file and be run from the terminal. Check that the script starts, connects to the browser, and exits without raising an attachment error.
Send a benign prompt to Copilot
Using a harmless prompt agreed with the test owner, such as a request for a general summary or a formatting task, the tester runs the script once. The purpose is to exercise the full path from PyRIT, through the browser, to Copilot and back, without introducing any test payload. Confirm that the visible Copilot window shows the prompt being typed and submitted, and that a reply appears in the browser.
Verify the response is captured in memory
The tester queries PyRIT memory for the conversation the script just created and checks that the prompt and the Copilot reply are both stored with the expected roles and a recent timestamp. If the reply is visible in the browser but missing from memory, the response parser or the attachment logic needs review before any red teaming runs. Record the conversation identifier so that later attacks and the evidence trail can be traced back to this connection test.
How the browser session carries the test
The test runs in two halves that sit on different machines. PyRIT's objective model, adversarial model and scorers run on the analyst side, where they generate attack prompts and judge replies. The PlaywrightCopilotTarget is the only part that touches Copilot. It attaches to a Microsoft Edge window that was started with remote debugging and is already signed in, types each prompt into the Copilot chat box, waits for the reply, and hands the text back to PyRIT. Every turn, prompt and response is written to PyRIT memory, which uses SQLite or Azure SQL, so the record of the run lives with the assessment team rather than in Copilot.
Because the target reuses an existing logged-in session, every prompt is sent as the test user. Copilot will answer with whatever that account can reach: mailbox items, files, Teams chats and SharePoint content that the user has permission to see, subject to the tenant's sensitivity labels, conditional access and Copilot settings. This is what the assessment must measure. The test is only meaningful if the account represents a real persona, such as a standard employee or a finance user, and the assessor should confirm with the client which account, group memberships and licenses apply before the first run. Plan a separate session for each persona so that findings can be traced to a specific permission set.
Confirm three things before the run. First, which Edge profile and account the remote debugging session uses, and that it is not an administrator account unless admin-level exposure is in scope. Second, that the test user's data access has been recorded so results can be compared with what the user should see. Third, that the analyst machine and the memory store are controlled by the client, since they will hold copies of sensitive replies. The PyRIT documentation for the Playwright Copilot target lists the supported Copilot variants and the setup steps the browser session needs.
How the Copilot test flow fits together
The flow starts on the analyst workstation, where a standalone Python script runs PyRIT and attaches to an Edge session that was started with remote debugging and is already signed in as the test identity. PyRIT's Playwright Copilot target drives that browser session against the Copilot web service inside the tenant boundary, so every prompt and reply travels through the logged-in browser. Responses then pass to the scorer and into PyRIT memory, which is where results are reviewed. Check that the test identity has only the access the assessment needs and that the memory store is kept under the same controls as the assessment data.
Components and hand-offs in a Copilot red teaming run, with the tenant boundary marked.
Which identities, data and settings map between PyRIT and Copilot
This table compares each identity, browser artifact, memory record and local setting on the PyRIT side with what it corresponds to on the Copilot and tenant side. Read it before the first run, since several mappings depend on tenant settings that DeployOpen cannot confirm from outside your environment. Items marked as needing confirmation should be checked with your Microsoft 365 administrator before any test account touches production data.
| Item | PyRIT side | Copilot or tenant side | Confirm in tenant |
|---|---|---|---|
| Test user account | The human identity whose logged-in browser session PyRIT drives | A licensed Microsoft 365 user with a Copilot license assigned, following the same access path as a real employee | Yes |
| License and permissions | Not stored by PyRIT; it only sees what the session can reach | Copilot access depends on the license, Microsoft Graph permissions and content each user can read in the tenant | Yes |
| Browser profile | Edge started with remote debugging, which PyRIT attaches to through the Playwright Copilot target | The signed-in session, cookies and any conditional access state tied to that browser | Yes |
| Session lifetime | Lasts only while the attached browser stays open and logged in | Subject to tenant sign-in and token policies, so a session may expire mid-run | Yes |
| Conversation memory | SQLite or Azure SQL records each prompt, response and score for later review | Copilot keeps its own chat history under the test account, separate from PyRIT memory | No |
| Findings record | Memory entries are linked to attack runs, labels and scores you export | Findings should cite the tenant, account and date so an assessor can match them to Copilot activity | Not applicable |
| Local settings file | Credentials in ~/.pyrit/.env and settings in ~/.pyrit/.pyrit_conf on the analyst machine | No direct counterpart; keep these values out of shared repositories and tenant documents | Not applicable |
| Audit trail | Local run history and exported results held by the analyst team | Tenant audit logs record sign-ins and Copilot use under the test account if your audit policy captures them | Yes |
Securing a test session against real tenant data
A Copilot session runs under a real identity and can reach real mailboxes, files and chats, so the controls around it matter as much as the attack prompts. The cards below cover identity, approval, credentials, workstations, stored results and teardown, which together decide whether the test itself becomes a data exposure.
Dedicated test identity
Create a separate test account for the Copilot session rather than reusing an administrator or a working employee account. Give it only the licenses, group memberships and SharePoint or mailbox access the assessment needs, and seed any sensitive-looking content in a controlled test site. Ask the tenant owner to confirm which Copilot features the account can reach, since Copilot answers from whatever the signed-in user can already see.
Written approval from the tenant owner
Get written approval from the person who owns the Microsoft 365 tenant before any session starts. The approval should name the Copilot surfaces in scope, the test window, the account used, the analyst accounts allowed to run it, and who is informed if the session triggers alerts or touches live content. Without this, a finding can become a security incident with no agreed owner.
No plain-text production credentials
The Playwright approach attaches to a logged-in Edge session, so the credential that matters is the browser profile and its cookies, not a password in a script. Keep the profile on an encrypted disk, avoid storing passwords in ~/.pyrit/.env, and require multi-factor authentication on the test account. Confirm that no tenant secrets reach version control or CI logs.
Restricted analyst workstations
Run the session from a managed workstation with disk encryption, endpoint protection and no access to production admin consoles. Browser sessions started with remote debugging open a local control port, so bind it to localhost, close it when the run ends, and block other local processes from reaching it. Ask the analyst team to confirm that the workstation is only used for this assessment during the test window.
Memory storage and response handling
PyRIT stores conversations and scores in SQLite or Azure SQL, and Copilot responses may quote confidential documents. Decide where the memory database lives, encrypt it at rest, restrict read access to the assessment team, and set a retention rule for raw transcripts. Redact or summarize real tenant content in reports so findings do not copy sensitive text into shared tickets.
Session removal at the end
When testing ends, close the remote-debugging browser, sign the test account out, revoke active sessions, and remove the account or reset its access if it was created for the assessment. Delete or archive the browser profile according to the agreed retention rule, and confirm in writing with the tenant owner that teardown is complete. Ask the vendor or partner to document each step so the closure can be reviewed later.
Testing M365 Copilot versus consumer Copilot
Microsoft 365 Copilot is the target that matters for a workplace rollout, because its answers depend on the signed-in user's tenant, the files, mail, chats and sites that user can reach, and the admin settings applied to the tenant. A run through a logged-in work account can show whether Copilot discloses content a user should not see, whether it follows sensitivity labels and oversharing paths, and how it handles prompts that try to pull data from connected sources. Those results are only as representative as the test account's permissions, so the run should use accounts that match real roles, not an administrator account with broad access.
- Permission scope: Results reflect the test account's group memberships, site access and sharing links, so record the account and its access before the run.
- Tenant configuration: Connectors, web search settings and label policies in your tenant change what Copilot can return, so note the configuration in effect.
- Data placed for testing: Seed controlled documents with known markers so leakage can be measured rather than guessed.
- Licensing and enablement: Confirm the test account has an assigned Copilot license and that the features under test are enabled for it.
- Admin access to logs: Confirm with your Microsoft 365 admin team what audit and Copilot activity records exist so each finding can be traced.
Confirm with your Microsoft 365 administrators which test accounts and sample data are approved before the run starts.
Consumer Copilot runs against a personal Microsoft account with no tenant context, so it shows how the public product behaves for an individual user, not how your organization's data is exposed. A consumer run can reveal model behavior, jailbreak susceptibility and content policy gaps that also matter if staff use personal accounts on corporate devices. It cannot show whether your SharePoint oversharing, sensitivity labels or Purview controls protect information, because none of those apply to a personal session.
- No tenant data: The session has no access to your files, mail or chats, so data leakage findings cannot be attributed to your deployment.
- Shadow use signal: Results indicate what happens when staff reach Copilot outside managed accounts, which relates to acceptable-use and browser controls.
- Account ownership: The test uses a personal account, so decide who owns it, how it is secured and how credentials are stored outside your corporate identity system.
- Terms and policy: Confirm that testing a consumer service complies with its terms and your legal and HR policies before the run.
- Version drift: Consumer Copilot changes without notice, so record the date and any visible product version with each run.
Confirm with legal and security leadership whether consumer testing is in scope and whether findings from it may be cited in rollout decisions.
The two runs answer different questions, and a clean result on one does not transfer to the other. A passing M365 Copilot run supports a claim about one configuration, for the accounts and data tested, on the date tested. A passing consumer run says little about tenant exposure. Findings should be labeled with the target and its configuration so the rollout team does not treat a consumer result as evidence about corporate data, or the reverse.
- Rollout evidence: M365 results can inform go or no-go decisions for specific groups, once test coverage is documented.
- Limits of coverage: A small set of test accounts and documents cannot represent every role, site and label combination.
- Behavior evidence: Consumer results can support model-level findings that feed into prompt hardening and policy discussions.
- Labeling discipline: Tag each finding with target, account type, tenant configuration and date.
- Repeat runs: Both targets change over time, so plan retests after configuration or product changes.
Before reporting, ask the reviewer which decisions the results will support, and state explicitly what the run did not test.
Choose the target from the decision you need to support. If the question is whether Copilot exposes your organization's information, the M365 target with a representative tenant and test accounts is the one to use. If the question is how the model behaves under adversarial prompts for any user, a consumer run can add evidence, but it should be presented separately. Many organizations need both, and the scope should say so in writing before work starts.
- Named decision: Write down the rollout or audit question the test answers.
- Tenant access: Confirm that Microsoft 365 administrators approve a test tenant or dedicated accounts.
- Browser session: Confirm that the Edge session can be started with remote debugging on the test machine and that policy allows it.
- Data handling: Confirm where transcripts and PyRIT memory are stored, and who can read them.
- Account approval: Confirm that any personal account use has legal and HR sign-off.
Confirm these points with your Microsoft 365, identity and legal teams before the run, and record their answers as part of the test scope.
Questions buyers ask before testing Copilot with PyRIT
What drives the cost of red teaming Copilot with PyRIT?
The cost follows the amount of expert time, which splits into test design, access setup, analyst time, and scoring and reporting. Test design covers which harms and prompts to use, how many Copilot surfaces are in scope, and how results will be judged. Access approvals and tenant setup are a one-time effort, while repeat runs after a Copilot change, a new connector, or a policy update recur. Scoring and reporting grow with the number of conversations reviewed and the audience for the findings. Ask any provider for a quote built from a written scope that lists the Copilot surfaces, the number of test accounts, the harm categories, and whether retesting is included.
How long does a first PyRIT run against Copilot take?
Duration depends on scope rather than on PyRIT itself, which runs as a standalone Python script. The main variables are how quickly approvals and test accounts are granted, how many surfaces and harm categories are covered, and how much time analysts need to review transcripts and score borderline responses. A narrow first pass on one Copilot experience with a small prompt set is much shorter than a multi-surface assessment with several test identities. Ask the provider to break the timeline into setup, execution, review and reporting, and to state which of those steps depend on your approvals.
What does our organization need to provide before the test starts?
The organization needs to provide several items before any prompt is sent:
Can our own team run PyRIT against Copilot without a partner?
Yes, a team with Python skills and a Microsoft 365 administrator can install PyRIT and run the Playwright Copilot target, since PyRIT is open source under the MIT license. The harder work is the surrounding discipline: choosing objectives, writing a defensible scoring method, handling sensitive transcripts, and turning raw memory records into findings that a risk owner can act on. Teams that have not done AI red teaming before often underestimate review time. A partner is most useful when you need an independent view, a repeatable process for each Copilot change, or evidence in a format your auditors or customers will accept.
What are the limits of testing Copilot through a logged-in browser session?
A browser-driven target tests what a signed-in user sees and can do, so the assessment must state that its coverage follows the browser path. PlaywrightCopilotTarget is built for Microsoft's Copilots and currently supports M365 Copilot and consumer Copilot, and it can attach to an existing logged-in Edge session started with remote debugging. Results can vary with interface changes, session state, tenant policy, and which grounding data the test account can reach. The assessment should name the Copilot surfaces tested, the account and permission level used, the browser and session method, and the surfaces it did not cover, such as admin controls or API-based access.
Why does the Playwright Copilot example fail in Jupyter notebooks?
The Playwright Copilot example will not run in Jupyter and must be run as a standalone Python script, according to the PyRIT documentation for the Playwright Copilot target. Engineers should plan the test harness around a script that starts or attaches to the browser, runs the attack, and writes results to memory. Notebooks remain useful for reviewing results afterward, but the live session should not depend on a notebook kernel. Confirm the current setup steps in the PyRIT Playwright Copilot Target documentation before building the harness.
How should results from a Copilot test be stored and reviewed?
PyRIT stores conversations and results in SQLite or Azure SQL, so the storage choice should match your data rules and retention policy before testing starts. Decide who can read transcripts, because Copilot prompts can surface internal content from the test account's grounding data. Scoring should combine automated scorers with human review of borderline cases, and the scoring method should be recorded so a second reviewer can reproduce it. Ask the provider how transcripts will be redacted, retained and deleted at the end of the engagement.
How DeployOpen works on this
DeployOpen runs PyRIT-based red teaming of Microsoft 365 Copilot and consumer Copilot as a fixed-scope engagement, with the scope, test accounts and evidence agreed in writing before any testing starts. The work is delivered in your environment and tenant conditions, with findings, fixes and a retest documented for your security and compliance teams.
How we scope
- Written scope names which Copilot surfaces, tenants and licensed user groups are in the test.
- Test accounts, their permissions and the data they can reach are agreed before any session is opened.
- Approval for browser sessions, prompt categories and acceptable test content is recorded in the scope document.
How we build
- The PyRIT Playwright Copilot target is set up against an existing logged-in Edge session started with remote debugging.
- Attack objectives and scoring are configured for the harms and data exposure risks defined in the scope.
- Test runs are executed as standalone Python scripts, with conversations stored in PyRIT memory for review.
How we hand over
- Findings report lists each reproduced issue, the conversation evidence behind it and the affected permissions or data.
- Remediation guidance covers Copilot admin settings, data access controls, sensitivity labels and user guidance where relevant.
- A retest of the fixed items is run and documented so your team can show what changed and what remains open.
How we support
- Engagements are fixed-scope, and the written scope sets the deliverables and timelines before work begins.
- Ongoing support, periodic re-testing after Copilot or PyRIT updates is available as a retainer.
- Ask for a quote built from the written scope, covering who tests, which accounts are used and what retesting is included.

