Exploitation of Pandoc Vulnerability CVE-2025-51591: A Threat to AWS EC2 IAM Credentials

In recent developments, cybersecurity experts have identified active exploitation of a security flaw in Pandoc, a widely-used document conversion tool. This vulnerability, designated as CVE-2025-51591 with a CVSS score of 6.5, is a Server-Side Request Forgery (SSRF) that enables attackers to inject malicious HTML iframe elements, potentially compromising entire infrastructures.

Understanding the Vulnerability

Pandoc, developed by JGM, is a versatile Haskell library and command-line tool that facilitates the conversion of documents across various markup formats. The identified SSRF vulnerability in Pandoc version 3.6.4 allows attackers to craft iframes that can access internal resources, including the AWS Instance Metadata Service (IMDS). This service provides metadata about running instances and temporary credentials for applications running on Amazon EC2 instances. By exploiting this flaw, attackers can retrieve sensitive information, such as IAM credentials, without direct access to the host system.

The Mechanics of the Exploit

The exploitation process involves an attacker submitting a specially crafted HTML document containing iframe elements. These iframes are designed to target the IMDS endpoint at 169.254.169.254, specifically aiming to access paths like /latest/meta-data/iam/info and /latest/meta-data/iam. If successful, this technique allows the attacker to exfiltrate sensitive metadata and credentials associated with the EC2 instance.

Historical Context and Precedents

The concept of exploiting SSRF vulnerabilities to access IMDS is not new. In early 2022, cybersecurity firm Mandiant reported that a threat actor, identified as UNC2903, had been targeting AWS environments since July 2021. They exploited an SSRF flaw (CVE-2021-21311) in Adminer, an open-source database management tool, to steal data by accessing the IMDS. This historical context underscores the persistent threat posed by SSRF vulnerabilities in cloud environments.

Mitigation Strategies

To defend against such exploits, it is crucial to implement robust security measures:

1. Upgrade to IMDSv2: AWS introduced IMDSv2, a session-oriented version of the metadata service, which requires a token for all requests. This design mitigates SSRF attacks by adding an additional layer of security.

2. Sanitize Inputs: Ensure that applications properly validate and sanitize all user inputs to prevent the injection of malicious iframes or other harmful elements.

3. Apply Security Patches: Regularly update software to incorporate security patches that address known vulnerabilities. For Pandoc users, it is advisable to use the `–sandbox` option when processing untrusted input to prevent the inclusion of potentially harmful iframe elements.

4. Network Segmentation: Implement network segmentation and firewall rules to restrict access to internal services, reducing the risk of unauthorized access through exploited vulnerabilities.

Conclusion

The exploitation of CVE-2025-51591 in Pandoc highlights the evolving tactics of cyber adversaries targeting cloud infrastructures. Organizations must remain vigilant, continuously update their security practices, and adopt comprehensive measures to protect against such sophisticated attacks.