Summary
Cockpit CMS contains a command injection vulnerability in its FFmpeg integration. An authenticated user with the assets/upload permission may be able to execute arbitrary commands as the web-server user by uploading a video whose filename contains shell metacharacters.
Affected context
The vulnerability occurs in Cockpit CMS deployments using the FFmpeg integration for uploaded video assets. It becomes risky when an authenticated account has permission to upload assets and the original filename is incorporated into a shell command before sanitization or strict argument handling occurs.
Exploit preconditions
- Attack surface: Authenticated asset-upload functionality and the FFmpeg processing workflow
- Required access: An account with the
assets/uploadpermission - Trigger point: Processing of an uploaded video file by the FFmpeg integration
- Why exploitation is possible: The filename is interpolated into a shell command before the intended
slugify()sanitization step, allowing shell syntax in the filename to alter command interpretation
Why this happens
The underlying flaw is the construction of a shell command from attacker-influenced filename data without applying effective sanitization or argument isolation before execution. Passing the resulting command to a shell-enabled process API allows shell metacharacters to be interpreted as control syntax rather than literal filename content. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection.
Potential impact
- An attacker may execute arbitrary operating-system commands as the web-server user
- The application runtime could be compromised
- Sensitive files, credentials, or environment data could be accessed
- Uploaded content or CMS data could be modified or deleted
- The host or connected services could be used for further unauthorized activity
General mitigation guidance
Mitigation generally centers on avoiding shell interpretation of user-controlled filenames and reducing the trust placed in upload metadata.
Common defensive patterns include:
- Invoke FFmpeg through an argument-array or equivalent non-shell API
- Treat filenames as data and pass them as isolated arguments rather than interpolating them into command strings
- Apply allowlist-based filename normalization before any processing
- Validate file type, extension, and media metadata independently of the filename
- Ensure sanitization occurs before command construction and execution
- Run media-processing workers with minimal operating-system and application privileges
- Restrict uploaded files and temporary directories using appropriate filesystem permissions
- Use process isolation and resource limits for external media tools
How teams detect issues like this
Detection can combine source review, runtime monitoring, and policy enforcement:
- Use static analysis rules to identify shell-enabled process APIs receiving concatenated or interpolated upload metadata
- Review code paths where filenames, paths, or form values reach command execution without argument separation
- Search for sanitization that occurs after command construction or after a process has started
- Monitor web-server and media-processing processes for unexpected child processes, command interpreters, or unusual outbound connections
- Enforce secure coding policies that prohibit shell command construction from untrusted input
- Add CI checks and automated review tools for command injection and unsafe process-spawning patterns

