Attack pattern

PDF Prompt Injection

How PDF structure, text extraction, rendering, OCR, annotations, form fields and embedded files create several different model-visible representations, and how provenance, constrained processing and independent authorization contain impact.

By Norbert HofmannPublished: 2026-09-20Last reviewed: 2026-09-20Level: IntermediateAudience: Security Engineers, Developers, AI Engineers
Variant
Indirect
Vector
PDF / Extracted Representation
Targets
LLM, RAG System, AI Agent, Tool
OWASP
LLM01:2026 Prompt Injection
Table of contents

What Is PDF Prompt Injection?

PDF prompt injection is indirect prompt injection delivered through a PDF file that an AI system reads, extracts, renders, summarizes, classifies, indexes or otherwise turns into model-visible content. The attacker may author the whole file, supply one attachment, fill a form field, add an annotation, or influence a document that is later exported to PDF. Direct access to the assistant is not required: a legitimate user, connector or batch job triggers processing later.

What makes PDF distinctive is not a special kind of instruction. It is that one PDF can yield several different representations of "its content", and those representations do not have to agree with each other. A person sees rendered pages in one viewer. A text extractor emits a stream whose order and completeness depend on the implementation. A rendering-plus-OCR path produces a third result. Annotations, form field values, attachments and metadata may or may not be included at all.

Model influence and security impact stay separate. A changed summary or classification shows influence. A security consequence additionally requires a sensitive data or capability path and a missing, overbroad or failed application control.

PDF vs. Generic Document Prompt Injection

The Document Prompt Injection article covers the general container problem: office and open formats, markup and plain text, collaborative editing, conversion pipelines and the parts a parser may or may not traverse. Everything there applies to PDF as well. This page adds only what is specific to a fixed-layout, object-graph format that is usually consumed through extraction or rendering rather than through a structured editing model.

Where the two pages differ
AspectGeneric document pageThis PDF page
Primary modelContainer with logical parts and an editing schemaObject graph with page-level content streams and a fixed presentation
Typical extractionPart traversal of a defined document modelText-stream reconstruction, layout heuristics, or rendering plus OCR
Ordering riskPart inclusion and flatteningReading order reconstructed from positioned content, which varies per tool
Secondary surfacesComments, notes, headers, propertiesAnnotations, form fields, embedded files, metadata, optional content groups
Human-view gapA part may not be displayed in the default viewExtractor output and rendered page can differ for the same file and page

Where both pages would say the same thing, this one links instead of repeating. The shared conclusion remains: representation determines exposure, and exposure is not authority.

Not Malware, Not a File-Format Exploit

PDF has a long security history that has nothing to do with prompt injection: embedded JavaScript actions, launch and URI actions, malicious embedded files, and memory-safety bugs in parsers and renderers. Those are code-execution and traditional-exploit problems. They are addressed by sandboxing, disabling active features, patching and malware scanning.

Prompt injection is a different failure class. No code executes. Ordinary language that a processing pipeline turns into model-visible text influences an interpretation or a plan. A file can be perfectly benign by every malware and format-conformance measure and still carry content that changes an assistant's proposal.

How PDFs Are Processed End to End

PDF processing path
UntrustedPDF Source
SystemDelivery / Upload
SystemAcceptance / Type Check
SystemParser / Renderer / OCR
Variable trustSelected Objects and Pages
SystemNormalization / Chunking
Variable trustModel-Visible Representation
SystemLLM
Variable trustProposal
SystemPolicy / Authorization
Variable trustEffect

Products combine these stages differently. Some extract the text layer and stop. Some rasterize pages and run OCR or a vision model. Some do both and merge the results. Some route scanned files down a different path than digitally generated ones. The security task is to document the runtime path that actually runs for each supported case, and the trust decision at every transition.

Trusted infrastructure faithfully returns untrusted content. A successful upload, a correct type check and a well-behaved parser establish properties of the pipeline, not authority for the text the pipeline emitted.

The Multi-Representation Problem

A single PDF can produce many different content views. Which of them exists in a given product depends entirely on its processing configuration.

01
RepresentationFile structure and object graph

Objects, pages, resources and references that define what the file contains before any view is produced.

02
RepresentationExtracted text stream

Characters reconstructed from positioned content, with reading order inferred by the extractor.

03
RepresentationRendered page image

What a specific viewer draws at a specific size, which is what a reviewing person actually sees.

04
RepresentationOCR or vision output

Text or descriptions derived from rendered pages, used for scans and often for all pages in some pipelines.

05
RepresentationAnnotations and comments

Review layers that some tools return with the text and others omit completely.

06
RepresentationForm field values

Interactive field content that may be stored separately from the page content stream.

07
RepresentationEmbedded files and attachments

Files carried inside the PDF, processed only when a workflow explicitly opens them.

08
RepresentationMetadata and properties

Title, author, keywords and custom properties, relevant only where a product surfaces them to the model.

09
RepresentationOptional content groups

Layer-organized content whose visibility state in a viewer may differ from what an extractor returns.

10
RepresentationDerived artifacts

Conversion output, summaries, RAG chunks and index entries produced from any of the above.

None of this is inherently malicious. It is a visibility and provenance condition: the content that influenced a model may not be the content a reviewer saw, and vice versa.

What Actually Becomes Model-Visible

Three views of the same PDF page
ViewWhat it representsSecurity question
Human rendered viewWhat one viewer displays at one zoom level and settingCould a reviewer reasonably have seen the material that later affected the model?
Extractor or OCR outputThe text stream or derived text the pipeline emittedWhat did this implementation include, omit, reorder or invent through layout heuristics?
Model-visible contextThe exact spans, wrappers, labels and application instructions sent to the modelWhich provenance and authority labels survived context assembly?

A screenshot cannot establish what the model received, and raw extractor output cannot establish what a person saw. Investigations and tests need both, plus the transformation between them. Teams should capture the exact model-visible representation per supported PDF class - digitally generated, scanned, form-bearing, annotated, mixed - rather than assuming one behaviour.

Parser, Renderer and Extractor Variance

Two conformant tools can return different text for the same page. Reading order is reconstructed rather than declared, so multi-column layouts, tables, footnotes, headers and floating elements can be ordered differently. Character mapping, ligatures, spacing heuristics and font encoding affect what the emitted string looks like. Rendering fidelity differs. OCR adds its own error and ordering profile.

This variance matters for three reasons. It means a security test result is tied to the exact library and version tested. It means a content span invisible in one pipeline can be prominent in another. And it means an incident reconstruction must record which component and version produced the representation that reached the model - otherwise the evidence cannot be reproduced.

Version pinning, a documented extraction configuration and re-testing after library upgrades are therefore part of the control set, not housekeeping.

Attacker Prerequisites and Delivery Surfaces

A PDF only matters to an AI system once it reaches a processing workflow. The realistic delivery surfaces are ordinary business channels.

01
SurfaceDirect upload

A user or customer uploads a file to an assistant, portal or intake form.

02
SurfaceEmail attachment

An inbound message carries a PDF into a mailbox an assistant reads or triages.

03
SurfaceTicket and support flows

Invoices, contracts, claims and evidence files attached to a case record.

04
SurfaceCollaboration spaces

Shared drives, wikis and channels where external collaborators may add files.

05
SurfaceWeb download

A browsing or research agent retrieves a published PDF.

06
SurfaceConnector ingestion

SaaS synchronization pulls files from systems with different authorship controls.

07
SurfaceRAG ingestion

A batch indexing job converts a document store into persistent retrievable chunks.

Each surface has a different prerequisite: an account, an email address, a customer relationship, edit rights in a space, or merely a public URL. Enumerating who can place a file into which pipeline is the first step of both threat modelling and an authorized assessment.

Offensive Perspective on PDF Ingestion

In an authorized assessment the starting question is not how to write a clever file. It is which PDF surface the tester can legitimately control, under which identity, and which realistic task would cause that file to be processed at all. Control without reachability produces no finding.

The following constraints are technical rather than linguistic. The file must be accepted by size, type and policy checks. It must be routed to the extraction path the product truly uses, which may be a text layer, a rendering plus OCR path, or a vendor conversion service. The relevant object class - page content, annotation, form field, attachment, metadata - must be one the implementation returns. What survives normalization, truncation and chunking then decides what the model sees, and in which order relative to the legitimate task material.

Because this page is written for defenders and authorized testers alike, it explains the barrier structure and how to measure each stage. It deliberately omits concealment techniques, reusable instruction strings, object-placement recipes and any procedure for increasing extraction or influence probability. Those implementation details stay in the cited research.

PDF Attack Success Chain

Success gates from file to effect
UntrustedDelivery / Reachability
SystemFile Accepted
SystemParser / Renderer / OCR Path
Variable trustContent Survives Transformation
Variable trustModel-Visible Representation
Variable trustModel / Plan Influence
Variable trustCapability / Data Reach
SystemPolicy / Authorization Failure
Variable trustSecurity-Relevant Effect

Every gate is necessary for a complete end-to-end security impact, and every gate is separately testable. Reporting should keep them apart: a file that is accepted is an intake finding, an extracted controlled span is an extraction finding, a changed summary is an influence finding, and only a failed authorization decision with a real side effect is an authorization finding.

Controls can break the chain at several points: restricting who can submit files, restricting accepted object classes, isolating parsing, labelling provenance, minimizing context, detecting task drift, enforcing least privilege and applying deterministic policy before any consequential action. This layered view avoids depending on perfect semantic detection while still treating observed influence as a signal worth investigating.

Competing Constraints for an Attacker

The chain also describes what an attacker competes against, which is why real-world exploitation is far less certain than a laboratory demonstration suggests.

01
ConstraintProcessing may never trigger

The file may sit unread, be handled by a human, or be excluded by the workflow's file selection.

02
ConstraintThe representation may not be produced

The chosen object class may be ignored by the configured extractor, or the OCR path may not run.

03
ConstraintTransformation may destroy the content

Reordering, truncation, chunk boundaries and normalization can break up or drop the relevant span.

04
ConstraintProvenance may label it as data

Clear source and authority marking reduces the chance a model treats the text as an instruction.

05
ConstraintContext minimization may exclude it

Task-scoped selection can leave the span out of the request entirely.

06
ConstraintCapability reach may be empty

A read-only summarizer offers no tool, destination or write path to reach.

07
ConstraintDeterministic policy may deny

Even a fully influenced plan fails at an authorization decision the model cannot affect.

These constraints are the reason stage-wise measurement is more informative than a single success number: they tell a team which gate is actually carrying its defensive weight.

Offensive Review Questions

An authorized PDF assessment should evidence each gate independently, using synthetic files, synthetic protected data, bounded permissions and reversible side effects. These questions structure the review without prescribing an exploitation sequence.

01
QuestionControllable surfaces

Which PDF surfaces can be authored or supplied - whole file, attachment, form field, annotation, exported document - and by which identity?

02
QuestionAcceptance and routing

Which files are accepted, and which extraction path does the product actually run for each PDF class?

03
QuestionParser and version variance

Which library and version produce the representation, and does the result change across supported versions?

04
QuestionRaw text vs rendered view

Where do extractor output and rendered page disagree for the same page, and is that difference visible to a reviewer?

05
QuestionOCR and vision path

When does rasterization plus OCR or a vision model run, and what does it contribute to context?

06
QuestionSecondary object classes

Are annotations, form values, embedded files, metadata and optional content returned to the model in this configuration?

07
QuestionDerived artifacts and caching

Which summaries, chunks, index entries and caches persist, and does deleting the source remove them?

08
QuestionDownstream tools and destinations

Which data, tools, recipients and write paths become reachable once a plan is influenced?

09
QuestionContainment and telemetry

Which deterministic decision denies the path, and can the evidence separate extraction, inclusion, influence, decision and effect?

Worked Scenario: Automated Invoice Intake

01Legitimate task

A finance assistant extracts supplier, amount and due date from an emailed PDF invoice and prepares a payment record for review.

02Processing

The pipeline reads the text layer, runs OCR on one scanned page and includes annotation content. Telemetry records file hash, page, object class, extractor version and each extracted span.

03Model influence

A supplier-controlled span changes the proposed record and adds an unrelated suggestion to look up a synthetic protected vendor ledger and email an update to an external address.

04Policy decision

Deterministic policy finds no task authorization for the additional retrieval or the external destination. Both are denied; the payment record stays a draft pending human review.

05Evidence

The event links file hash and page, the extracted span, the model-visible context, the proposal, the policy version, the denial, and the unchanged draft.

Influence occurred, because PDF-derived language changed the proposal. Impact was contained, because the synthetic protected ledger never entered context and no external action executed. The extractor did not fail; the architecture treated its output as untrusted task data. All data in such an exercise should be synthetic and every side effect reversible.

PDFs in RAG and Derived Artifacts

PDF is one of the most common formats in enterprise retrieval corpora. Once a file is parsed, chunked and indexed, a one-time exposure becomes persistent and can reach users far from the original upload. Source-level provenance and access policy must survive chunking, embedding, indexing, retrieval and context assembly; document ACLs that disappear from child chunks are an authorization failure before prompt influence is even considered.

Deleting the source PDF does not automatically remove its derivatives. Summaries, caches, index entries, embeddings and memory writes can outlive the file and must be enumerated and invalidated explicitly. The RAG Prompt Injection article covers retrieval reachability, security trimming, tenant isolation and index generations in depth; this page contributes the page- and object-level lineage that the retrieval layer must preserve rather than flatten.

Detection and Telemetry

Evidence from file to effect
  1. 01
    Source

    File hash, size, delivery channel, submitting principal or connector, owner, tenant and effective permissions.

  2. 02
    Acceptance

    Declared and detected type, policy decision, size and page limits, and the chosen processing route.

  3. 03
    Processing

    Parser, renderer and OCR components with versions and configuration, plus sandbox result.

  4. 04
    Representation

    Page and object identifiers, object class, extracted spans and the exact model-visible text.

  5. 05
    Probabilistic signals

    Instruction-like language, large divergence between rendered and extracted content, unexpected object classes and task drift.

  6. 06
    Proposal

    Model output, proposed retrievals or actions, tool-chain changes and source attribution.

  7. 07
    Decision and effect

    Policy version, allow or deny, exact parameters, destination and executed side effect.

These signals establish sequence and context; they rarely prove internal model causality. Hard evidence comes from file history, authorization decisions and executed-action records. Extracted text and model context can contain confidential material, so apply purpose limitation, access control, retention limits and redaction while preserving enough to reconstruct an incident.

Prevention and Secure Architecture

  1. 01
    Process representation-aware

    Know and document which representations - text layer, render, OCR, annotations, form values, attachments, metadata - each pipeline produces.

  2. 02
    Minimize accepted surfaces

    Accept only the object classes the task needs instead of extracting everything a library can return.

  3. 03
    Isolate parsing

    Sandbox parsers, renderers and OCR to contain traditional file-processing risk, and keep components patched and pinned.

  4. 04
    Establish provenance

    Record submitter, channel, ownership, file hash, page and object identity without trusting claims made inside the file.

  5. 05
    Preserve lineage

    Carry source, page, object class and access labels into every model-visible span, chunk, summary and cache entry.

  6. 06
    Ingest permission-aware

    Apply repository and tenant authorization before content enters an index or a model context.

  7. 07
    Minimize context

    Send only task-required PDF content and only the application data the task needs.

  8. 08
    Separate proposal and execution

    Treat model output as an untrusted proposal and authorize every sensitive action deterministically.

  9. 09
    Constrain capability and egress

    Use least privilege, task-scoped and short-lived credentials, destination policy and observable execution.

  10. 10
    Bind approval to the action

    Where human approval is used, bind it to the exact immutable action and expire it if the proposal changes.

Risky
  1. PDF
  2. Extractor / OCR
  3. LLM Agent
  4. Privileged Action

Everything the library can return flows straight into a broadly capable agent.

Stronger
  1. PDF + Provenance
  2. Isolated Parsing / Object Policy
  3. Page and Object Labels
  4. Minimized Model Context
  5. LLM Proposal
  6. Policy / Authorization
  7. Restricted Action

Representation, authority and execution stay separate across the whole workflow.

The Defense Hub places these controls in the site's broader model for provenance, information flow, least privilege, action control, monitoring and recovery.

Controlled Defensive Testing

Use synthetic PDFs, synthetic identities, test repositories and test tenants. Vary the PDF class - digitally generated, scanned, form-bearing, annotated, mixed - the extraction path, the library version, the object classes returned, the permission state and the available capabilities. Measure each stage separately.

The Document / PDF Prompt Injection lab practices the underlying trust decisions with fictional documents: storage, extraction and document labels versus provenance and application records.

Separate PDF-processing security metrics
MetricQuestion answered
Extraction / Visibility Rate by object classHow often does each tested object class reach the exact model context?
Retrieval RateHow often is the indexed PDF content actually retrieved under realistic queries?
Injection Influence RateHow often does visible synthetic content change answer, classification, plan or proposal?
Policy Bypass RateHow often does a prohibited influenced path pass application policy?
Unauthorized Action RateHow often does an impermissible side effect execute?
Data Disclosure Success RateHow often does synthetic protected data reach a forbidden output or destination?
Detection RecallHow many known synthetic cases produce the expected alert or review signal?
False-Positive RateHow many benign PDFs are incorrectly flagged?
Containment RateHow often is influence prevented from becoming unauthorized impact?

Do not combine these into one score. High visibility with low influence is a different control outcome from high influence with zero policy bypass, and only the separation shows whether to improve extraction policy, detection, authorization or containment.

Incident Response

PDF injection response checklist

  • Preserve the original PDF, its cryptographic hash and the delivery record.
  • Preserve submitter, channel, owner, tenant, permissions and sharing state.
  • Record the parser, renderer, OCR and conversion components with versions and configuration.
  • Preserve the rendered view, the extracted representation and the exact model-visible context with page and object identifiers.
  • Identify the affected spans and derived chunks without publishing reusable payload text.
  • Enumerate every user, workflow and tenant that processed the affected file.
  • Locate summaries, caches, chunks, index entries, embeddings, tickets and drafts derived from it.
  • Separate observed model influence from data actually disclosed or actions actually executed.
  • Quarantine the file and its derivatives while preserving evidence, then rebuild indexes from known-good material where needed.
  • Revoke or rotate credentials only when evidence supports exposure or misuse.

Common Misconceptions

Frequent PDF-processing errors

  • Believing a malware-clean, conformant PDF is safe from semantic influence.
  • Assuming the rendered page and the extracted text contain the same content in the same order.
  • Testing with one library and treating the result as valid for the whole product.
  • Extracting every object class a library supports because it is available.
  • Assuming OCR or conversion to plain text sanitizes instruction-like language.
  • Treating a digital signature or an internal repository as instruction authority.
  • Letting PDF-derived text select tools, parameters, recipients or permissions.
  • Indexing PDFs without carrying document permissions to every chunk.
  • Deleting the source file while leaving chunks, caches, summaries and embeddings.
  • Recording no link from page and object to model context, proposal, decision and effect.

Standards and Research Context

Reviewed classifications and format references

OWASP GenAI Security Project
LLM01:2026 Prompt Injection
NIST
NIST AI 100-2e2025 terminology, NIST Glossary: indirect prompt injection
Microsoft
Defend against indirect prompt injection attacks, Input, Context, and Retrieval Hygiene
Format reference
ISO 32000-1 / PDF 32000-1:2008
Research
Greshake et al. 2023, CrackedPDFs 2026, Hidden prompts in manuscripts 2025

OWASP LLM01:2026 states that indirect prompt injection can arrive through external sources such as files, that such content need not be visible to a human as long as it is parsed by the model, and that multimodal systems add cross-modality risk. NIST AI 100-2e2025 describes indirect prompt injection as attacker control over a resource that a generative AI system consumes, and keeps that mechanism distinct from downstream impact.

Microsoft guidance counts documents among untrusted external content and recommends layered probabilistic and deterministic controls. Its Input, Context, and Retrieval Hygiene guidance states that every prompt, document, retrieved chunk, tool result and memory write should be treated as untrusted input, and that secure retrieval requires source provenance, permission-aware indexing and validation at every read and write. That applies directly to extracted PDF pages and to the summaries, caches and index entries derived from them.

For research context, CrackedPDFs is a controlled benchmark for hidden prompt injection in PDFs; its results describe that benchmark setup and should not be read as universal robustness or success claims for arbitrary products. It is cited here for one defensive lesson: flattening and extraction can destroy the evidence that content was never human-visible, which is exactly why investigations need the rendered view, the extracted representation and their difference. Research on AI-assisted peer review similarly documents that PDF-borne hidden prompts can affect LLM reviewers. Neither concealment methods nor optimization procedures are reproduced here. The PDF specification is used only for factual structure; it is not an AI-security standard and assigns no trust.

Frequently Asked Questions

How is this different from Document Prompt Injection?

The general document page covers containers, parts and conversion across formats. This page covers what is specific to PDF: one file yielding several representations through extraction, rendering, OCR, annotations, form fields, attachments and metadata, each of which may disagree with the others.

Is this a PDF vulnerability?

No. No code executes and no format bug is required. The exposure comes from an AI pipeline turning file content into model-visible text and an application granting that text more influence than it should have.

Does disabling JavaScript in PDFs help?

It reduces traditional active-content risk, which is worth doing, but it does not affect semantic prompt injection. Ordinary text is enough.

Must the content be hidden from humans?

No. Visible ordinary text can influence a model just as well. Concealment only changes the review probability, not the underlying authority problem.

Do two PDF libraries produce the same text?

Often not. Reading order is reconstructed, not declared, so multi-column pages, tables and floating elements can be ordered differently, and secondary objects may be included by one tool and omitted by another.

Does OCR make a scanned PDF safer?

No. OCR creates text from what was previously an image, which can add a model-visible representation that the text-layer path would not have produced at all.

What changes when PDFs enter RAG?

Exposure becomes persistent and shared. Chunks, embeddings, summaries and caches can reach other users later, so document permissions and provenance must survive every derivative, and deleting the source is not sufficient.

How should PDF-processing agents be authorized?

With the initiating principal's current permissions, task-scoped and short-lived capabilities, deterministic policy for every sensitive retrieval, destination and write, and approval bound to the exact action for selected high-impact effects.

References

  1. LLM01:2026 Prompt InjectionOWASP GenAI Security Project · GuidanceReviewed 2026-09-20
  2. Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST AI 100-2e2025NIST · Standard · 2025-03Reviewed 2026-09-20
  3. indirect prompt injectionNIST Glossary · Technical documentationReviewed 2026-09-20
  4. Defend against indirect prompt injection attacksMicrosoft Learn · GuidanceReviewed 2026-09-20
  5. Input, Context, and Retrieval HygieneMicrosoft Learn · GuidanceReviewed 2026-09-20
  6. PDF 32000-1:2008 (ISO 32000-1) Document management - Portable Document FormatAdobe / ISO · Standard · 2008Reviewed 2026-09-20
  7. CrackedPDFs: A Controlled Benchmark for Hidden Prompt Injection in PDFsarXiv:2607.19396 · Research publication · 2026Reviewed 2026-09-20
  8. Hidden Prompts in Manuscripts Exploit AI-Assisted Peer ReviewarXiv:2507.06185 · Research publication · 2025Reviewed 2026-09-20
  9. Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt InjectionKai Greshake et al. · Research publication · 2023Reviewed 2026-09-20