An EPUB packages web content (HTML, CSS, SVG, JavaScript and the files they use) in one container, so its security and privacy problems are those of web content, plus a few of its own. EPUB 3.3 (the Core specification) has a section for authors, EPUB Reading Systems 3.3 has one for the programs that open books. Both are non-normative except where they repeat a MUST or SHOULD stated elsewhere. This page summarises them and says what the explorer reports about a file.
How a publication can harm or track a reader
| Vector | The risk | What the explorer reports |
|---|---|---|
| Remote resources | Audio, video and fonts (and anything a script fetches) may live outside the container. They can be swapped after publication, so a check at distribution proves nothing later, and every request tells the server who is reading and when. | Each remote reference in a content document, a style sheet or the manifest; remote resources that are not audio, video or fonts; http where https is advised; the remote-resources manifest property missing or unused. |
| Links to the web | An external link opens a site the author may not control: the target can be hijacked when its domain lapses, a tracking identifier in the address profiles the reader, and a malicious site can attack the browser. | Links to files inside the container are checked (the file and the fragment must exist); an external link is never followed. |
| Malicious content in the container | Scripts, forms that send data to a third party, and files that exploit the reading system. Third-party games and quizzes cannot always be vetted. Symbolic links and aliases in a container can point at files outside it. | script elements, event-handler attributes and forms (the scripted property), embedded objects, and manifest or content references that leave the container. |
| Scripts with network access | A script that can reach the network can collect information about the reader, try to read local files or storage, phish (a page made to look like a trusted site) and inject content from other sites. | Which documents are scripted; whether they also reference remote resources. |
| Digital rights management | Encrypting and decrypting a book can send the reader’s identity, their shop and their reading choices to third parties. Publishers who must use it should prefer schemes that do not. | Every encrypted file with its algorithm and key information (the container page); font obfuscation is not encryption and sends nothing. |
| Falsified publication information | A book can claim a title, an author, an identifier and a publisher that are not true, so that its forms and links look trustworthy. A reading system cannot always check, because EPUB has no mandatory way to sign a book. | The package metadata as written, and any XML-DSig signatures in META-INF/signatures.xml, verified against the certificate in the file (the certificate’s trust is not checked). |
| Reading habits and profiles | Collecting what a reader reads, or inferring their needs from metadata such as accessibility preferences, without permission can violate their privacy even if it is for internal use. | Nothing: it concerns what a reading system does, not what a file contains. |
What reading systems should do
- Treat every book as untrusted: it may carry scripts that attack local storage or the network, resources that exploit flaws in the reading system or the operating system, and links to malicious sites. Sideloaded books need the reader’s consent for network access and scripts.
- Expose as little as possible in requests for remote resources and when links are followed: no tracking identifiers, no details of the reader’s environment.
- Secure user-generated content inside the book (text areas and other interactive parts) and the persistent data a reader stores, especially personal information.
- Say what data is collected about the reader and their reading, and obtain consent; anonymise data collected for the operation of the service. Do not profile readers from their reading or from metadata such as accessibility preferences.
- Content processors (shops, libraries, distributors) should check books on ingestion for malicious content (virus scans, remote resources, external links) as well as validating them, and take care when processing XML.
- Do not build support for deprecated features before weighing how rarely content uses them.
The Reading Systems specification points out that there is no standard way of signing an EPUB, so a reading system cannot always tell
whether a book was changed between its author and the device. The container does define XML signatures
(META-INF/signatures.xml), but a book need not have one and the specification does not require reading systems to check it.
Under-implemented and deprecated features
EPUB 3.3 marks features that reading systems implement poorly as under-implemented (authors may use them; a conformance
checker should note them but must not call them errors) and features it no longer recommends as deprecated or
legacy (kept for EPUB 2 compatibility). The explorer reports the deprecated ones it can see in a file: epub:switch and
epub:trigger, a deprecated accessibility term, meta-auth, and the discouraged
base, rp and embed elements, as recommendations and not as errors.
What opening an EPUB in the explorer does
The explorer reads the file in your browser. Nothing is uploaded. It does not run scripts in the book, does not follow links or load remote resources, and draws only pictures held in the file. A password or key you give for an encrypted book is used for that book only and is not kept.