/

CVE-2026-25965

Severity:

HIGH RISK

(8.6)

Path Traversal / Local File Inclusion in ImageMagick File

CVE-2026-25965

Modified

Vulnerability type

Category:

Path Traversal / Local File Inclusion

CWE:

CWE-22

Impact:

Local File Disclosure via Policy Bypass

Severity:

HIGH RISK

(8.6)

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

ImageMagick's path security policy was applied to raw, unnormalized filenames, allowing attackers to use path traversal sequences to bypass rules intended to block access to sensitive locations (e.g., /etc/*).

When an application uses ImageMagick to process user-supplied paths, an attacker may be able to read local files (LFI) despite a configured policy-secure.xml, as the OS resolves the traversal while the policy engine does not.

Affected context

This vulnerability affects deployments that:

  • Use ImageMagick to read or transform images by path, filename, or pseudo-image references
  • Rely on ImageMagick's policy-secure.xml to restrict access to directories or sensitive paths (e.g., /etc/*)
  • Accept file paths, URLs, or similar locators that may be influenced by untrusted input

The issue manifests when security policies are evaluated against the unnormalized path string, but the underlying filesystem resolves traversals and symlinks before opening the file.

Exploit preconditions

  • Attack surface: Any ImageMagick entry point that accepts or derives file paths from untrusted or partially trusted input (CLI, libraries, bindings).
  • Required access: Ability to supply or influence the filename/path that ImageMagick uses when opening an image or related resource.
  • Trigger point: Invocation of ImageMagick operations (e.g., convert, identify, or library calls) that cause ImageMagick to open a file path subject to policy checks.
  • Why exploitation is possible: The path security policy engine evaluates policy rules on the raw, non-normalized path string, while the operating system resolves path traversal segments (e.g., ../) to the actual filesystem location, allowing an attacker to craft paths that appear to bypass restricted prefixes or patterns.

Why this happens

The root cause is a mismatch between how ImageMagick enforces path-based security policies and how the underlying operating system resolves file paths.

The security policy matcher checks the original path string against patterns like /etc/* before normalization, whereas the OS resolves relative segments, symbolic links, and traversals, potentially mapping an apparently safe path into a protected directory.

This design flaw aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where input paths are not normalized or canonicalized before access control checks, allowing traversal sequences to bypass directory or filename-based restrictions.

Potential impact

  • Disclosure of sensitive configuration files (e.g., files under /etc/)
  • Exposure of application secrets, credentials, or API keys stored on disk
  • Leakage of environment-specific information useful for further attacks (e.g., user accounts, installed services)
  • Possible access to files outside intended directories even when security policies appear to forbid them

General mitigation guidance

Mitigation focuses on correctly enforcing path-based restrictions and reducing trust in user-controlled filenames:

  • Normalize and canonicalize paths before applying any allow/deny rules, including resolution of traversal segments and symbolic links.
  • Prefer whitelisting of specific directories or patterns over broad blacklisting; restrict ImageMagick file access to tightly scoped locations.
  • Use ImageMagick's security policies in a defense-in-depth fashion, not as the sole boundary, and ensure policies disallow both reading from and writing to sensitive paths.
  • Isolate ImageMagick processing in sandboxes or containers with limited filesystem visibility to reduce the impact of any path traversal.
  • Apply least-privilege principles to the account running ImageMagick, minimizing access to sensitive files that should never be readable by image-processing components.

How teams detect issues like this

Detection techniques generally target the mismatch between intended policy and effective filesystem access:

  • Static review of ImageMagick usage sites to identify any direct consumption of untrusted or semi-trusted path strings; verify that normalization or canonicalization is performed before ImageMagick is invoked.
  • Configuration review of policy-secure.xml to ensure rules are aligned with canonical paths and account for traversal-resistant patterns, and that both read and write operations to sensitive locations are restricted.
  • Runtime monitoring or auditing of file access by ImageMagick processes (e.g., using OS-level auditing or container security tools) to detect unexpected reads of sensitive files.
  • Use of security scanners and SAST/DAST tools that flag path traversal use cases and misconfigured ImageMagick policies as part of CI/CD pipelines.

Sources

SourceLink
github.comgithub.com/ImageMagick/ImageMagick/security/advisories/GHSA-8jvj-p28h-9gm7
access.redhat.comaccess.redhat.com/errata/RHSA-2026:5573
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-25965
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2442118
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-25965.json

Frequently asked

questions

It can be remotely exploitable when ImageMagick is used in a web service or API that accepts user-controlled filenames, URLs, or image sources. In such cases, a remote attacker may trigger file reads on the server via crafted paths.

The attacker needs the ability to influence the path or resource identifier that ImageMagick processes. This might be via a file upload endpoint, an image transformation API, or any feature that passes user-controlled paths to ImageMagick.

The safest pattern is to ensure all paths are normalized and canonicalized before policy checks or file access, combined with strict whitelisting of allowed directories and robust policy definitions that block both read and write access to sensitive locations.

Preventing similar flaws involves designing path-based access controls around canonical paths, avoiding reliance solely on string-based policy checks, minimizing the filesystem scope exposed to image-processing tools, and integrating regular security reviews of policy configurations into the development and deployment process.

Find out what's already
exploitable in your codebase.