Summary
Kroki's TikZ backend does not block several native TeX file-reading primitives when safe mode is enabled. An unauthenticated requester may submit crafted LaTeX through the TikZ or generic diagram API and cause the renderer to read files accessible to its container user, with their contents potentially returned in the SVG.
Affected context
The issue affects Kroki deployments using the TikZ backend with safe mode enabled before the relevant guard fully restricts TeX file operations. The guard blocks \verbatiminput but allows other native file-reading primitives, while TeX Live's permissive openin_any setting may permit access to files available to the renderer's container user. Disabling shell escape does not prevent these file reads.
Exploit preconditions
- Attack surface: The TikZ endpoint (
POST /tikz/svg) or the generic diagram API. - Required access: No authentication is required, according to the vulnerability description.
- Trigger point: Submission of a TikZ/LaTeX diagram that the renderer processes.
- Why exploitation is possible: Safe-mode filtering does not cover all native TeX file-reading primitives, and the renderer can access files permitted by its container and TeX configuration.
Why this happens
The TikZ guard blocks a limited set of file-reading constructs rather than enforcing a complete restriction on TeX file access. As a result, native primitives such as \openin, \read, \input, and \include can access files within the renderer's permitted filesystem scope, and the resulting content can appear in rendered output. This is associated with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because access is not adequately confined to an intended set of files. The -no-shell-escape option limits shell execution but does not restrict these native file operations.
Potential impact
- An attacker could disclose configuration files, credentials, private keys, or mounted secrets accessible to the container user.
- Sensitive information could be embedded in the SVG response and exposed to the requester.
- Disclosure could support follow-on compromise of connected services or accounts.
General mitigation guidance
Defensive patterns include restricting TeX file access rather than relying on a narrow command guard, and using strict filesystem allowlists or equivalent sandboxing for renderer inputs. Configure TeX to deny access beyond explicitly required paths, minimize sensitive files mounted into the container, and run the renderer with least-privilege permissions. Treat submitted diagram text as untrusted input, and do not rely on shell-escape restrictions as a substitute for file-access controls.
How teams detect issues like this
- Use static analysis and code review to identify incomplete filters around TeX primitives and other file-reading constructs.
- Review renderer and TeX configuration for permissive filesystem access, including
openin_anysettings and container mounts. - Monitor diagram requests and renderer output for unexpected file references or sensitive content, while avoiding unnecessary logging of submitted secrets.
- Enforce policies that restrict renderer filesystem access and validate those restrictions in security testing.

