PDF Metadata Leaks, Incremental %%EOF Forensics & Unicode Trojan Source Analysis
Documents exchanged by investigative journalists, graduate researchers, and software engineers carry two largely invisible threat planes: append-only binary leftovers inside ISO 32000-2 PDF structures (leaking deleted prose, workstation usernames, and active /OpenAction triggers) and non-printing UTF-8 anomalies spanning CVE-2021-42574 bidirectional overrides, TR39 homoglyphs, and Plane-14 steganographic watermarks.
How do ISO 32000-2 incremental updates (%%EOF) preserve deleted PDF edits and hidden history?
Direct answer: When a desktop viewer or signing utility performs an incremental PDF save under ISO 32000-2, it leaves original body objects completely untouched and appends new indirect objects plus a trailing cross-reference section pointing backward via /Prev. Every additional %%EOF trailer marks a surviving historical snapshot inside raw file bytes.
Students submitting double-blind peer reviews, whistleblowers distributing redacted court filings, and attorneys exchanging marked-up deal memos frequently make a fatal visual assumption: because a PDF viewer renders only the latest cross-reference tree starting from the final trailer, prior revisions must no longer exist inside the file. In reality, append-only incremental updates were designed by Adobe and codified in ISO 32000-1 and ISO 32000-2 precisely so electronic signatures and rapid marginal annotations could update a 50-megabyte document in milliseconds without rewriting earlier object offsets (which would invalidate byte-range cryptographic signatures covering prior revisions).
Counting raw %%EOF delimiters inside a local Uint8Array buffer immediately reveals multi-revision lineage. A cleanly flattened single-pass export typically exhibits exactly 1 trailing %%EOF marker (though linearized "Fast Web View" PDFs contain 2 trailers for page-one streaming). Whenever a non-linearized PDF carries 3 or more %%EOF footers, earlier unreferenced object streams remain recoverable by jumping backward along chained /Prev byte offsets—exposing pre-redacted names, earlier draft numbers, author login handles inside superseded /Info dictionaries, and deleted review comments. Local verification on /tools/pdf-metadata-inspector surfaces this revision count in browser RAM before a single byte crosses the network.
Which PDF dictionaries expose author identity, installed fonts, and active /JavaScript vectors?
Direct answer: Beyond visible page typography, ISO 32000-2 PDFs embed attribution and execution hazards across five binary structures: the document /Info trailer dictionary, embedded RDF/XML XMP /Metadata streams, active triggers (/JavaScript, /OpenAction, /AA, /Launch), outbound /URI link targets, and embedded /BaseFont descriptor names.
| PDF Binary Structure | Key Dictionary / XML Tags | Forensic Leak / Risk Exposure | Remediation Action |
|---|---|---|---|
| /Info Trailer Dictionary | /Author /Creator /Producer /CreationDate | Exposes local OS account name, Word/LaTeX build path, and timezone offsets | Strip or normalize fields before redistributing |
| /Metadata XMP Stream | <dc:creator> <xmp:CreatorTool> <xmpMM:DocumentID> | Survives /Info deletion; links document versions via persistent UUIDs | Inspect raw XML stream; strip XMP packets entirely |
| Incremental %%EOF Chain | %%EOF · /Prev <offset> · xref | Retains superseded text, old metadata, and black-box annotation layers | Re-distill / linearize into clean 1-revision binary |
| Active Execution Flags | /JavaScript /JS /OpenAction /AA /Launch | Triggers embedded AcroJS or external shell prompts automatically upon open | Quarantine untrusted files; disable viewer JS |
| Resource & Action Links | /URI /BaseFont /EmbeddedFiles | Phishing/tracking URLs, corporate custom fonts, or attached zip/script payloads | Audit every /URI target and attachment object offline |
Consider how /OpenAction and /AA (Additional Actions) turn an ordinary invoice or academic manuscript into an active execution container. Under ISO 32000-2 Sections 12.6 and 14.3, a document catalog may specify an /OpenAction entry evaluated automatically the instant a PDF opens, or /AA triggers attached to specific page-enter and field-focus events. Malicious attachments pair /OpenAction with /JS or /Launch dictionaries (sometimes obfuscated via hex escapes like /J#61vaScript using PDF name-syntax hex decoding!) or plant tracking /URI beacons that issue DNS/HTTP requests when opened. Meanwhile, even benign academic submissions frequently forget to purge /Producer strings revealing exact corporate print servers or /CreationDate strings exposing timezone offsets (such as D:20261125021400-08'00').
Two additional PDF structures deserve close forensic attention during pre-publication audits: compressed object streams (/ObjStm and /Type /XRef introduced in PDF 1.5 and standardized in ISO 32000-2) and subsetted /BaseFont tables. Modern exporters frequently deflate indirect dictionaries inside FlateDecode streams, meaning naive plain-text grep commands over raw PDF bytes miss compressed /Author entries or hidden /URI annotations unless the parser either scans Flate streams or inspects uncompressed catalog trailers and font descriptors. Even when text metadata is wiped cleanly, embedded font subset names (such as six-character uppercase tag prefixes coupled with specialized corporate typefaces or regional CJK/Arabic fallback fonts) reveal the authoring operating system and software build toolchain. Auditing fonts alongside /Info, XMP packets, and %%EOF counts inside /tools/pdf-metadata-inspector surfaces these artifacts deterministically inside browser memory.
%PDF-2.0
% Incremental leak & active vector excerpt (raw byte stream)
4 0 obj << /Author (j.smith_internal) /Producer (Internal Build Box 192.168) >> endobj
5 0 obj << /Type /Catalog /OpenAction << /S /JavaScript /JS (app.alert('Beacon');) >> >> endobj
trailer << /Size 6 /Root 5 0 R /Info 4 0 R >>
startxref
148
%%EOF
% --- User edits & clicks "Save" instead of clean re-export ---
4 0 obj << /Author (Anonymous) /Producer (Redacted) >> endobj
trailer << /Size 6 /Root 5 0 R /Info 4 0 R /Prev 148 >>
startxref
412
%%EOF <-- Object 4 from Revision 1 ("j.smith_internal") remains 100% readable at byte 28!How does CVE-2021-42574 (Trojan Source) hide malicious logic inside visually valid source code?
Direct answer: Described by Boucher and Anderson (USENIX Security 2023) and tracked as CVE-2021-42574, Trojan Source exploits Unicode UAX #9 bidirectional formatting characters inside comments or string literals. Because compilers evaluate logical token sequence while editors obey visual BiDi reordering, an injected U+202E (RLO) reverses apparent control flow to deceive code reviewers.
To grasp why standard syntax highlighters miss the attack, distinguish logical codepoint storage from visual glyph rendering. Unicode Standard Annex #9 (UAX #9) defines explicit directional embedding, override, and isolate characters designed so right-to-left scripts such as Arabic or Hebrew mix cleanly with left-to-right prose inside a single paragraph. When left-to-right programming languages (C, C++, Rust, Swift, Python, JavaScript, Go) allow arbitrary UTF-8 codepoints inside string constants and inline comments, an attacker can insert Right-to-Left Override (U+202E) or Right-to-Left Isolate (U+2067) inside a comment without tripping the compiler’s lexer—never closing the scope before the line ends, or strategically pairing Pop Directional Isolate (U+2069) / Pop Directional Formatting (U+202C) so human reviewers visually read an early return or permission check that actually sits harmlessly inside a comment!
// CVE-2021-42574 Logical Bytes vs Visual BiDi Deception + Astral Codepoint Scanner
// Logical byte sequence inside UTF-8 source:
// const isAdmin = false; /* [RLI U+2067] [LRI U+2066] if (isAdmin) { [PDI U+2069] [PDI U+2069] */
// Visually reordered in naive BiDi UI to look like an active if (isAdmin) block or early return!
function scanUnicodeThreats(input) {
const anomalies = [];
let utf16Idx = 0;
for (const ch of String(input || '')) { // Iterates full Unicode scalar values (handles surrogates!)
const cp = ch.codePointAt(0);
const isBidi = (cp >= 0x202A && cp <= 0x202E) || (cp >= 0x2066 && cp <= 0x2069) ||
cp === 0x061C || cp === 0x200E || cp === 0x200F;
const isZeroWidth = (cp >= 0x200B && cp <= 0x200D) || cp === 0xFEFF || cp === 0x2060;
const isPlane14Tag = cp >= 0xE0000 && cp <= 0xE007F;
if (isBidi || isZeroWidth || isPlane14Tag) {
anomalies.push({ utf16Idx, hex: 'U+' + cp.toString(16).toUpperCase().padStart(4, '0') });
}
utf16Idx += ch.length;
}
return anomalies;
}How do TR39 homoglyphs, Plane-14 tags, and ZWSP bitstreams hide payloads in UTF-8 text?
Direct answer: Beyond bidirectional reordering, attackers and tracking pipelines embed invisible payloads using zero-width format characters (U+200B–U+200D), astral Plane-14 tag glyphs (U+E0000 + ASCII), variation selectors (U+FE00–U+FE0F), and cross-script Cyrillic or Greek confusables cataloged in Unicode Technical Standard #39—surviving clipboard copy-paste invisibly until audited at codepoint level.
| Unicode Threat Class | Exact Codepoint Range | Security / Forensic Impact | Standard & Tool |
|---|---|---|---|
| BiDi Overrides / Isolates | U+202A..202E, U+2066..2069, U+061C, U+200E..200F | Visual token inversion (Trojan Source code/filename spoofing) | CVE-2021-42574 · UAX #9 |
| Zero-Width Format Controls | U+200B, U+200C, U+200D, U+FEFF, U+2060 | Binary leaker watermarks & regex word-boundary bypasses | Unicode TR36 · /tools/watermark-inspector |
| Plane-14 ASCII Tags | U+E0000..U+E007F (4-byte UTF-8) | Invisible hidden prompt-injection instructions inside markdown | /tools/unicode-regex-forensics |
| Mixed-Script Confusables | Cyrillic U+0430/0435/043E/0440 · Greek U+03B1/03BF | Spoofed domain links, shadow variable names, plagiarism evasion | Unicode UTS #39 Confusables |
Notice how Unicode TR36 and UTS #39 confusables intersect directly with academic integrity and package supply chains. Substituting a single Cyrillic small letter а (U+0430) or Ukrainian і (U+0456) inside an imported package identifier, DNS hostname, or legal clause renders identically in almost every sans-serif font, yet breaks literal ASCII equality and defeats naive plagiarism shingles. When inspecting suspicious text or LLM outputs, /tools/unicode-regex-forensics decomposes every non-ASCII codepoint with UTF-8 and UTF-16 hex offsets while offering 1-click stripping and skeleton normalization, complementing /tools/watermark-inspector for full media C2PA + steganographic text verification.
Why do defensive regex sanitizers trigger catastrophic ReDoS backtracking on hostile inputs?
Direct answer: Backtracking NFA regex engines (used in JavaScript, Python re, and PCRE) suffer exponential worst-case runtime O(2n) whenever a pattern combines nested quantifiers such as (a+)+$ or overlapping alternation branches like ([a-z]+|[a-z0-9]+)+$ against an almost-matching input terminated by one illegal character.
Ironically, engineers attempting to sanitize untrusted metadata strings or validate complex URLs regularly introduce Denial-of-Service bugs inside their security middleware. Suppose an input sanitizer validates emails or Markdown tags with a nested quantifier pattern on a 35-character string ending in a single punctuation mismatch: a backtracking engine tests roughly 235 ≈ 34 billion partitionings before failing, locking Node.js event loops or browser worker threads indefinitely.
Mitigating ReDoS before deploying regex validators requires three disciplined engineering rules: (1) run static pattern auditing for star-height ≥ 2 (quantifiers nested inside quantified groups) and ambiguous disjunctions over overlapping character classes; (2) cap input slice lengths and reject redundant outer wildcards by anchoring explicit negated character classes (such as [^/]+ instead of .*); and (3) prefer linear-time finite-automaton engines (such as RE2 or Rust regex) or bounded character-by-character state machines whenever parsing arbitrary untrusted files.
Bringing both forensic surfaces together yields a repeatable four-step sanitization checklist for investigative newsrooms, university peer reviewers, and software maintainers before releasing any artifact publicly. First, inspect raw binary trailers, /Info fields, XMP XML, /OpenAction dictionaries, and /URI links locally with /tools/pdf-metadata-inspector; if the %%EOF count exceeds one (on a non-linearized export) or sensitive fields persist, re-distill the pages into a single flattened archival PDF/A stream rather than saving incrementally. Second, strip any black redaction rectangles created with simple drawing overlays—true redaction must delete underlying PDF text operators rather than covering glyphs with opaque rectangles. Third, pass copied prose, Markdown notes, or pull-request source patches through /tools/unicode-regex-forensics to expose CVE-2021-42574 BiDi overrides, Plane-14 tag injections, TR39 homoglyphs, and unsafe backtracking patterns. Fourth, whenever distributing image figures or verifying published visuals alongside documents, cross-check container chunks and invisible bitstreams via /tools/watermark-inspector and log the clean output’s SHA-256 hash so every published artifact carries an auditable integrity baseline.
Primary PDF, Unicode & Security References
- PDF Association — ISO 32000-2 (PDF 2.0) Standard & Errata Resources
- U.S. Library of Congress — PDF 2.0 (ISO 32000-2:2020) Format Specification Profile
- Unicode Technical Report #36 — Unicode Security Considerations
- Unicode Technical Standard #39 — Unicode Security Mechanisms (Confusables)
- Unicode Standard Annex #9 — Unicode Bidirectional Algorithm (UAX #9)
- NIST National Vulnerability Database — CVE-2021-42574 (Trojan Source BiDi)
- Boucher & Anderson (USENIX Security 2023) — Trojan Source: Invisible Vulnerabilities
- OWASP Foundation — Regular Expression Denial of Service (ReDoS)
PDF Metadata & Unicode Forensics FAQ
- Why does hitting ordinary "Save" in a PDF editor fail to erase deleted paragraphs or author history?
- Under ISO 32000-2 Section 7.5.6, incremental PDF saves append newly modified objects, an updated cross-reference table, a /Prev byte offset pointer, and a fresh %%EOF trailer at the end of the file without overwriting earlier byte ranges—preserving previous /Info dictionaries, removed annotations, and superseded page streams verbatim.
- What distinguishes PDF /Info dictionaries from embedded XMP XML metadata streams?
- The legacy PDF /Info trailer dictionary holds terse key-value pairs (/Author, /Creator, /Producer, /CreationDate), whereas an embedded /Metadata stream stores structured RDF/XML under the Extensible Metadata Platform (<xmp:CreatorTool>, <dc:creator>, <xmpMM:History>). Scrubbing only /Info often leaves identical username, machine OS, and revision UUID leaks intact inside XMP.
- How does CVE-2021-42574 (Trojan Source) exploit Unicode bidirectional controls in code and prose?
- Compilers parse source files in logical memory order, while code editors and review UIs render lines visually according to the Unicode Bidirectional Algorithm (UAX #9). Injecting unmatched LRE/RLE/RLO overrides (U+202A–U+202E) or isolates (U+2066–U+2069) reverses displayed tokens so an authorization check appears active even when commented out logically.
- Why do JavaScript charCodeAt() loops miss Plane-14 Unicode steganographic watermarks?
- JavaScript strings expose UTF-16 code units rather than Unicode scalar values. Astral Plane-14 Tag codepoints (U+E0000–U+E007F) exceed 0xFFFF and split into high/low surrogate pairs under charCodeAt(), whereas iterating via for (const ch of str) and reading ch.codePointAt(0) decodes full 21-bit codepoints accurately.