Summary
File Browser's hook system, which runs administrator-defined shell commands on file events, can be abused to inject arbitrary OS commands via crafted filenames.
When an attacker with file write permissions uploads or renames a file to include shell metacharacters, the unsanitized variable substitution in the hook command can lead to remote code execution on the server.
Affected context
This vulnerability occurs in deployments of File Browser that:
- Use versions from 2.0.0 through 2.63.1
- Have the hook system enabled and configured to run shell commands on file events such as upload, rename, or delete
- Pass event-related variables (e.g., $FILE, $USERNAME) directly into shell commands
It primarily affects environments where untrusted users are granted file write permissions through File Browser and hooks are executed via a shell.
Exploit preconditions
- Attack surface: File operations exposed by File Browser (e.g., web UI, API, or integrations that allow uploads, renames, or deletions).
- Required access: Ability to create or rename files through File Browser with filenames under attacker control; hooks must be configured and enabled.
- Trigger point: Execution of hook commands that interpolate variables such as $FILE or $USERNAME into shell command lines.
- Why exploitation is possible: Variable substitution is implemented via
os.Expandwithout sanitization or proper escaping, allowing shell metacharacters embedded in filenames or usernames to alter the shell command structure and inject additional commands.
Why this happens
The underlying issue is the direct interpolation of untrusted data into shell command strings executed by the system shell.
File Browser's hook mechanism relies on os.Expand to substitute variables like $FILE and $USERNAME into an administrator-defined command template, without escaping or constraining those values.
When these variables contain shell metacharacters (such as separators, redirection operators, or command substitution syntax), the shell treats them as part of the command syntax rather than plain data.
This aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') and is related to CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection'), as the attacker manipulates command arguments and structure via crafted filenames.
Potential impact
- Execution of arbitrary OS commands with the privileges of the File Browser process
- Full compromise of the underlying host or container, depending on deployment and privilege level
- Unauthorized access to or modification of files managed by File Browser and other local resources
- Use of the compromised system as a foothold for lateral movement within the network
- Data exfiltration, tampering, or destruction affecting stored files and possibly connected services
General mitigation guidance
Effective mitigation focuses on eliminating direct shell interpretation of untrusted data and constraining hook behavior:
- Prefer invoking commands without a shell where possible, using structured APIs or argument arrays rather than shell-constructed strings.
- Apply strict validation and encoding to variables used in hook commands, ensuring filenames and usernames cannot introduce shell metacharacters or argument delimiters.
- Treat hook inputs as opaque data and pass them as discrete command-line arguments instead of embedding them into a single shell command string.
- Limit the privileges of the File Browser process and the commands executed by hooks (e.g., use dedicated service accounts with least privilege).
- Restrict hook usage to trusted environments and trusted users; disable hooks where not strictly necessary.
- Implement defensive configuration defaults that do not execute shell commands on user-controlled events unless explicitly enabled with appropriate safeguards.
How teams detect issues like this
Detection can target both configuration and runtime behaviors:
- Static/configuration review: Examine File Browser configuration for hook commands that interpolate variables directly into shell command strings, especially those passed through
/bin/sh,/bin/bash, or similar. - Code and config review signals: Look for usage patterns where $FILE, $USERNAME, or other user-controlled values appear unescaped in hook templates or scripts.
- Static analysis and linters: Use security-focused configuration scanning or policy-as-code tools to flag shell commands that include untrusted variables without sanitization.
- Runtime monitoring: Monitor process execution patterns from the File Browser service, such as unexpected shells or utilities being spawned on file events, anomalous command lines, or outbound network connections initiated by hook processes.
- Logging and audit trails: Ensure hooks and file operations are logged with sufficient detail to identify suspicious filenames or repeated failures that may indicate attempted injection.

