Wednesday, March 12, 2025
Homecyber securityPHP XXE Injection Vulnerability Allows Attackers to Access Config Files & Private...

PHP XXE Injection Vulnerability Allows Attackers to Access Config Files & Private Keys

Published on

SIEM as a Service

Follow Us on Google News

A newly uncovered XML External Entity (XXE) injection vulnerability in PHP has demonstrated how attackers can bypass multiple security mechanisms to access sensitive configuration files and private keys.

The vulnerability, detailed by web application security researcher Aleksandr Zhurnakov, highlights the risks posed by improper XML parsing configurations, even in seemingly secure implementations.

The exploit leverages a combination of PHP’s libxml extension and its wrappers, enabling attackers to bypass restrictions such as LIBXML_NONET, LIBXML_DTDLOAD, and other flags.

These flags are designed to prevent loading external entities or accessing external resources, but the research reveals how they can be circumvented using advanced payloads and techniques.

Bypassing Security Flags and Filters

The vulnerability arises from the way PHP handles XML parsing via the DOMDocument class. By default, external entity loading is disabled, but certain flags like LIBXML_DTDLOAD allow attackers to load malicious DTD files.

These files can then be crafted to exfiltrate data such as /etc/passwd or private keys by exploiting PHP wrappers like php://filter.

One of the critical bypasses involves replacing http:// URLs with alternative wrappers such as php://filter/resource=, effectively sidestepping the LIBXML_NONET restriction.

PHP XXE Injection
 inbound HTTP request

Additionally, by abusing parameter entities (%name;), attackers can inject malicious content into the XML structure before security checks are applied.

Further complicating matters, the research demonstrates how payloads can be compressed using filters like zlib.deflate and encoded in base64 to reduce their size, allowing them to fit within common server constraints for GET parameters or query strings.

According to PT Swarm Report, this approach also facilitates exfiltration via DNS subdomains when outbound TCP connections are blocked on the server.

Real-World Implications and CVE Assignment

The vulnerability has already been observed in specific applications.

For instance, an XXE flaw in SimpleSAMLphp (CVE-2024-52596) allowed unauthenticated users to read configuration files, extract private keys, and forge authentication assertions.

PHP XXE Injection
working xxe payload

This effectively enabled attackers to bypass authentication mechanisms entirely when SimpleSAMLphp was configured as an Identity Provider.

Zhurnakov’s research underscores the importance of secure XML parsing practices in PHP applications.

Developers are advised to disable all unnecessary libxml flags (LIBXML_DTDLOAD, LIBXML_NOENT, etc.) and ensure that the latest PHP versions with enhanced XXE protections (such as LIBXML_NO_XXE introduced in PHP 8.4) are deployed.

This vulnerability serves as a stark reminder of how complex attack vectors can emerge from seemingly minor misconfigurations, emphasizing the need for rigorous testing and secure coding practices in web application development.

Are you from SOC/DFIR Teams? – Analyse Malware Incidents & get live Access with ANY.RUN -> Start Now for Free. 

Aman Mishra
Aman Mishra
Aman Mishra is a Security and privacy Reporter covering various data breach, cyber crime, malware, & vulnerability.

Latest articles

CYREBRO’s AI-Native MDR Platform Earns Silver at the 2025 Globee Cybersecurity Awards

CYREBRO, the AI-native Managed Detection and Response (MDR) solution, announced today that it won...

Aptori Now on Google Cloud Marketplace for AI-Powered Security and Automated Risk Remediation

Aptori’s AI-Driven AppSec Platform Proactively Eliminates Vulnerabilities to Minimize Risk and Ensure Compliance.Aptori, a...

MirrorFace APT Using Custom Malware To Exploited Windows Sandbox & Visual Studio Code

The cybersecurity landscape witnessed a significant development when the National Police Agency (NPA) and...

CISA Issues Advisory on Windows NTFS Flaw Enabling Local Code Execution

The U.S. Cybersecurity and Infrastructure Security Agency (CISA) has issued an advisory regarding a...

Supply Chain Attack Prevention

Free Webinar - Supply Chain Attack Prevention

Recent attacks like Polyfill[.]io show how compromised third-party components become backdoors for hackers. PCI DSS 4.0’s Requirement 6.4.3 mandates stricter browser script controls, while Requirement 12.8 focuses on securing third-party providers.

Join Vivekanand Gopalan (VP of Products – Indusface) and Phani Deepak Akella (VP of Marketing – Indusface) as they break down these compliance requirements and share strategies to protect your applications from supply chain attacks.

Discussion points

Meeting PCI DSS 4.0 mandates.
Blocking malicious components and unauthorized JavaScript execution.
PIdentifying attack surfaces from third-party dependencies.
Preventing man-in-the-browser attacks with proactive monitoring.

More like this

Aptori Now on Google Cloud Marketplace for AI-Powered Security and Automated Risk Remediation

Aptori’s AI-Driven AppSec Platform Proactively Eliminates Vulnerabilities to Minimize Risk and Ensure Compliance.Aptori, a...

MirrorFace APT Using Custom Malware To Exploited Windows Sandbox & Visual Studio Code

The cybersecurity landscape witnessed a significant development when the National Police Agency (NPA) and...

CISA Issues Advisory on Windows NTFS Flaw Enabling Local Code Execution

The U.S. Cybersecurity and Infrastructure Security Agency (CISA) has issued an advisory regarding a...