CVE-2025-58180 Overview
OctoPrint is a widely deployed web interface for controlling consumer 3D printers. CVE-2025-58180 is an authenticated command injection vulnerability affecting OctoPrint versions up to and including 1.11.2. An authenticated attacker can upload a file with a specially crafted filename that, when referenced by a configured system event handler, results in arbitrary command execution. The flaw maps to CWE-78: OS Command Injection. Exploitation requires that the OctoPrint administrator has configured event handlers executing system commands with uploaded filenames as parameters. The vulnerability is patched in version 1.11.3.
Critical Impact
Authenticated attackers on an adjacent network can achieve arbitrary command execution on the OctoPrint host by uploading files with shell metacharacters in their names, when filename placeholders are referenced by system event handlers.
Affected Products
- OctoPrint versions up to and including 1.11.2
- OctoPrint instances with event handlers using filename-based placeholders in system commands
- OctoPrint deployments where feature.enforceReallyUniversalFilenames is not enabled
Discovery Timeline
- 2025-09-09 - CVE-2025-58180 published to the National Vulnerability Database
- 2025-09-09 - GitHub Security Advisory GHSA-49mj-x8jp-qvfc released
- 2025-09-09 - Patch released in OctoPrint 1.11.3
- 2025-09-18 - Last updated in NVD database
Technical Details for CVE-2025-58180
Vulnerability Analysis
The vulnerability is an OS command injection issue rooted in insufficient sanitization of uploaded filenames. OctoPrint supports user-configurable event handlers that can execute system commands when specific events occur. Administrators commonly use filename placeholders inside these command templates so the relevant file is passed as an argument. When OctoPrint substitutes the placeholder with a filename containing shell metacharacters, the resulting command string is interpreted by the system shell. An authenticated user with upload privileges can therefore craft a filename embedding additional shell commands. Once the matching event fires, those commands run with the privileges of the OctoPrint process.
Root Cause
The sanitization routine for uploaded filenames did not strip shell metacharacters such as ;, |, &, ?, $, *, <, and >, nor unprintable ASCII control characters. The fix in src/octoprint/util/files.py extends _sfn_really_universal to remove these characters before the filename is stored, preventing command injection regardless of how the filename is later interpolated into shell commands.
Attack Vector
An authenticated attacker on an adjacent network uploads a file whose name contains shell metacharacters and a payload. When an administrator-configured event handler that uses a filename placeholder is triggered, OctoPrint constructs and executes a shell command containing the attacker-controlled filename. The injected payload executes in the OctoPrint host context. If no event handlers reference filename placeholders, the vulnerability is not exploitable.
import logging
import os.path
import re
+import string
+_UNPRINTABLE_ASCII = "".join(chr(c) for c in range(128) if chr(c) not in string.printable)
+_STRIPPED_FILE_NAME_CHARS = ";|&?$*<>" + _UNPRINTABLE_ASCII
+_STRIPPED_FILE_NAME_RE = re.compile(
+ f"[{re.escape(_STRIPPED_FILE_NAME_CHARS):s}]", re.UNICODE
+)
+### taken from pathvalidate library
+_WINDOWS_RESERVED_FILE_NAMES = ("CON", "PRN", "AUX", "CLOCK$", "NUL") + tuple(
+ f"{name:s}{num:d}" for name, num in itertools.product(("COM", "LPT"), range(1, 10))
+)
+_MACOS_RESERVED_FILE_NAMES = (":",)
+def _sfn_really_universal(name):
+ from octoprint.util.text import sanitize
Source: OctoPrint patch commit c3a9409
Detection Methods for CVE-2025-58180
Indicators of Compromise
- Files in the OctoPrint uploads directory whose names contain shell metacharacters such as ;, |, &, $, *, <, or >
- Unexpected child processes spawned by the OctoPrint process around the time of an event trigger such as upload, print start, or print done
- Outbound network connections initiated by processes spawned by OctoPrint that do not match normal printer control workflows
- Modifications to the OctoPrint config.yaml event handler section by non-administrative accounts
Detection Strategies
- Audit the OctoPrint uploads directory for filenames containing characters outside the printable filename character set and quarantine suspicious files
- Inspect process creation telemetry for sh, bash, or cmd.exe children of the OctoPrint Python process with command lines containing upload filenames
- Review OctoPrint event handler configuration in config.yaml to enumerate every command template that interpolates a filename placeholder
Monitoring Recommendations
- Enable verbose OctoPrint logging for event handler execution and forward logs to a central collector for review
- Monitor file upload events on the OctoPrint host filesystem and alert on filenames containing shell metacharacters
- Track the OctoPrint process tree continuously and alert on any spawned shell or interpreter not normally invoked during printing
How to Mitigate CVE-2025-58180
Immediate Actions Required
- Upgrade OctoPrint to version 1.11.3 or later, which contains the filename sanitization fix
- Audit all configured event handlers and disable any that reference filename-based placeholders until the upgrade is verified
- Review existing uploads and delete any files with suspicious names containing shell metacharacters or unprintable characters
- Restrict OctoPrint network exposure so the web interface is not reachable from untrusted networks
Patch Information
OctoPrint released the fix in version 1.11.3. The patch is implemented in commits be4201e and c3a9409, updating _sfn_really_universal in src/octoprint/util/files.py to strip dangerous characters. See the GitHub Security Advisory GHSA-49mj-x8jp-qvfc for full details.
Workarounds
- In the GUI Event Manager, disable every event handler that uses filename placeholders by unchecking the Enabled checkbox or setting enabled to False in config.yaml
- Set feature.enforceReallyUniversalFilenames to true in config.yaml and restart OctoPrint to enforce stricter filename sanitization
- Vet existing uploads after enabling enforcement and delete any files with suspicious names
- Limit access to the OctoPrint web interface to trusted users and trusted network segments only
# Configuration example - config.yaml
feature:
enforceReallyUniversalFilenames: true
events:
subscriptions:
- event: Upload
command: "/usr/local/bin/process.sh {filename}"
type: system
enabled: false # disable until upgraded to 1.11.3
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

