Security Experts:

Connect with us

Hi, what are you looking for?

SecurityWeekSecurityWeek

Vulnerabilities

Lossy Image Compression Can Hide Malicious Code in PDF Files: Researcher

A researcher has demonstrated that lossy image compressors can be used to hide arbitrary code inside PDF documents. The method could be highly efficient for malicious actors because security products are designed to ignore such data.

A researcher has demonstrated that lossy image compressors can be used to hide arbitrary code inside PDF documents. The method could be highly efficient for malicious actors because security products are designed to ignore such data.

It’s not uncommon for cybercriminals to hide malicious code in PDF files. The malicious code is usually designed to exploit vulnerabilities in the application that is used to open the document, in most cases Adobe Reader.

Exploits can be hidden inside PDF files by using data compressors, such as Lempel–Ziv–Welch (LZW) and Deflate, and even image compressors, such as CCITTFaxDecode and JBIG2Decode. Security products are designed to scan PDF files for payloads compressed using these algorithms.

On the other hand, antiviruses and PDF forensic tools usually ignore data compressed with lossy compressors such as JPXDecode and DCTDecode. Lossy compression uses inexact approximations for representing the encoded content, which leads to a certain amount of information being discarded.

Lossy compression is efficient for images, but not for code, which is why security solutions assume that lossily compressed data can’t contain malicious code.

However, CSIS researcher Dénes Óvári has demonstrated that hiding malicious code in a JPEG image compressed with the DCTDecode lossy compressor is possible. The experts has determined that while encoding a color JPEG image would result in data loss that would lead to corrupted code, a high-quality grayscale JPEG image could do the trick.

Óvári has developed a proof-of-concept where he encoded a piece of JavaScript code as a grayscale image and embedded it in a PDF document. The image was inserted into an Image object filtered with DCTDecode, that was then referenced by a JavaScript action entry. This ensures that the code is executed when the PDF file is opened.

“Although this is not a security breach in itself (an exploit still needs to be used inside the stream for malicious activity), the fact that the usage of DCTDecode for this purpose has seemingly been ruled out by the industry means that even known threats could be hidden in this way from anti-virus scanners and/or researchers,” Óvári wrote in a research paper published on Virus Bulletin.

“In order to provide users with maximum protection, the DCTDecode stream must no longer be overlooked: in PDF reader implementations, the referencing of uncompressed image data as parameters from objects expecting binary data should be prohibited. We should also perhaps re-examine the handling of other file formats in which data in JPEG format is assumed always to be lossily compressed, while a greyscale mode is still available,” the expert added.

Written By

Eduard Kovacs (@EduardKovacs) is a contributing editor at SecurityWeek. He worked as a high school IT teacher for two years before starting a career in journalism as Softpedia’s security news reporter. Eduard holds a bachelor’s degree in industrial informatics and a master’s degree in computer techniques applied in electrical engineering.

Click to comment

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest threats, trends, and technology, along with insightful columns from industry experts.

Join this webinar to learn best practices that organizations can use to improve both their resilience to new threats and their response times to incidents.

Register

Join this live webinar as we explore the potential security threats that can arise when third parties are granted access to a sensitive data or systems.

Register

Expert Insights

Related Content

Vulnerabilities

Less than a week after announcing that it would suspended service indefinitely due to a conflict with an (at the time) unnamed security researcher...

Risk Management

The supply chain threat is directly linked to attack surface management, but the supply chain must be known and understood before it can be...

Vulnerabilities

Apple has released updates for macOS, iOS and Safari and they all include a WebKit patch for a zero-day vulnerability tracked as CVE-2023-23529.

Application Security

Drupal released updates that resolve four vulnerabilities in Drupal core and three plugins.

Cloud Security

VMware vRealize Log Insight vulnerability allows an unauthenticated attacker to take full control of a target system.

IoT Security

Lexmark warns of a remote code execution (RCE) vulnerability impacting over 120 printer models, for which PoC code has been published.

Application Security

A CSRF vulnerability in the source control management (SCM) service Kudu could be exploited to achieve remote code execution in multiple Azure services.

Vulnerabilities

GoAnywhere MFT users warned about a zero-day remote code injection exploit that can be targeted directly from the internet