Overview:
CVE-2022-44268 is a critical security vulnerability affecting ImageMagick version 7.1.0-49. When processing a PNG image, ImageMagick may inadvertently embed the contents of an arbitrary remote file into the resulting image. This occurs if the ImageMagick binary has permissions to read the remote file. An attacker could exploit this flaw by crafting a malicious PNG image or using an existing one, potentially extracting sensitive information from the target system. To mitigate this risk, users and administrators should promptly update ImageMagick to a patched version. Regularly checking for security updates is crucial to maintaining software security.
- CVE ID: CVE-2022-44268
- Product Affected: ImageMagick (version 7.1.0-49)
- Vulnerability Type: Information Disclosure
Technical Details:
ImageMagick supports a wide range of image formats and features, including the ability to reference and include external files within an image. This is useful for complex image processing tasks but can be exploited if not properly controlled.
The vulnerability primarily stems from inadequate input validation and insufficient checks during image processing (such as during resizing). ImageMagick fails to properly validate input data, allowing attackers to manipulate the image content and embed arbitrary file content into processed images.
When ImageMagick processes a PNG image, it inadvertently includes the content of an external file specified by the attacker. Attackers can exploit this by crafting PNG images with embedded file paths, such as "/etc/passwd", to disclose sensitive information. Successful exploitation of this vulnerability requires the `magick` binary, which is part of ImageMagick, to have the necessary permissions to read the specified file.
Exploitation:
Here are the steps to exploit this vulnerability:
- Download the Exploit Script: First, download the exploit script from the following URL:
2. Generate the Crafted PNG File: Use the downloaded script to create a crafted PNG file containing a chunk with the file path you want to disclose. For example, to reveal the contents of /etc/passwd, run:
3. Upload the Crafted PNG File: Upload the generated poc.png file to the target server where ImageMagick processes images.
.png)
4. Extract Chunks from the Output Image: Download the resulting image from the server (e.g., out.png) and use the exploit script to extract all the chunks from it:
5. Exploitation Result: Upon execution, you should observe that /etc/passwd is read, and the result is written to an output file by ImageMagick. This demonstrates the successful exploitation of the vulnerability, showcasing the ability to extract sensitive information from the target system.
.png)
Mitigation:
To protect against this risk, users and administrators should take the following steps:
Certainly! Here are some recommendations for handling the CVE-2022-44268 vulnerability:
- Patch or Update ImageMagick: Ensure that your ImageMagick installation is up-to-date. Check for any available security patches or updates related to this vulnerability. If a fix is available, apply it promptly.
- Disable ImageMagick Features: If you don’t require certain features of ImageMagick, consider disabling them. For example, if you don’t need PNG processing, you can disable it in the configuration. This reduces the attack surface.
- Input Validation and Sanitization: Implement strict input validation and sanitization for any user-supplied data that interacts with ImageMagick. Validate file paths, image dimensions, and other parameters to prevent malicious input.
References:
https://nvd.nist.gov/vuln/detail/CVE-2022-44268
https://www.metabaseq.com/imagemagick-zero-days/
https://www.vicarius.io/blog/cve-2022-44268-arbitrary-remote-leak-in-imagemagick
https://hackerone.com/reports/1858574