Summary
nodejs-whisper contains an OS command injection vulnerability in its audio conversion workflow, where attacker-controlled file paths are incorporated into an ffmpeg command executed through a shell. If an attacker can supply or influence an audio file name or path, crafted input may cause arbitrary operating system commands to run with the Node.js process privileges.
nodejs-whisper contains an OS command injection vulnerability in its audio conversion workflow, where attacker-controlled file paths are incorporated into an ffmpeg command executed through a shell. If an attacker can supply or influence an audio file name or path, crafted input may cause arbitrary operating system commands to run with the Node.js process privileges.
Affected context
The issue occurs in nodejs-whisper deployments that use convertToWavType() to process audio files and construct ffmpeg commands through shell execution. Risk is greatest when file names or paths originate from untrusted uploads, external requests, shared storage, or other sources that an attacker can influence.
The issue occurs in nodejs-whisper deployments that use convertToWavType() to process audio files and construct ffmpeg commands through shell execution. Risk is greatest when file names or paths originate from untrusted uploads, external requests, shared storage, or other sources that an attacker can influence.
Exploit preconditions
- Attack surface: Audio file conversion through the nodejs-whisper processing workflow
- Required access: Ability to provide or influence an audio file name or path
- Trigger point: Invocation of
convertToWavType()and subsequent ffmpeg command execution - Why exploitation is possible: Untrusted path data is interpolated into a shell command, allowing shell syntax to alter command interpretation
- Attack surface: Audio file conversion through the nodejs-whisper processing workflow
- Required access: Ability to provide or influence an audio file name or path
- Trigger point: Invocation of
convertToWavType()and subsequent ffmpeg command execution - Why exploitation is possible: Untrusted path data is interpolated into a shell command, allowing shell syntax to alter command interpretation
Why this happens
The vulnerability results from combining attacker-controlled file path data with a command executed through a shell. Shell metacharacters and command-substitution syntax are interpreted because the input is not reliably separated from the command structure before execution. This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection.
The vulnerability results from combining attacker-controlled file path data with a command executed through a shell. Shell metacharacters and command-substitution syntax are interpreted because the input is not reliably separated from the command structure before execution. This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly known as OS command injection.
Potential impact
- Attackers may execute arbitrary operating system commands
- The Node.js application process and its accessible data could be compromised
- Sensitive files, credentials, or environment variables may be exposed
- Malicious processes could modify application data or configuration
- Compromised hosts may be used for lateral movement or service disruption
- Attackers may execute arbitrary operating system commands
- The Node.js application process and its accessible data could be compromised
- Sensitive files, credentials, or environment variables may be exposed
- Malicious processes could modify application data or configuration
- Compromised hosts may be used for lateral movement or service disruption
General mitigation guidance
Mitigation generally focuses on eliminating shell interpretation and reducing trust in file names and paths.
Common defensive patterns include:
- Use process-spawn APIs with argument arrays rather than shell-based execution
- Pass validated file paths as discrete arguments to external tools
- Apply strict allowlists for permitted file names, extensions, and path locations
- Resolve paths within controlled directories and reject traversal or unexpected separators
- Prefer fixed executable paths and immutable conversion options
- Run conversion workers with least-privilege operating-system accounts and restricted filesystem access
- Isolate media processing from sensitive services and credentials
Mitigation generally focuses on eliminating shell interpretation and reducing trust in file names and paths.
Common defensive patterns include:
- Use process-spawn APIs with argument arrays rather than shell-based execution
- Pass validated file paths as discrete arguments to external tools
- Apply strict allowlists for permitted file names, extensions, and path locations
- Resolve paths within controlled directories and reject traversal or unexpected separators
- Prefer fixed executable paths and immutable conversion options
- Run conversion workers with least-privilege operating-system accounts and restricted filesystem access
- Isolate media processing from sensitive services and credentials
How teams detect issues like this
Detection approaches can include:
- Static analysis rules identifying shell execution APIs that receive concatenated, interpolated, or template-built strings
- Code review checks for external input flowing into ffmpeg or other process commands
- Dependency and policy scans that flag shell-based process execution in upload or media-processing paths
- Runtime monitoring for unexpected child processes, command interpreters, or unusual ffmpeg arguments
- Tests using benign shell metacharacter cases to verify that path data remains a single argument
- Automated code review tools that trace tainted file metadata into command execution sinks
Detection approaches can include:
- Static analysis rules identifying shell execution APIs that receive concatenated, interpolated, or template-built strings
- Code review checks for external input flowing into ffmpeg or other process commands
- Dependency and policy scans that flag shell-based process execution in upload or media-processing paths
- Runtime monitoring for unexpected child processes, command interpreters, or unusual ffmpeg arguments
- Tests using benign shell metacharacter cases to verify that path data remains a single argument
- Automated code review tools that trace tainted file metadata into command execution sinks

