/

CVE-2026-48997

Severity:

HIGH RISK

(7.1)

Command Injection (CWE-78) in e107 ImageMagick path

CVE-2026-48997

Deferred

Vulnerability type

Category:

Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution under constrained, non-default conditions

Severity:

HIGH RISK

(7.1)

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

e107 CMS contains a command injection flaw in how it constructs ImageMagick resize commands, allowing partial user-controlled input into the destination path.

Under specific non-default configuration settings, an authenticated non-admin attacker can craft a news title that injects shell syntax into the ImageMagick convert invocation, potentially leading to arbitrary command execution on the server.

Affected context

The vulnerability arises in e107 deployments that use ImageMagick for image resizing within the "submit news" upload flow.

It affects instances where:

  • resize_method is set to ImageMagick
  • subnews_attach is enabled to allow attachments to submitted news
  • upload_enabled is enabled for user uploads
  • subnews_resize is configured to a numeric value between 30 and 5000
  • Non-admin users belong to roles permitted by both subnews_class and upload_class

In this context, parts of the user-controlled news title are incorporated into the ImageMagick destination filename and passed into a shell command.

Exploit preconditions

  • Attack surface: HTTP-based news submission and file upload interface of e107.
  • Required access: Authenticated non-admin account in classes allowed to submit news and upload attachments, as configured by subnews_class and upload_class.
  • Application configuration: All of the following non-default options must be enabled:
  • resize_method=ImageMagick
  • subnews_attach=1
  • upload_enabled=1
  • subnews_resize set to a numeric value between 30 and 5000
  • Trigger point: The submit-news flow that processes an uploaded image and invokes ImageMagick's convert command for resizing.
  • Why exploitation is possible: The destination path passed to convert contains the first six characters of the user-controlled news title, inserted inside double quotes without robust shell-escaping. While the source path is protected with escapeshellarg(), the destination segment still allows special shell constructs—such as command substitution and control characters like tabs—to survive inside the quoted argument and be interpreted by /bin/sh -c.

Why this happens

This issue stems from unsafe construction of shell commands that mix partially sanitized and unsanitized user input.

The resize_image() function correctly wraps the source path using escapeshellarg(), but it builds the ImageMagick convert command line by embedding the destination filename directly inside double quotes without equivalent escaping.

In the submit-news upload flow, the destination filename is derived from the first six characters of the news title, which is filtered only to remove literal spaces, not shell metacharacters or tab characters.

As a result, shell syntax such as $(), backticks, and other constructs can be preserved inside the quoted argument and interpreted by /bin/sh -c when the command is executed.

This pattern maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, where input feeding into a command line is not fully neutralized, enabling an attacker to alter the command's behavior.

Potential impact

  • Execution of arbitrary OS commands with the privileges of the web server process
  • Unauthorized access to application data and configuration files
  • Lateral movement within the hosting environment, depending on local protections
  • Modification, deletion, or exfiltration of uploaded media and other content
  • Potential use of the compromised server as a pivot point for further attacks

General mitigation guidance

Risk reduction centers on eliminating direct shell command construction and tightening trust boundaries around user input:

  • Prefer API-level or library-based invocation of ImageMagick (e.g., using bindings that avoid /bin/sh -c) instead of shelling out with concatenated strings.
  • If shell execution is unavoidable, build command arguments as arrays passed directly to process execution functions that do not invoke a shell, ensuring each parameter is treated as data, not command syntax.
  • Apply strict normalization and encoding to any user-derived data used in filenames or command arguments, allowing only a conservative set of characters and rejecting or sanitizing all others.
  • Separate user-facing metadata (like titles) from filesystem paths, generating destination filenames from server-controlled identifiers rather than user input.
  • Run the web application and image processing utilities with least-privilege accounts and constrained filesystem permissions, limiting the blast radius of a successful injection.
  • Consider disabling complex or rarely needed upload and auto-resize paths unless they are strictly required, especially when they rely on external command-line tools.

How teams detect issues like this

Detection efforts can focus on both code-level and runtime signals:

  • Static analysis rules or custom linters that flag:
  • Concatenation of user-controlled variables into shell command strings
  • Use of /bin/sh -c or equivalent shells with interpolated data
  • Partial escaping patterns (e.g., only some arguments passed through escapeshellarg()).
  • Manual code review concentrating on:
  • Image processing and upload handlers
  • Places where titles, filenames, or other user metadata influence OS-level operations
  • Misaligned validation, such as filters that remove spaces but leave shell metacharacters intact.
  • Policy and CI enforcement:
  • Build-time checks that reject new code introducing shell-based tooling where safer APIs exist
  • Security-focused unit or integration tests that feed crafted titles into the upload pipeline to detect unexpected command execution.
  • Runtime monitoring:
  • Logging and alerting around ImageMagick invocations, especially commands containing unusual characters in paths
  • Host-based intrusion detection to spot anomalous child processes spawned from the web server.

Sources

SourceLink
github.comgithub.com/e107inc/e107/releases/tag/v2.3.6
github.comgithub.com/e107inc/e107/security/advisories/GHSA-3j33-c9v4-4p42

Frequently asked

questions

Exploitation is constrained: it requires a specific non-default configuration and an authenticated non-admin account with permission to submit news and upload attachments. However, when these conditions are met, the impact can extend to arbitrary command execution on the server.

The attacker must be a logged-in non-admin user in classes allowed by both subnews_class and upload_class, and must be able to submit news with an attachment. No shell or system-level access is needed prior to exploitation.

The most robust fix is to avoid constructing shell commands from dynamic strings altogether, using direct library or API calls to ImageMagick or invoking it through non-shell process execution APIs with arguments passed as separate parameters. Additionally, destination filenames should not be derived from user-controlled text.

Establish coding standards that prohibit passing user input—directly or indirectly—into shell commands, enforce allowlist-based validation for any data touching filesystem or OS operations, and integrate static analysis and security reviews into the development lifecycle to catch new instances of command injection patterns early.

Find out what's already
exploitable in your codebase.