/

CVE-2026-35585

Severity:

HIGH RISK

(7.2)

OS Command Injection in File Browser

CVE-2026-35585

Modified

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-88

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.Expand without 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.

Sources

SourceLink
github.comgithub.com/filebrowser/filebrowser/issues/5199
github.comgithub.com/filebrowser/filebrowser/security/advisories/GHSA-jvpw-637p-h3pw

Frequently asked

questions

Exploitability depends on whether hooks are enabled and how they are configured. If hooks are disabled or not using user-supplied variables in shell commands, the risk is significantly reduced. When hooks are active and reference variables like $FILE, any user with file write permissions may be able to exploit the issue.

The attacker generally needs the ability to create or rename files through File Browser in a context where hooks run on the corresponding events. They do not need direct shell access; the attack is carried out via crafted filenames or other substituted values.

The safest pattern is to avoid passing untrusted data through a shell interpreter altogether. Instead, use APIs that execute commands with explicit argument lists, and treat filenames and usernames as data only, not as part of the command syntax. Applying strict validation to all substituted variables further reduces risk.

When designing hook or automation systems, treat all user-controlled values as untrusted and keep them separate from command syntax. Use least-privilege execution, safe process spawning primitives without shells, input validation and encoding, and default configurations that disable or strictly limit risky behaviors such as arbitrary shell command execution on user-driven events.

Find out what's already
exploitable in your codebase.