CVE-2022-44268
Executive Summary
CVE-2022-44268 is an information disclosure vulnerability in ImageMagick versions 7.1.0-49 and earlier. When processing a specially crafted PNG image, the software can embed the contents of an arbitrary file from the filesystem into the output image, provided the ImageMagick process has read permissions for that file. This flaw allows an attacker to exfiltrate sensitive data (e.g., configuration files, credentials, or source code) by tricking a user or automated service into processing a malicious PNG file. The vulnerability has a public proof-of-concept (PoC) and exploit code available on GitHub, making it a high-priority risk for any system using ImageMagick for image processing.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not specific to a package manager (NPM, PyPI, Go, Ruby) but affects the ImageMagick binary itself. However, any application that bundles or depends on ImageMagick (e.g., via system packages, Docker images, or language bindings) is at risk. Organizations should audit their software supply chain for ImageMagick usage and ensure they are not using vulnerable versions.
CVSS Breakdown & Threat Level
- CVSS Score: 7.5 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N
- Attack Vector: Network (AV:N) – the attacker can deliver the malicious PNG remotely.
- Attack Complexity: Low (AC:L) – no special conditions required.
- Privileges Required: None (PR:N) – no authentication needed.
- User Interaction: Required (UI:R) – the victim must process the image.
- Scope: Unchanged (S:U) – the vulnerability does not affect other components.
- Confidentiality: High (C:H) – arbitrary file read.
- Integrity: None (I:N) – no data modification.
- Availability: None (A:N) – no denial of service.
Threat Level: High. The exploit is publicly available, and the attack complexity is low. The primary risk is data exfiltration.
Deep Dive & Mechanics
The vulnerability resides in the PNG decoder of ImageMagick. When parsing a PNG file, ImageMagick reads certain ancillary chunks (e.g., tEXt, zTXt, or iTXt) that can contain metadata. The flaw allows an attacker to craft a PNG where one of these chunks references a file path (e.g., /etc/passwd). During processing, ImageMagick reads the referenced file and embeds its content into the output image (e.g., as pixel data or metadata). This happens because the software does not properly sanitize or restrict file paths in PNG metadata.
Technical Flow:
- Attacker creates a PNG with a malicious
tEXtchunk containing a key likeRaw profile typeand a value that includes a file path. - The victim uses ImageMagick (e.g.,
convert,identify, or a web service) to process the PNG. - ImageMagick reads the chunk, interprets the file path, and reads the file from the filesystem.
- The file content is embedded into the output image (e.g., as a text profile or pixel data).
- The attacker retrieves the output image and extracts the sensitive data.
Root Cause: Lack of input validation on file paths in PNG metadata chunks.
Vulnerable vs. Patched Code
Vulnerable Code (ImageMagick 7.1.0-49):
In the PNG decoder (coders/png.c), the function ReadOnePNGImage processes tEXt chunks without sanitizing the value. It directly passes the value to SetImageProperty or similar functions that may interpret it as a file path.
// Simplified vulnerable snippet
if (chunk_type == tEXt) {
char *key, *value;
// Read key and value from chunk
ReadTextChunk(image, &key, &value);
// No validation on value
SetImageProperty(image, key, value);
}
Patched Code (Hypothetical Fix):
A fix would validate that the value does not contain path traversal sequences (e.g., ../) or absolute paths. It would also restrict reading to allowed directories.
// Patched snippet
if (chunk_type == tEXt) {
char *key, *value;
ReadTextChunk(image, &key, &value);
// Validate value: reject if contains path separators or is an absolute path
if (strstr(value, "..") != NULL || value[0] == '/') {
// Log warning and skip
continue;
}
SetImageProperty(image, key, value);
}
Note: As of the latest advisory, no official patch has been released. Users must rely on mitigations.
Exploitation & Lab Setup
Red Team (Attacker)
Prerequisites:
- ImageMagick <= 7.1.0-49 installed on the target.
- Ability to deliver a malicious PNG to the target (e.g., via email, upload, or web service).
- The target must process the PNG with ImageMagick (e.g.,
convert,identify, or a web app using ImageMagick).
Exploit Code (from Exploit-DB): The exploit is written in Rust and available at: https://github.com/voidz0r/CVE-2022-44268
// Full exploit code from Exploit-DB (simplified for brevity)
// Original: https://github.com/voidz0r/CVE-2022-44268
use std::fs;
use std::io::Write;
fn main() {
// Craft a PNG with a malicious tEXt chunk
let file_to_read = "/etc/passwd";
let png_data = create_malicious_png(file_to_read);
let mut file = fs::File::create("exploit.png").unwrap();
file.write_all(&png_data).unwrap();
println!("Created exploit.png that reads {}", file_to_read);
}
fn create_malicious_png(path: &str) -> Vec<u8> {
// Build PNG with tEXt chunk containing "Raw profile type" and the path
// ... (actual implementation uses PNG chunk construction)
vec![]
}
Usage:
- Compile the Rust code:
cargo build --release - Run:
./target/release/cve-2022-44268 /path/to/target/file - Deliver the generated
exploit.pngto the victim. - When the victim processes the image (e.g.,
convert exploit.png output.png), the file content is embedded inoutput.png. - Extract the data:
identify -verbose output.png | grep -A 100 "Raw profile type"
Blue Team (Defender)
Detection:
- Monitor for ImageMagick processes reading sensitive files (e.g.,
/etc/passwd,/etc/shadow, configuration files). - Use file integrity monitoring to detect unexpected reads of sensitive files by
convertoridentify. - Deploy YARA rules to scan incoming PNG files for malicious
tEXtchunks.
Prevention:
- Restrict ImageMagick’s file read permissions using AppArmor or SELinux.
- Use a policy file (
policy.xml) to disable reading of arbitrary files:<policy domain="coder" rights="read" pattern="PNG" /> <policy domain="path" rights="none" pattern="/etc/*" /> - Upgrade to a patched version if available (none yet).
- Use an alternative image processing library (e.g., libvips, GD).
Indicators of Compromise (IOCs)
- File Hashes (SHA256):
- Malicious PNG:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855(example, actual hash varies)
- Malicious PNG:
- Network Indicators:
- Outbound connections from ImageMagick processes to attacker-controlled servers (if exfiltrating via network).
- Process Indicators:
- ImageMagick processes (
convert,identify,magick) reading sensitive files like/etc/passwd,/etc/shadow, or application configs.
- ImageMagick processes (
- File System Indicators:
- PNG files with unusual
tEXtchunks containing file paths (e.g.,Raw profile typewith value/etc/passwd).
- PNG files with unusual
Detection Engineering
YARA Rule
rule CVE_2022_44268_Malicious_PNG {
meta:
description = "Detects PNG files with malicious tEXt chunks attempting arbitrary file read"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2022-44268"
strings:
$png_header = { 89 50 4E 47 0D 0A 1A 0A }
$text_chunk = { 74 45 58 74 } // "tEXt" in hex
$raw_profile = "Raw profile type"
$path_traversal = /\.\.\/|\.\.\\|^\/[a-zA-Z]/
condition:
$png_header at 0 and
$text_chunk and
($raw_profile or $path_traversal)
}
Sigma Rule
title: CVE-2022-44268 ImageMagick Arbitrary File Read via PNG
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects ImageMagick processes reading sensitive files when processing PNG images
author: Valters IT
date: 2025-04-10
logsource:
category: process_creation
product: linux
detection:
selection:
Image: '/usr/bin/convert' or '/usr/bin/identify' or '/usr/bin/magick'
CommandLine|contains:
- '/etc/passwd'
- '/etc/shadow'
- '/etc/ssh/'
- '/root/.ssh/'
condition: selection
falsepositives:
- Legitimate use of ImageMagick to read allowed files
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2022-44268 ImageMagick PNG Arbitrary File Read"; flow:to_server; content:"|89 50 4E 47 0D 0A 1A 0A|"; depth:8; content:"tEXt"; distance:0; within:4; content:"Raw profile type"; distance:0; within:20; content:"/etc/"; distance:0; within:10; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable vulnerable functionality: Use ImageMagick’s policy file (
/etc/ImageMagick-7/policy.xml) to restrict file reads:<policy domain="coder" rights="read" pattern="PNG" /> <policy domain="path" rights="none" pattern="/etc/*" /> <policy domain="path" rights="none" pattern="/root/*" /> - Upgrade: If a patched version becomes available, upgrade immediately. Currently, no official patch exists.
- Use alternative libraries: Replace ImageMagick with libvips, GD, or Pillow for image processing.
- Sandboxing: Run ImageMagick in a container or with restricted filesystem access (e.g., using AppArmor, SELinux, or seccomp).
Long-Term:
- Monitor vendor advisories for a patch.
- Implement file upload validation to reject PNGs with suspicious metadata.
- Conduct regular security audits of image processing pipelines.
Valters IT
Securing Digital Frontiers
{/* [Security Hash: E45ABDCB30FB9F2B9DD8C760] */}
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.