Summary
A command injection flaw in Atril Document Viewer lets attackers execute arbitrary code when a user clicks a crafted link inside a malicious PDF file.
By abusing unescaped link-destination fields and GTK module loading, a single polyglot PDF/ELF file can achieve configuration-independent code execution on affected MATE desktop systems.
Affected context
This vulnerability occurs in Atril when handling hyperlink actions embedded in PDF documents.
It becomes relevant when:
- Users open untrusted or attacker-crafted PDFs
- The PDF contains specially crafted link-destination fields
- The environment uses default Atril configurations without additional hardening
Under these conditions, Atril's link handling logic may interpret attacker-controlled data as part of a shell-processed command line.
Exploit preconditions
- Attack surface: User interaction with Atril via opening and clicking links in PDF documents
- Required access: Ability to deliver a malicious PDF to the target (e.g., email, download, file share)
- User action: The user must open the document in Atril and click the crafted link once
- Trigger point: Atril's
ev_spawnbuilds a command line from PDF link-destination fields and passes it tog_app_info_create_from_commandline - Why exploitation is possible: Link-destination fields are not safely quoted or escaped (e.g., missing
g_shell_quote), allowing injection of arguments like--gtk-module=PATHthat are later interpreted and cause GTK todlopen()attacker-controlled shared libraries.
Why this happens
The underlying bug class maps to command and argument injection (CWE-77 and CWE-88), combined with loading untrusted code via external modules (CWE-829).
Atril constructs a shell-parseable command line from data originating in PDF link-destination fields, treating this untrusted input as trusted command components.
Because the input is not passed through robust quoting, escaping, or structured argument APIs, an attacker can smuggle additional parameters into the command line.
GTK's module loading (--gtk-module=PATH) then resolves and loads attacker-provided shared libraries, turning the injected argument into arbitrary code execution during initialization.
Potential impact
- Arbitrary code execution in the context of the user running Atril
- Installation of backdoors or persistence mechanisms on the user's account
- Execution of arbitrary system commands, including data theft or destructive actions
- Lateral movement within the user's session (e.g., accessing other applications or files)
- Potential escalation of impact if combined with local privilege escalation vulnerabilities
General mitigation guidance
Pattern-based mitigations for this class of vulnerability focus on reducing trust in user-controlled data and avoiding shell-like command construction:
- Use structured APIs that accept argument arrays instead of constructing shell-parsed command lines from strings.
- Apply strict quoting/escaping (e.g.,
g_shell_quoteequivalents) to any data that must appear in command lines, and prefer avoiding shell interpretation entirely. - Treat document-embedded metadata (such as PDF link-destination fields) as untrusted input and validate or constrain allowed formats before use.
- Limit or sandbox dynamic module loading paths so user-controllable fields cannot point directly to loadable shared libraries.
- Apply least-privilege principles so that, even if document viewers are compromised, their ability to affect the wider system is reduced.
How teams detect issues like this
High-level detection approaches for similar issues typically include:
- Static analysis rules that flag string-based command construction and calls to APIs that accept command lines instead of argument vectors.
- Code review checklists that require scrutiny of any use of user-controlled document fields in process spawning, module loading, or configuration options.
- Security-focused linters for GUI and document applications that detect uses of
g_app_info_create_from_commandlineand related APIs with untrusted input. - Policy enforcement in CI/CD pipelines to block merges when patterns like shell-parsed command lines or unvalidated module paths are detected.
- Targeted tests where fuzzed or crafted documents exercise hyperlink and action handling paths to observe unexpected argument parsing or dynamic loading behavior.

