Running an Entire LLM Inside a PDF: The Engineering Breakthrough and Cybersecurity Implications

August 17, 2026
4 mins
Running an Entire LLM Inside a PDF: The Engineering Breakthrough and Cybersecurity Implications

Lately, we have seen incredible proof-of-concept experiments of running AI models on microcontrollers with less than 1MB of memory, running models inside Windows 98 and now thanks to developer Evan Zhou who has successfully ran a complete Large Language Model (LLM) entirely inside a PDF file without any external server or internet connection.

How It Works

Traditionally, PDFs are viewed as static files meant for text, books or images. However, by leveraging PDF execution capabilities, embedded JavaScript and cross-compilation. It is became possible to run local inference:

  • The Inference Engine: Running an LLM requires an inference engine. While llama.cpp is a fast C++ inference engine where PDF readers cannot execute native C++ binaries directly.

  • Emscripten & asm.js: The developer solved this by using the Emscripten toolchain to cross-compile the C++ source code of llama.cpp into asm.js a highly optimized subset of JavaScript that runs inside a virtual machine close to native binary speed.

  • Model Weights Storage (Base64): The GGUF quantized binary weights of the model are converted into text strings via Base64 encoding and stored directly within the PDF's internal data streams.

When a user opens the PDF and interacts with an interactive form (AcroForm) or triggers an /OpenAction, the integrated JavaScript engine reads the Base64 string decodes it into an ArrayBuffer in system RAM and initializes the asm.js inference engine to process matrix multiplications and stream tokens back into the PDF form in real time.

Cybersecurity Implications

While these experiments push the boundaries of edge computing and resource optimization but they also open up new attack vectors and security concerns:

  1. Weaponized Document Exploits: If complex logic like an LLM can be packed into a PDF, malicious actors can leverage similar execution pipelines to embed obfuscated payloads, evasion tools or autonomous phishing agents inside seemingly harmless documents.

  2. Bypassing Email Gateways and Scanners: Traditional security gateways scan PDFs for known malicious signatures or standard script tags. Heavy obfuscation using techniques like Base64-encoded binary streams and compiled asm.js can make static analysis significantly harder.

  3. Client-Side Resource Exhaustion (DoS): Running matrix multiplications and neural network inference locally inside a PDF reader consumes massive amounts of CPU and RAM. Attackers could craft documents that freeze, crash, or exhaust the resources of target machines simply by opening a file.