/

CVE-2026-41247

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in elFinder ImageMagick Resize Backend

CVE-2026-41247

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

elFinder versions prior to 2.1.67 contain an OS command injection vulnerability in the resize command when using the ImageMagick CLI backend.

Unsafely incorporating the user-controlled bg (background color) parameter into shell command strings can allow an attacker to execute arbitrary system commands under the web server process account.

Affected context

The vulnerability occurs in elFinder deployments that:

  • Enable the resize image operation, and
  • Use ImageMagick via a command-line (CLI) backend, and
  • Construct shell commands by concatenating user-supplied parameters such as the bg color value.

In these configurations, untrusted input flows into shell command strings without robust quoting or escaping, making the file-management endpoint a remote code execution surface.

Exploit preconditions

  • Attack surface: HTTP(S) endpoints exposing elFinder's file management UI or API.
  • Required access: Ability to invoke the resize command, typically via an authenticated elFinder session or any integration that forwards user-controlled parameters to elFinder.
  • Trigger point: Submitting a crafted bg parameter value in a resize/rotate request that reaches the ImageMagick CLI backend.
  • Why exploitation is possible: The bg parameter is interpolated into a shell command line without rigorous sanitization or safe argument handling, allowing shell metacharacters to break out of the intended command and inject attacker-controlled commands.

Why this happens

The underlying bug is an OS command injection issue (CWE-78) caused by constructing shell commands from user input.

Instead of treating the bg parameter as opaque data passed through a safe argument interface, the application embeds it directly into a command string that is executed by the system shell.

Shell metacharacters, chaining operators, or argument injection sequences within the bg value can therefore alter the command structure.

This pattern reflects a broader insecure design: relying on string concatenation for command execution instead of using parameterized execution APIs or non-shell-based libraries for image manipulation.

Potential impact

  • Execution of arbitrary system commands as the web server process user
  • Reading or modifying application data accessible to the web server account
  • Planting web shells or backdoors on the server filesystem
  • Lateral movement inside the hosting environment, depending on local network exposure
  • Disruption or defacement of hosted applications and stored content

General mitigation guidance

Effective mitigation focuses on removing the direct dependency on shell command construction and reducing trust in user-controlled parameters:

  • Prefer image-processing libraries that operate in-process (e.g., language-native bindings) rather than invoking shell-based tools.
  • If external tools must be used, call them via APIs that pass arguments as arrays instead of concatenated command strings, so user input cannot alter the command structure.
  • Treat all parameters influencing command execution (such as colors, filenames, options) as untrusted and enforce strict allowlists and validation for expected formats.
  • Run the web server and any helper processes under the least-privileged account practical, with restricted file-system and network access to limit blast radius.
  • Isolate file-management components in dedicated containers or sandboxes to reduce the impact of potential command execution.

How teams detect issues like this

Detection typically combines code-centric and operational approaches:

  • Static analysis: Flag patterns where user input flows into functions that build shell command strings (e.g., string concatenation passed to exec, system, or similar APIs).
  • Code review: Look for ad-hoc command construction using user-controlled parameters, especially around media processing, archiving, or system utilities.
  • Configuration review: Identify components that use CLI-based backends (such as ImageMagick) and verify that arguments are passed via safe interfaces rather than raw shells.
  • Runtime monitoring: Use application and system logs to detect anomalous commands issued by the web server user, correlating command invocations with web requests to sensitive endpoints.
  • Policy enforcement: Integrate security checks into CI/CD pipelines to prevent introduction of new shell-based integrations that build commands from unvalidated input.

Sources

SourceLink
github.comgithub.com/Studio-42/elFinder/security/advisories/GHSA-8q4h-8crm-5cvc

Frequently asked

questions

Exploitability depends on how elFinder is exposed. If the resize command is reachable to untrusted users over HTTP and the ImageMagick CLI backend is enabled, an attacker can potentially achieve remote code execution.

That varies by deployment. In many setups, invoking resize requires an authenticated elFinder session or application-level permissions, but any role that can trigger image resizing with a controllable bg value can be abused.

Avoid constructing shell commands with string concatenation. Use non-shell image-processing libraries where possible; if external tools are necessary, pass all user-derived values as sanitized, validated arguments to non-shell execution APIs.

Establish a development guideline that external commands must never be built from raw user input, enforce strict input validation and allowlists, and use static analysis and code review checklists to detect shell command construction patterns early in the development lifecycle.

Find out what's already
exploitable in your codebase.