Skip to main content

XXE using J4LFOPServer leading to Remote Code Execution

Illustration of XXE using J4LFOPServer leading to Remote Code Execution
Jakub Żoczek

Introduction

While testing the LAN infrastructure of one of our clients I discovered that one of the applications is handling XML input which led to finding critical vulnerabilities. By allowing the definition of custom entities within XML input better known as XML External Entity (XXE) the application exposed itself to a range of serious threats, including local file disclosure, external network interactions resulting in NTLMv2 hash leakage, and most notably, Remote Code Execution through the use of XSLT templates.

Technical Details

The first step was identification of open services for the server using nmap:

Nmap scan results

Jetty instance on port 8087/tcp shows two deployed applications (including their full path in the system):

Jetty applications

The J4LFOPServer - based on information published over the Internet - is an application / component being part of Oracle Application Express / Apex reporter and used to generate PDF files based on XML input and Apache FOP templates. Accessing application from the browser revealed directory listing with two files - Example.html and FOP.html:

Directory listing

The first one - Example.html shows a simple form with XML input:

XML input form

By clicking Convert to PDF button - a PDF document based on XML input is generated:

PDF generation

One of the abilities of XML is to define entities, which can be external references to files in the filesystem or network resources. To confirm that, auditor created external entity reference to controlled HTTP server:

External entity reference

After converting such input to PDF, it was possible to see HTTP interaction in Burp Collaborator tool:

Burp Collaborator interaction

As an alternative payload instead of URL, it was possible to use network share in format: \10.27.20.41\anything

Server under IP 10.27.20.41 was the machine controlled by the auditor and running application Responder - a special tool used to poison LLMNR / NBT / MDNS and DNS answers and try to collect NTLMv2 hashes from the network. Forcing the application through XXE vulnerability to request this network share, resulted in interception of attacked server NTLMv2 hash:

NTLMv2 hash interception

Cracking this password allowed the execution of code on this and other servers and was a base for a lot of sensitive information disclosure and privilege escalations. However, there is also a second way to achieve code execution using J4LFOPServer and it is under FOP.html file:

FOP.html interface

There is also a simple form that expects uploading two files - XSL-FO template and XML file. Digging through the Apache FOP documentation, the auditor was able to find FOP file examples that show that it partially uses XML and XSLT structures to give the final PDF a certain style. There are known methods of using XSLT to execute code in different programming languages. Below is an example implementation of FOP file that allows code execution:

XSLT code execution

Now we have a sample valid XML file:

Sample XML file

Uploading those two on FOP.html and clicking on convert button will show such output:

Code execution output

We can also notice DNS interaction which is proof of remote code execution achieved:

DNS interaction proof

Final Notes

As part of our recommendations, we advised the client to assess whether the vulnerable application, likely installed over a decade ago is still actively in use. If it no longer serves a functional purpose, the safest course of action would be to remove it entirely. Given the lack of an available changelog and uncertainty around whether J4LFOPServer is still maintained, we also recommended considering alternative, well-supported solutions that offer similar functionality but with ongoing security updates and vendor support.

Other Insights

Illustration of Wipe and Rise: How Deleting Folder on Windows Enables LPE

Wipe and Rise: How Deleting Folder on Windows Enables LPE

Mateusz Lewczak

Time-of-check-to-time-of-use (TOCTOU) race conditions have plagued Windows software for decades, yet they still surface in modern code. During a recent audit of TestedAPP we uncovered a textbook example: the application's background service first checks whether a cache directory exists and, milliseconds later, deletes it without re-validating the path. Because every non-privileged user can create files and folders inside the application tree, an attacker can win the race, swap the legitimate directory for an NTFS mount point, and redirect the deletion to any location on the system drive.

READ article
Illustration of IAM – Privilege Escalation in Azure Cloud

IAM – Privilege Escalation in Azure Cloud

Adam Borczyk

In my recent analysis of Identity and Access Management (IAM) controls within Azure Cloud environments, I identified a significant risk related to improper role assignments. Specifically, the use of broad built-in roles, such as Owner and Contributor, without granular permission management can lead to unrestricted access. Although the tested environment contained a limited number of accounts, this misconfiguration represents a substantial security risk that can compromise cloud infrastructure and sensitive data.

READ article
A professional cybersecurity consultant ready to assist with your inquiry.

Any questions?

Happy to get a call or email
and help!