August 24, 2026
๐จ PDF Exploit Scanner & Patcher | Detect Malicious PDFs + Block Threats
PDF files are everywhere.
By Pentester Club
7 min read
Businesses use them for invoices, contracts, reports, resumes, presentations, forms, and internal documentation. Because PDFs are so common, they are also an attractive delivery mechanism for malicious content.
A PDF can contain much more than visible text and images. Modern PDF documents may include:
- JavaScript
- Embedded files
- Launch actions
- Forms
- External references
- Annotations
- Multimedia
- Object streams
- Complex document structures
That makes PDF security analysis an important part of modern defensive security.
A useful PDF-security workflow should answer two questions:
_๐ _Does this PDF contain suspicious or potentially dangerous structures?
and:
_๐ก๏ธ _Can we safely sanitize the document before distributing it?
This article explores the concept of a PDF Exploit Scanner & Patcher โ a defensive security workflow for detecting suspicious PDF structures and producing a safer sanitized copy.
๐ Why Are PDFs a Security Concern?
A PDF looks like a simple document to the user:
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ PDF DOCUMENT โ
โ โ
โ Text + Images โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ PDF DOCUMENT โ
โ โ
โ Text + Images โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโInternally, however, a PDF can contain a complex object hierarchy:
PDF
โ
โโโ Catalog
โโโ Pages
โโโ Fonts
โโโ Images
โโโ Metadata
โโโ Actions
โโโ JavaScript
โโโ Embedded Files
โโโ Object StreamsPDF
โ
โโโ Catalog
โโโ Pages
โโโ Fonts
โโโ Images
โโโ Metadata
โโโ Actions
โโโ JavaScript
โโโ Embedded Files
โโโ Object StreamsThis complexity creates a larger attack surface for PDF readers and processing applications.
A malicious document may attempt to abuse a vulnerability in a PDF viewer, exploit dangerous document features, or trick a user into interacting with an embedded resource.
๐ What Is a PDF Exploit Scanner?
A PDF exploit scanner is a defensive analysis tool that examines a document for indicators associated with potentially malicious or risky PDF behavior.
A simplified architecture looks like:
๐ PDF
โ
โผ
File Validation
โ
โผ
PDF Structure
Analysis
โ
โโโโโโโโโโโผโโโโโโโโโโ
โผ โผ โผ
Scripts Actions Embedded
Objects
โ โ โ
โโโโโโโโโโโผโโโโโโโโโโ
โผ
Risk Engine
โ
โโโโโโโดโโโโโโ
โผ โผ
CLEAN SUSPICIOUS
โ
โผ
Sanitizer
โ
โผ
Safe Copy๐ PDF
โ
โผ
File Validation
โ
โผ
PDF Structure
Analysis
โ
โโโโโโโโโโโผโโโโโโโโโโ
โผ โผ โผ
Scripts Actions Embedded
Objects
โ โ โ
โโโโโโโโโโโผโโโโโโโโโโ
โผ
Risk Engine
โ
โโโโโโโดโโโโโโ
โผ โผ
CLEAN SUSPICIOUS
โ
โผ
Sanitizer
โ
โผ
Safe CopyThe important concept is that a scanner should identify risk indicators, not automatically claim that every suspicious PDF is an exploit.
๐ง Detection vs Exploitation
One of the most important distinctions in document security is:
Suspicious PDF
โ
Confirmed ExploitSuspicious PDF
โ
Confirmed ExploitFor example, the presence of JavaScript does not automatically mean a PDF contains malware.
Similarly:
Embedded File
โ
Malicious FileEmbedded File
โ
Malicious FileA legitimate business document may contain attachments or interactive forms.
Therefore, a good scanner should use findings as indicators requiring context.
๐ฌ PDF Structure Analysis
A PDF is composed of objects that describe the document.
A simplified structure might look like:
1 0 obj
Catalog
endobj
2 0 obj
Pages
endobj
3 0 obj
Page
endobj1 0 obj
Catalog
endobj
2 0 obj
Pages
endobj
3 0 obj
Page
endobjAdditional objects can describe:
- Fonts
- Images
- Streams
- Actions
- Forms
- Attachments
A security scanner can inspect these objects for unusual or dangerous constructs.
๐จ Suspicious PDF Features
A defensive scanner may flag structures such as:
JavaScript
PDF JavaScript can provide interactive document functionality, but it can also be abused in attacks.
OpenAction
A document can specify actions that execute when the document is opened.
Launch Actions
These can be particularly sensitive because they may attempt to launch external resources or applications.
Embedded Files
Attachments can contain additional content that needs independent inspection.
URI Actions
PDFs can contain links to external resources.
AcroForms
Forms are legitimate PDF functionality, but they can also be involved in phishing and data-collection workflows.
๐งช A Basic Scanning Workflow
A defensive analysis pipeline can be structured as:
1. Receive PDF
โ
2. Calculate file hash
โ
3. Validate PDF structure
โ
4. Extract metadata
โ
5. Inspect objects
โ
6. Detect suspicious features
โ
7. Assign risk indicators
โ
8. Sanitize if required
โ
9. Re-scan sanitized PDF
โ
10. Generate report1. Receive PDF
โ
2. Calculate file hash
โ
3. Validate PDF structure
โ
4. Extract metadata
โ
5. Inspect objects
โ
6. Detect suspicious features
โ
7. Assign risk indicators
โ
8. Sanitize if required
โ
9. Re-scan sanitized PDF
โ
10. Generate reportThis provides a repeatable security workflow.
๐ Step 1 โ Hash the Original File
Before modifying a document, calculate a cryptographic hash.
For example:
sha256sum suspicious.pdfsha256sum suspicious.pdfThe result provides an identifier for the original artifact.
Conceptually:
PDF
โ
โผ
SHA-256
โ
โผ
Original File HashPDF
โ
โผ
SHA-256
โ
โผ
Original File HashThis is useful for:
- Incident response
- Evidence tracking
- File comparison
- Reproducibility
- Security investigations
Never overwrite the original evidence during analysis.
๐ Step 2 โ Inspect PDF Metadata
Metadata can provide useful information about the document.
Depending on the file, it may contain:
Author
Creator
Producer
Creation Date
Modification Date
Title
SubjectAuthor
Creator
Producer
Creation Date
Modification Date
Title
SubjectTools such as pdfinfo can help with basic inspection:
pdfinfo suspicious.pdfpdfinfo suspicious.pdfMetadata alone does not establish maliciousness, but unusual values can contribute to an investigation.
๐งฐ Step 3 โ Extract PDF Objects
A deeper analysis examines the document's internal objects.
Security researchers may look for indicators such as:
/JavaScript
/JS
/OpenAction
/AA
/Launch
/EmbeddedFile
/URI
/AcroForm/JavaScript
/JS
/OpenAction
/AA
/Launch
/EmbeddedFile
/URI
/AcroFormA simple static scanner can search for suspicious object names.
For example:
strings suspicious.pdf | grep -Ei '/JavaScript|/JS|/OpenAction|/Launch|/EmbeddedFile'strings suspicious.pdf | grep -Ei '/JavaScript|/JS|/OpenAction|/Launch|/EmbeddedFile'However, string matching alone is not sufficient for serious analysis.
PDF files can use object streams, compression, encoding, and other structures that make simple pattern matching incomplete.
๐งฉ JavaScript Detection
PDF JavaScript deserves special attention.
A scanner might identify:
/JavaScript/JavaScriptor:
/JS/JSand report:
โ JavaScript detected
Risk: Medium
Action: Manual reviewโ JavaScript detected
Risk: Medium
Action: Manual reviewThe correct response isn't necessarily:
"This PDF is malicious."
Instead:
"This PDF contains active scripting functionality and should be reviewed according to organizational policy."
๐จ OpenAction Analysis
A PDF can define actions that occur when a document is opened.
A scanner may therefore flag:
/OpenAction/OpenActionThe important question is:
What does the action actually do?
A benign document might use actions for legitimate navigation.
A suspicious document might combine automatic actions with other dangerous features.
Therefore, correlation matters.
๐ Embedded File Detection
PDFs can contain embedded files.
A security scanner may identify:
/EmbeddedFile/EmbeddedFileand extract metadata about the attachment without automatically opening it.
The safe workflow is:
PDF
โ
โผ
Embedded Object
โ
โผ
Extract Safely
โ
โผ
Hash
โ
โผ
Analyze SeparatelyPDF
โ
โผ
Embedded Object
โ
โผ
Extract Safely
โ
โผ
Hash
โ
โผ
Analyze SeparatelyEmbedded files should be treated as independent potentially untrusted artifacts.
๐งน What Does "Patching" a PDF Mean?
PDF patching in a defensive context generally means sanitizing the document.
Instead of trying to repair a potentially malicious object manually, a safer approach can be to reconstruct the document while preserving only the content that is required.
For example:
Original PDF
โ
โโโ Text
โโโ Images
โโโ JavaScript
โโโ Actions
โโโ Attachments
โ
โผ
Sanitization
โ
โผ
โโโโโโโโโโโโโโโโโโ
โ Safe Content โ
โ Text โ
โ Images โ
โโโโโโโโโโโโโโโโโโOriginal PDF
โ
โโโ Text
โโโ Images
โโโ JavaScript
โโโ Actions
โโโ Attachments
โ
โผ
Sanitization
โ
โผ
โโโโโโโโโโโโโโโโโโ
โ Safe Content โ
โ Text โ
โ Images โ
โโโโโโโโโโโโโโโโโโThe sanitized document may deliberately lose advanced functionality.
That tradeoff can be acceptable when security is the priority.
๐ก๏ธ Content Disarm and Reconstruction
A more advanced approach is known as Content Disarm and Reconstruction (CDR).
The basic idea is:
Untrusted Document
โ
Parse
โ
Extract Safe Content
โ
Reconstruct
โ
New DocumentUntrusted Document
โ
Parse
โ
Extract Safe Content
โ
Reconstruct
โ
New DocumentInstead of trying to determine whether every malicious component is safe, the system removes potentially dangerous functionality and rebuilds the document.
This can dramatically reduce the attack surface.
๐ Re-Scan After Sanitization
Never assume that a sanitization process succeeded.
Use:
Original PDF
โ
โผ
Scan
โ
โผ
Sanitize
โ
โผ
New PDF
โ
โผ
Scan AgainOriginal PDF
โ
โผ
Scan
โ
โผ
Sanitize
โ
โผ
New PDF
โ
โผ
Scan AgainCompare the results.
For example:
Original:
JavaScript โ Detected
OpenAction โ Detected
Embedded File โ Detected
Sanitized:
JavaScript โ Not detected
OpenAction โ Not detected
Embedded File โ Not detectedOriginal:
JavaScript โ Detected
OpenAction โ Detected
Embedded File โ Detected
Sanitized:
JavaScript โ Not detected
OpenAction โ Not detected
Embedded File โ Not detectedThis provides evidence that the sanitization process actually changed the document.
๐งช Safe Testing Environment
Suspicious PDFs should not be opened casually on a production workstation.
A safer architecture is:
๐ Suspicious PDF
โ
โผ
โโโโโโโโโโโโโโโโ
โ Quarantine โ
โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ Isolated VM โ
โโโโโโโโฌโโโโโโโโ
โ
Static Analysis
โ
โผ
Sanitization
โ
โผ
Re-Analysis๐ Suspicious PDF
โ
โผ
โโโโโโโโโโโโโโโโ
โ Quarantine โ
โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ Isolated VM โ
โโโโโโโโฌโโโโโโโโ
โ
Static Analysis
โ
โผ
Sanitization
โ
โผ
Re-AnalysisAdditional controls can include:
- Network isolation
- Disposable virtual machines
- Restricted privileges
- No access to sensitive files
- Snapshot/revert capability
- Malware-analysis infrastructure
๐ฅ Building a PDF Security Scanner
A basic defensive application could be organized into modules:
pdf_security/
โ
โโโ scanner.py
โโโ metadata.py
โโโ indicators.py
โโโ sanitizer.py
โโโ hashing.py
โโโ reporter.py
โโโ cli.pypdf_security/
โ
โโโ scanner.py
โโโ metadata.py
โโโ indicators.py
โโโ sanitizer.py
โโโ hashing.py
โโโ reporter.py
โโโ cli.pyEach component can have a specific responsibility.
scanner.py
Parses the PDF and coordinates analysis.
metadata.py
Extracts document metadata.
indicators.py
Detects suspicious PDF structures.
sanitizer.py
Creates a sanitized copy.
hashing.py
Calculates cryptographic hashes.
reporter.py
Generates security findings.
cli.py
Provides the command-line interface.
๐ Example Scanner Output
A useful defensive scanner could produce:
========================================
PDF SECURITY ANALYSIS
========================================
File: invoice.pdf
SHA256: <hash>
[+] PDF structure: Valid
[+] Pages: 4
[+] Metadata: Extracted
[!] JavaScript: Detected
[!] OpenAction: Detected
[+] Embedded files: None
[+] Launch actions: None
[+] URI actions: 2
Risk Assessment:
HIGH
Recommendation:
Sanitize document before distribution.========================================
PDF SECURITY ANALYSIS
========================================
File: invoice.pdf
SHA256: <hash>
[+] PDF structure: Valid
[+] Pages: 4
[+] Metadata: Extracted
[!] JavaScript: Detected
[!] OpenAction: Detected
[+] Embedded files: None
[+] Launch actions: None
[+] URI actions: 2
Risk Assessment:
HIGH
Recommendation:
Sanitize document before distribution.The output should clearly distinguish:
Detected IndicatorDetected Indicatorfrom:
Confirmed ExploitConfirmed Exploit๐ง Risk Scoring
A scanner can assign risk based on multiple indicators.
For example:
JavaScript +2
OpenAction +3
Launch +4
Embedded File +2
Suspicious URI +1
Malformed Objects +3JavaScript +2
OpenAction +3
Launch +4
Embedded File +2
Suspicious URI +1
Malformed Objects +3Then:
0โ2 โ Low
3โ5 โ Medium
6โ8 โ High
9+ โ Critical0โ2 โ Low
3โ5 โ Medium
6โ8 โ High
9+ โ CriticalHowever, these values should be treated as an internal heuristic rather than a universal vulnerability standard.
Context is essential.
๐ Static vs Dynamic Analysis
There are two major approaches.
Static Analysis
Inspect the PDF without executing its content.
Advantages:
- Safer
- Fast
- Easy to automate
- Suitable for large document volumes
Limitations:
- Can miss behavior hidden behind complex structures
- May produce false positives
Dynamic Analysis
Open the document inside a controlled analysis environment and monitor behavior.
Potential observations include:
Process creation
Network connections
File creation
Registry changes
Unexpected child processesProcess creation
Network connections
File creation
Registry changes
Unexpected child processesDynamic analysis can provide more behavioral information, but it requires substantially stronger isolation.
๐ก๏ธ Enterprise PDF Security Architecture
Organizations processing large volumes of documents can implement:
Email / Upload
โ
โผ
File Gateway
โ
โผ
PDF Scanner
โ
โโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โผ โผ
Clean Suspicious
โ โ
โผ โผ
Delivery Quarantine
โ
โผ
CDR
โ
โผ
Sanitized File
โ
โผ
Re-scanEmail / Upload
โ
โผ
File Gateway
โ
โผ
PDF Scanner
โ
โโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โผ โผ
Clean Suspicious
โ โ
โผ โผ
Delivery Quarantine
โ
โผ
CDR
โ
โผ
Sanitized File
โ
โผ
Re-scanThis approach can help prevent potentially dangerous documents from reaching employees directly.
๐ง PDF Security in Email
Email is a common delivery mechanism for malicious documents.
A secure email gateway can analyze:
Message
โ
โโโ Sender
โโโ Authentication
โโโ URLs
โโโ Attachments
โ โ
โ โผ
โ PDF Analysis
โ
โโโ ReputationMessage
โ
โโโ Sender
โโโ Authentication
โโโ URLs
โโโ Attachments
โ โ
โ โผ
โ PDF Analysis
โ
โโโ ReputationCombining email authentication with attachment analysis provides stronger defense than relying on either control alone.
๐จ Common Mistakes
Mistake #1 โ Trusting File Extensions
A file named:
invoice.pdfinvoice.pdfshouldn't automatically be considered safe.
The actual file format should be validated.
Mistake #2 โ Opening Suspicious Files Directly
Don't open unknown documents on machines containing sensitive information.
Use isolation.
Mistake #3 โ Relying on One Scanner
No static scanner detects everything.
Use layered analysis.
Mistake #4 โ Automatically Calling Every Finding Malware
A PDF containing JavaScript isn't necessarily malicious.
Always distinguish indicators from confirmed malicious behavior.
Mistake #5 โ Modifying the Original Evidence
Keep:
Original
+
Hash
+
Analysis Results
+
Sanitized CopyOriginal
+
Hash
+
Analysis Results
+
Sanitized CopyNever overwrite the original during forensic analysis.
๐ PDF Security Checklist
- Validate the actual file format
- Calculate SHA-256 hash
- Extract metadata
- Inspect PDF objects
- Check for JavaScript
- Check automatic actions
- Check launch actions
- Check embedded files
- Check external URI actions
- Analyze suspicious attachments separately
- Sanitize high-risk documents
- Re-scan sanitized output
- Keep the original artifact
- Use isolated analysis environments
- Document findings
๐ฅ Why PDF Sanitization Matters
Traditional antivirus detection asks:
"Is this file malicious?"
A CDR-oriented security model asks:
"What functionality does this document actually need?"
If the answer is:
Text
Images
FormattingText
Images
Formattingthen there may be little reason to preserve:
JavaScript
Embedded executables
Automatic actions
External launch behaviorJavaScript
Embedded executables
Automatic actions
External launch behaviorRemoving unnecessary functionality can reduce the attack surface.
๐ Final Thoughts
PDF security is often underestimated because PDFs appear to be simple documents.
Under the hood, however, they can contain complex structures and active functionality.
A robust defensive workflow therefore looks like:
๐ Receive
โ
๐ Inspect
โ
๐ง Analyze
โ
๐จ Detect Suspicious Features
โ
๐งน Sanitize
โ
๐ Re-scan
โ
๐ Report
โ
โ
Safely Distribute๐ Receive
โ
๐ Inspect
โ
๐ง Analyze
โ
๐จ Detect Suspicious Features
โ
๐งน Sanitize
โ
๐ Re-scan
โ
๐ Report
โ
โ
Safely DistributeThe most important lesson is:
Don't blindly trust documents just because they have a familiar file extension.
Security teams should combine:
Static analysis + sandboxing + CDR + email security + endpoint protection + user awareness.
A PDF exploit scanner and patcher can become a valuable layer in that defense, particularly when it focuses on safe analysis, transparent findings, document sanitization, and verification after remediation.
๐ Responsible Security Notice
This article is intended for defensive cybersecurity research, malware-analysis laboratories, CTFs, document-security testing, and authorized penetration-testing environments.
Do not use malicious documents against unsuspecting users or systems. Never open potentially dangerous PDFs on production machines without appropriate security controls.
Scan suspicious documents. Sanitize aggressively. Preserve evidence. Protect users. ๐จ๐๐