Summary
Docling's EasyOCR model download feature previously extracted ZIP archives without validating internal file paths, allowing Zip Slip-style directory traversal.
If an attacker can tamper with the model source, they may write files outside the intended directory, enabling code execution, backdoor installation, or system corruption wherever the process has write access.
Affected context
The vulnerability occurs when Docling downloads and extracts EasyOCR model archives from external sources using ZIP extraction logic that does not sanitize member paths.
It is relevant in environments where:
- Model files are fetched over the network or from untrusted locations
- The downloading process runs with permissions to write into application or system directories
- Integrity of the archive source can be influenced via supply chain compromise, DNS spoofing, or man-in-the-middle attacks
Exploit preconditions
- Attack surface: Network-exposed or remotely accessible model download mechanism used by Docling's EasyOCR integration.
- Required access: Ability to control or modify the ZIP archive delivered to the application, typically via compromised hosting, package registry, DNS spoofing, or MITM on the download channel.
- Trigger point: Invocation of the EasyOCR model download and extraction routine, which automatically unpacks ZIP contents.
- Why exploitation is possible: Archive entries are extracted using file paths as provided, without normalizing or checking for
../or absolute paths, allowing files to be written outside the intended model directory.
Why this happens
This issue stems from unsafe handling of file paths during ZIP archive extraction, aligning with CWE-22 (Improper Limitation of a Pathname to a Restricted Directory).
The extraction logic trusts the paths embedded in archive entries and writes them directly to disk, without enforcing a confined root directory or rejecting traversal sequences such as ../ or absolute paths.
As a result, a malicious archive can escape the target folder and overwrite arbitrary files in locations writable by the process, converting a file handling bug into a potential code execution or persistence vector.
Potential impact
- Malicious overwrite of Python modules or application files that may be loaded for code execution
- Replacement or modification of system binaries or scripts in writable locations
- Installation of persistent backdoors via altered startup scripts, cron jobs, or SSH keys
- Corruption of configuration files, logs, or model artifacts used by downstream components
- Escalation from application compromise to broader system-level compromise depending on process privileges
General mitigation guidance
Effective mitigation focuses on confining archive extraction and reducing trust in external model sources.
Recommended patterns include:
- Normalizing and validating each archive member path before extraction, ensuring it stays within a designated base directory and rejecting traversal or absolute paths
- Using high-level archive utilities or helper functions that enforce safe extraction semantics by default
- Treating remote model archives as untrusted input and applying integrity checks (signatures, checksums) before use
- Running the downloading and extraction logic with least-privilege accounts and isolated directories that cannot affect application or system code
- Separating model storage from executable paths so that overwriting a model cannot directly change runtime behavior
How teams detect issues like this
Detection typically involves a mix of code-centric and operational checks:
- Static analysis rules that flag ZIP or archive extraction routines lacking path normalization and restricted output directories
- Code review checklists that require verification of handling for
../sequences, absolute paths, and symlink entries during archive processing - Security policies that mandate the use of vetted helper utilities for archive extraction rather than ad hoc file path handling
- Runtime monitoring for unexpected file changes outside the intended model directories following model download operations
- Automated scanning tools configured to look for Zip Slip patterns in repository code, CI pipelines, or dependency updates

