Why PDF and document converters matter for PyRIT injection testing
If your assistant reads uploaded PDFs or answers questions from a retrieval index built on documents, attacks that arrive as chat messages will not test that path. PyRIT's PDFConverter turns attack text into document form so you can send it through the same upload or ingestion route your users and data pipelines use. The converter, as described in the PyRIT documentation, generates PDFs from YAML templates or from plain text, and it can also inject text into an existing PDF. That second capability matters most when a realistic file is the carrier, because the text sits inside a document your system already accepts.
Teams usually need this converter when the risk lives in how content is extracted, chunked, embedded and passed to a model rather than in the prompt box. Typical cases include a document summarizer, a claims or contract review tool, or a knowledge assistant indexed from shared drives. In those systems, instructions hidden in a page footer, a metadata field or a low-contrast block can reach the model after text extraction, even though no user typed them. Before you build the test, confirm with your own pipeline which extractor runs, whether hidden or off-page text survives it, and which file types the upload service accepts, because the result depends on that chain rather than on the attack string alone.
The documentation for this converter covers PDFs. Word document production is part of the same test idea, since a .docx upload follows the same route into extraction and retrieval, but you should confirm current Word support against the PyRIT documentation for your installed version before you rely on it in a test plan. Whichever formats you use, record the exact file, its generation settings and the target response so the finding can be reproduced and retested after a fix.
How a PyRIT document payload reaches the model
The flow starts with a red team objective that PyRIT's PDFConverter turns into a PDF, either from a YAML template or plain text, or by injecting text into an existing PDF. The document then enters the application's upload or ingestion pipeline, where the parser, chunker and vector store decide whether the hidden instruction survives into retrieval. The dashed boundary separates user-supplied content from the privileged context the model sees. Check each hand-off, because a payload that the parser drops or the chunker splits never reaches the target.
Document payload path from PyRIT converter to target model, with the untrusted upload boundary marked.
Choosing between template PDFs, plain-text PDFs and injection into existing files
PyRIT's PDFConverter covers three ways to put attack text into a document: generating a PDF from a YAML template, generating one from plain text, and injecting text into an existing PDF. A Word document option sits alongside them for upload paths that accept .docx files. Each path tests a different part of the ingestion pipeline, so the choice depends on what your upload and RAG parser actually sees.
Template-generated PDFs from YAML
The PDFConverter can build a PDF from a YAML template, so the layout, headers, and surrounding content are fixed while the attack text is placed into the template. This suits tests where the document structure matters, such as invoices, forms, or reports that your ingestion pipeline processes with layout-aware parsing. Check that the template reflects the document types your users really upload, because a generic layout can hide parser behavior that a real file would trigger. Confirm the rendering and text extraction behavior of your own parser for each template.
File converters docsPlain-text PDFs
Plain-text PDFs take the attack prompt as raw content and render it into a simple PDF page. This is the quickest way to check whether a document-upload path passes instructions from file body text into a model's context without filtering. Its limit is that it shows little about how real documents are laid out, so a clean result does not show that a formatted report, scanned form, or multi-column file behaves the same way. Test with the text extraction library your system uses, not only the one PyRIT produces.
Injection into an existing PDF
Injection adds attack text to a PDF you already have, which keeps the original content, metadata, and visual design intact. This matters when the risk comes from a trusted file that a user or partner later edits, or from a document in a shared repository that RAG indexes. The result cannot show how the file would be handled if the whole document were generated from scratch, so pair it with a generated test. Confirm which text layers, annotations, and hidden elements your parser reads before reading any result as coverage.
Word document output
Word documents are a separate test path for systems that accept .docx uploads or convert them internally, since Word files use a different container and parsing stack from PDFs. Use this option when your intake, conversion service, or RAG loader handles Office formats, and when the document is part of a shared workflow such as document review. Do not assume a PDF result carries over, because a converter in the pipeline may strip or reinterpret content differently for each format. Confirm the Word output capability in the PyRIT release you run before you plan around it.
PDFConverter configuration options and when each fits
This table compares the main choices when setting up PDFConverter for a document injection test: where the content comes from, whether an existing file is modified, and how the result reaches the target. Read each row as a test question first, then check the trade-off between realism and control before fixing your configuration. Parameter names are not listed here because they should be confirmed in the PyRIT 1.1.0 parameter reference for your installed version.
| Choice | Test scenario it fits | Trade-off between realism and control |
|---|---|---|
| Template source (YAML template) | Repeatable tests of a known document layout, such as an invoice or policy form, where the same structure must be sent to several targets | Templates give consistent layouts across runs, but the generated document may look less like a real upload than a file taken from your own corpus |
| Plain text input | Quick checks of whether the ingestion path extracts and passes through instructions embedded in ordinary body text | Fast to set up and easy to vary, but the document has no realistic formatting, metadata or visual structure that a parser might treat differently |
| Existing file to inject into | Testing whether injected text in a real document from your own file store is extracted, summarized or acted on by a RAG pipeline | Closest to production content and layout, but depends on having an approved sample file and needs care with any real business data it contains |
| Output location | Keeping generated files in a controlled test directory so they can be reviewed, deleted and attributed to a specific run | Local storage makes review simple, while shared or cloud paths add access and retention questions you must answer before testing |
| Attachment to the target request | Uploading the converted file through the target's document endpoint or a web upload form to exercise the full ingestion chain | Exercises the real path including parsing and storage, but the upload mechanics depend on the target, so confirm the supported attachment method in the parameter reference |
| Parameter names and defaults | Any configuration not covered above | Confirm exact parameter names, defaults and supported options in the PyRIT 1.1.0 file converter documentation or the parameter reference for your version |
Setting up PDF converters in a PyRIT test environment
This sequence takes a team from an empty Python environment to a PDF carrying injected test text that has been delivered to a non-production target. Each step ends with a check so the team knows the converter works before any document reaches a system they care about.
Confirm a supported Python version
The engineer running the tests checks that the workstation or build runner has Python 3.10 or later and below 3.15, the range the PyPI package supports. The PyRIT documentation recommends Python 3.13, so use that version if the team can. Run the version command in the shell and confirm the output falls in the supported range before installing anything. Record the version in the test notes so later reruns use the same interpreter.
Install PyRIT in an isolated environment
Create a dedicated virtual environment and install the PyRIT package from PyPI with pip, keeping it separate from other Python projects on the same machine. Confirm the install by importing the package in a Python shell and printing its version, which should match the release the team has agreed to test with. Pin that version in a requirements file so the same converter behavior is available on every rerun. The check is a clean import with no dependency errors.
Configure credentials and settings files
Create the ~/.pyrit/.env file for target credentials and the ~/.pyrit/.pyrit_conf file for settings, and keep both out of source control. Store only the keys for the non-production target the team plans to use, and restrict file permissions so other local users cannot read them. Confirm the configuration loads by running a PyRIT startup command or a short script that prints the active target name without printing any secret. If the secret value appears in any output, correct the file before continuing.
Define the PDF template or source document
Decide whether the test starts from a YAML template that the PDFConverter renders into a new PDF, or from plain text, or from an existing PDF that already matches the document type the target ingests. Write the carrier content so it looks like a normal business document, and mark the injected instruction with a unique token so it can be found later. Store the template in the test repository with a version label. The check is a written document that a reviewer can read and that contains the unique marker.
Run the PDF converter on a sample
Run the PDFConverter against the template or source file on a single sample prompt, with the output path set to a scratch directory. Use one sample first so that any template or injection-text errors show up before the full test set is generated. Confirm the run completes without exceptions and that a new PDF file exists at the output path. Note the file name and size in the run log so the artifact can be traced later.
Verify the PDF opens and the text extracts
Open the generated PDF in a standard reader, then extract its text with a separate text extraction tool that the team uses for ingestion pipelines. Search the extracted text for the unique marker from the template, and confirm the injected instruction appears in full and in the order expected. Also confirm that the visible page layout is what a reviewer would expect for the document type. If the marker is missing from the extracted text, the target's parser may not see the injection, so record that as a converter result, not a pass.
Send the document to a non-production target
Upload the verified PDF to the non-production upload or RAG ingestion endpoint, using a test account that has the same permissions as a normal user. Confirm the upload is accepted, then ask the target a question whose answer depends on the document so the team can see whether the injected text reached the model context. Save the conversation and the uploaded file hash in PyRIT memory so the result can be reviewed later. Only move to a production-adjacent system after the team has written approval for that scope.
How injected text in a PDF reaches a RAG pipeline
A payload written into a PDF only matters if it survives the path from upload to retrieval, and the result depends on your own ingestion code, not on PyRIT. A typical retrieval-augmented generation pipeline passes the file through a parser that extracts a text layer, sometimes through OCR when the text is an image or the text layer is missing, then through a chunker that splits the text into segments, an embedding model that turns each segment into a vector, and a retriever that returns the closest chunks to the model at question time. At each stage the injected text can be kept, altered, split across chunks, dropped as boilerplate, or ranked too low to reach the prompt. A payload that is visible when you open the PDF may never appear in the extracted text, and text that the parser extracts may not be retrieved for the queries you expect.
Because each stage is a decision someone on your team made, the test has to follow the real pipeline. Use the same parser library, version and options, the same OCR settings, the same chunk size and overlap, the same embedding model and the same retrieval parameters that production uses, then query the system with questions that should pull the injected segment back. Record the extracted text, the chunk that contains the payload and the retrieved context at each step, so a failure can be traced to the stage that removed it. Confirm parser behavior with your own document stack before you read anything into a negative result, since text extraction varies with how the PDF was produced, how fonts are embedded and whether the parser reads hidden or off-page content.
Questions teams ask before testing document injection with PyRIT
Can our own team run PyRIT's PDF converters without outside help?
Yes, a team with Python experience can install PyRIT with pip and use the PDF converter, which generates PDFs from YAML templates or plain text and can inject text into existing PDF documents. The PyPI package supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. The harder part is not the converter call itself but deciding which document paths to test, building a realistic corpus, and reading the results against your ingestion pipeline. Teams without someone who owns that pipeline usually find the scenario design takes longer than the tooling setup.
How much effort do setup and scenario design take, and what drives it?
Effort depends mostly on how many ingestion paths you test and how much access your team has to them. Installing PyRIT and running a single converter on a test file is a small task. Effort grows with the number of document types (PDF, Word, scanned or templated files), the number of upload and retrieval stages between the user and the model, and whether the target is a custom HTTP endpoint or a web app that needs browser automation through Playwright. Each injected payload also needs a clear success condition, so the scenario has to be written against what your system is supposed to do with the document. Ask any partner for a written breakdown by ingestion path, not a single lump estimate.
What does the work need from our team?
Three things are needed from your side: a test environment that mirrors production document handling, a sample corpus of documents your users actually upload, and access to the pipeline stages that process them. The test environment should be isolated, so injected content cannot reach real users or live retrieval indexes. The corpus should include normal business documents, not only synthetic files, because parsing behavior often differs by layout and file structure. Pipeline access means logs or traces from parsing, chunking, embedding and retrieval, so a finding can be traced to the stage where it happened. Confirm credentials and their storage in advance, since PyRIT reads them from ~/.pyrit/.env.
Do PDF and document injection results need a scorer?
Yes, in most cases a scorer is needed to decide whether an injection worked. Without one, a team reviews every model response by hand, which does not scale across many documents and payloads. PyRIT scorers can evaluate responses with LLMs, Azure AI Content Safety or custom logic, and custom logic is often the most reliable choice for document tests because you can check for a specific string, an unexpected tool call or a leaked instruction. Scorers themselves need validation against cases where you already know the answer, since an LLM judge can be wrong in either direction. Plan the scorer design alongside the scenario, not after the first run.
How should we handle sensitive content in test documents?
Test documents should never contain real personal, financial or health data unless your data protection rules explicitly allow it in the test environment. Build the corpus from synthetic or redacted documents that keep the same layout and metadata patterns as production files. Store generated PDFs and Word files in a restricted location, and confirm the retention period for conversation records in PyRIT memory, which is stored in SQLite or Azure SQL. Injected payloads may themselves contain sensitive-looking text, so review where results are exported and who can read them. Your privacy and legal teams should approve the corpus and storage plan before the first run.
When is outside help worth it for document injection testing?
Outside help is most worth considering when the ingestion path is complex, when results must feed an audit or customer security review, or when the internal team lacks time to build and maintain scenarios. A partner can scope the work in writing, cover the converters, scorers and pipeline tracing, and hand over documented runs your team can repeat. DeployOpen plans and runs AI security testing, including testing of AI systems and agents, and prepares evidence for compliance assessments, but it does not issue audit reports or certifications. Ask for a fixed scope with named deliverables and a retest step before work starts.
Which document types should we test first?
Start with the file types your users upload most often and the ones your pipeline parses with the least certainty. In practice, that usually means PDFs and Word documents that reach retrieval-augmented generation (RAG) indexes or agent tools. Begin with a small set of templates and plain-text payloads, confirm that the converter output matches what your parser sees, and then expand to injected existing PDFs. Documents that pass through optical text extraction or conversion services add another stage and should be tested separately. Record which file type triggered each result so fixes can target the right parser.
Security and operational risks of running document injection tests
Document injection tests generate files that look like real business documents and feed them into systems that may index, summarize or act on their contents. The cards below cover the controls that keep those tests contained, from the test files themselves to the memory records and vulnerability reports that follow.
Treat generated payloads as hostile files
PDFs and Word documents built with injected instructions can trigger behavior in any parser, indexer or model that reads them. Keep generated files in a dedicated working folder, label them clearly by test ID, and never reuse them as sample documents. Before sharing a payload with another team, confirm who can open it and that it carries no real customer data, since templates and plain text inputs are easy to copy from production sources.
Keep tests inside a non-production environment
Document upload and RAG ingestion paths often connect to live knowledge bases, shared drives and ticketing systems. Run the target in a staging or isolated environment with its own index, storage and service accounts, so an injected instruction cannot reach documents or actions that real users depend on. Ask the system owner to confirm which downstream tools the ingestion pipeline can call during a test.
Store credentials in the PyRIT environment file
PyRIT reads credentials for model and service targets from ~/.pyrit/.env and settings from ~/.pyrit/.pyrit_conf. Keep that file readable only by the tester's account, out of shared repositories and out of logs. Use test-scoped keys for the document target, rotate them after the engagement, and confirm that the converter configuration contains no secrets that would be copied into generated files.
Control what memory keeps
PyRIT stores conversations and results in SQLite or Azure SQL, and generated document content and model responses can end up there. Decide the retention period and who can query the database before the first run. Confirm where the file lives, whether it is encrypted at rest, and how it is deleted. Injected content may include sensitive-looking text, so treat the memory store as sensitive data.
Report PyRIT vulnerabilities privately
If a test reveals a flaw in PyRIT itself, such as a converter that writes files outside its intended folder, report it privately rather than in a public issue. The project directs vulnerability reports through the Microsoft Security Response Center under its security policy. Record the PyRIT version in use, the converter involved and the reproduction steps, and keep the details out of public tickets until a fix is available.
PyRIT on GitHubWhat to check about PyRIT's license and project status
Start by confirming the project status before you build a document injection test around PyRIT. PyRIT, the Python Risk Identification Tool, is an open source framework from Microsoft released under the MIT license. The original Azure/PyRIT repository was archived on 27 March 2026 and is now read-only, so development continues at microsoft/PyRIT. Any clone, fork, or example that still points to the Azure namespace will not receive fixes, and your install and documentation references should use the active repository, microsoft/PyRIT on GitHub.
Pin the exact PyRIT version your PDF and Word converter tests depend on, and record it in the test repository alongside the Python version. The PDFConverter's template handling and text injection behavior can change between releases, so a payload that rendered correctly on one version may produce a different file on the next. PyRIT v1.1.0 was released on 4 September 2026, and the PyRIT releases page is where you should check release notes before each upgrade. Assign one person to read those notes and decide whether converter output needs to be retested.
Keep the license review separate from the engineering review. The buyer's guide content group covers what the MIT license permits, who holds the copyright and what the trademark notice restricts, and your legal or procurement team should work through that material before a document test program goes live. Confirm the license terms against the repository's own license file for the version you installed, not against a summary.
How DeployOpen scopes and delivers document injection testing
DeployOpen plans PyRIT document converter testing as a written, fixed-scope piece of work tied to the upload and ingestion paths your organization actually runs. The work covers which PDF and Word documents carry test payloads, how they reach the target, and what evidence the team keeps from each run.
How we scope
- Identify which upload forms, document pipelines and RAG ingestion paths receive PDFs or Word files from users
- Agree which payload types to test, such as template-generated PDFs, injected text in existing PDFs and Word documents
- Confirm the target system, access method and test accounts in writing before any document is sent
- Set the success criteria, deliverables and timeline in a written scope agreed before work starts
How we build
- Install PyRIT in a test environment you control, using a Python version the PyPI package supports
- Write YAML templates and plain text sources for PDF generation, keeping each test document traceable to its test case
- Create injected PDF and Word variants of your existing sample documents, with payloads placed where your parser reads them
- Run each document through the same ingestion path your production users follow, and record every target response
How we hand over
- Deliver the generated test document set, templates and configuration files in a version-controlled repository
- Provide a findings report that maps each result to the document type, payload location and ingestion step
- Document how PyRIT memory records each conversation so your team can review and rerun the tests
- Walk your security and platform engineers through the runbook for repeating the tests after changes
How we support
- Offer ongoing support and continuous testing as a retainer when document pipelines change often
- Retest fixed findings after your team changes parsers, filters or retrieval settings
- Review new PyRIT releases against your test harness before you upgrade the framework
- Confirm with your team which support level and retest scope fit your environment before signing

