CVE-2015-8557
Critical · 9.0CVSS
9.0
EPSS
6.7%
Published
Jan 8, 2016
CISA due date
—
Cloudanix analysis
A flaw in a popular code-highlighting tool lets attackers run any commands they want on the computer whenever someone tries to display code with a specially crafted font name.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- Moderate
- Impact
- Remote Code Execution
- Component
- Library
- Class
- Command Injection
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
The vulnerable function passes an attacker-controlled font name containing shell metacharacters directly into a shell command without sanitization, enabling arbitrary command execution on the host running Pygments.
Why it matters to the business
Successful exploitation grants remote attackers full control over affected systems, allowing theft of source code, intellectual property, or customer data, disruption of services that rely on syntax highlighting, and potential lateral movement within the environment.
How an attack unfolds
An attacker supplies a malicious font name containing shell metacharacters to any code path that invokes the affected formatter with a user-supplied or attacker-influenced font parameter; the unsanitized value reaches a shell invocation that executes the injected commands.
How to fix it
Upgrade Pygments to a version newer than 2.0.2 that contains the fix for this command-injection flaw; if immediate upgrade is not possible, disable or avoid the img formatter and any code paths that accept untrusted font names.
How to confirm the fix worked
Confirm the installed Pygments version is greater than 2.0.2, review application code and configuration to ensure no user-controlled font names reach the img formatter, and test that previously vulnerable input no longer results in command execution.
Typical attack path
- Identify an application or service that uses Pygments to render code or images and accepts font names from user input or configuration.
- Craft a font name containing shell metacharacters that will be passed to the vulnerable _get_nix_font_path function.
- Trigger the rendering path so the malicious font name reaches the shell command execution.
- Execute arbitrary commands to establish a foothold, exfiltrate data, or install additional tools.
How to detect it
Review web-application and Python application logs for unexpected shell commands or error messages generated during image or code formatting; look for child processes spawned by Python interpreters that import pygments.formatters.img.
What your security team should do
- Prioritize patching Pygments across all environments that render user-supplied or external code snippets.
- Inventory applications and libraries that depend on Pygments to determine exposure breadth.
- Implement input validation or sandboxing around any font-name parameters passed to Pygments.
- Monitor for unusual process spawns originating from Python processes that import Pygments.
The record
The FontManager._get_nix_font_path function in formatters/img.py in Pygments 1.2.2 through 2.0.2 allows remote attackers to execute arbitrary commands via shell metacharacters in a font name.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| PyPI | pygments | 1.2.2 | 2.1 |
| Debian:11 | pygments | 0 | 2.0.1+dfsg-2 |
| Debian:12 | pygments | 0 | 2.0.1+dfsg-2 |
| Debian:13 | pygments | 0 | 2.0.1+dfsg-2 |
| Debian:6.0 | pygments | 0 | 1.3.1+dfsg-1+deb6u11 |
| Debian:7 | pygments | 0 | 1.5+dfsg-1+deb7u1 |
| Debian:8 | pygments | 0 | 2.0.1+dfsg-1.1+deb8u1 |
| Mageia:5 | python-pygments | 0 | 1.6-9.1.mga5 |
| Ubuntu:14.04:LTS | pygments | 0 | 1.6+dfsg-1ubuntu1.1 |
| pypi | Pygments | 1.2.2 | No fix |
Related vulnerabilities
- CVE-2026-96376 Improper Neutralization of Special Elements used in an OS Command ("OS Command… CWE-78
- CVE-2026-113732 virtualenv is a tool for creating isolated virtual python environments. CWE-78
- CVE-2026-113776 virtualenv is a tool for creating isolated virtual python environments. CWE-78
- CVE-2026-113726 virtualenv is a tool for creating isolated virtual python environments. CWE-78
- CVE-2026-113725 virtualenv is a tool for creating isolated virtual python environments. CWE-78
- CVE-2026-113722 virtualenv is a tool for creating isolated virtual python environments. CWE-78
- CVE-2026-112943 launch-editor allows users to open files with line numbers in editor from Node.js. CWE-78
- CVE-2026-112900 Pillow is a Python imaging library. CWE-78