Out of Band XXE in an E-commerce IOS app
An iOS e-commerce app's JSON endpoint accepted XML input and parsed it with external entity declarations enabled, so a crafted XML document could make the server fetch external resources and read local files. The author demonstrated out-of-band requests to their own listener and retrieved a system file from the host.
Published on 0xgaurang.medium.com
While testing IOS app of the target application, I had found XXE vulnerability for which I’m going to share the writeup. Wanted to publish this since long time, but was only waiting for the disclosure.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
The target was the iOS app of a large e-commerce company, described in the report as a big giant in the e-commerce industry with more than 50 million downloads at the time of writing. The researcher was not permitted to name the company, so the name is redacted in the screenshots.
The feature involved is a JSON endpoint. The report does not describe the business function of that endpoint. What matters is that the endpoint accepted a request body with the content type flipped to XML, and that the XML parser behind it was configured to process external entities.

Setup
The testing was done against the iOS app of the target. The tools used were:
- A generic XML payload to probe whether the endpoint parsed XML at all.
- A listener on a remote server controlled by the researcher, to observe out-of-band requests.
- XXEserve, a small Sinatra application that runs a web server, creates a DTD file and prints out the logs, used to collect data sent out of band.
Finding it
The first signal came from changing the content type to XML on a JSON endpoint. Sending a generic XML payload produced an XML parsing error in the response, which confirmed that the application was processing XML input even though the endpoint was designed for JSON. Because the parsing error was displayed to the end user, detection was easy.

The error alone only proves that XML is parsed. The next question was whether external entities are resolved, which is what turns XML parsing into an XXE vulnerability.
Exploitation
Step 1: Confirm external service interaction
To check whether the parser would make requests to external sites, the researcher started a listener on a remote server and used an XML payload that causes the parser to send a request to that server. The report does not reproduce the payload itself.
The connection was received from the target IP address. The user-agent of the incoming request indicated that the back-end server is processing Java. The connection was received from the target IP address, showing the server can be made to issue requests to an external host.

Step 2: Retrieve files out of band
With interaction confirmed, the next step was to exfiltrate data from the remote host. The researcher used XXEserve, which runs a web server, creates a DTD file and prints out the logs, making it useful for collecting data sent out of band.
Using XXEserve, it was possible to retrieve files from the target host via HTTP. The file shown in the report is /etc/resolv.conf. The report does not include the DTD or the request payload used for this step.

Root cause
The parsing functionality did not have XML External Entity Declaration disabled, which allowed an attacker to read files from the server. The parsing error returned to the end user made the behaviour visible, but the underlying weakness is the parser configuration, not the error message.
Impact
As described in the report's own summary of XXE, an attack of this kind may lead to the disclosure of confidential data, denial of service, server side request forgery, port scanning from the perspective of the machine where the parser is located, and other system impacts. In this specific case the researcher demonstrated two concrete outcomes: requests originating from the target's back-end server to an external host, and retrieval of files from the target host over HTTP, with /etc/resolv.conf as the example. The report does not enumerate which other files or data were reachable.
Fix
To harden a JSON endpoint, XML parsing should be disabled altogether and/or inline DOCTYPE declarations should be disabled to prevent XML external entity injections. The report does not state which of the two measures was applied.
Variants to test
- Content type flipping on JSON endpoints: send a body with the content type set to XML and a generic XML payload. A positive result is an XML parsing error in the response, which shows the body reaches an XML parser.
- External entity resolution: point an entity at a listener you control. A positive result is an incoming connection from the target's address, ideally with a user-agent that identifies the back-end stack.
- Out-of-band file retrieval: serve a DTD from a tool such as XXEserve and reference local files through it. A positive result is file contents appearing in the logs of your server.
- Error visibility: watch for parser errors returned to the client, since they make the first step of detection trivial and suggest the parser is not hardened.
What happened, in plain words
A security researcher was testing the iPhone app of a very large online shopping company. The report calls it a big giant in the e-commerce industry, with more than 50 million downloads at the time of writing. The researcher was not allowed to name the company, so the name is blacked out in the screenshots.
While testing, the researcher found a bug called XXE, short for XML External Entity. In simple terms: the app sends data to a server, and that server reads the data with a piece of software called an XML parser. A parser is a program that reads a structured text format and turns it into something the application can use, a bit like a clerk who reads a filled-in paper form and copies the answers into a computer. If that clerk is too trusting, you can add a line to the form saying "before you finish, go and fetch the file on my desk and read it out loud", and the clerk will do it. That is what happened here: the researcher could make the company's server send requests to a server the researcher controlled and retrieve files from the target host.
The report describes how the bug was spotted, how it was confirmed, and how data was pulled out of the company's server. The company fixed it in a few hours.

Background: the words you need
Before walking through the steps, here are the ideas involved, explained from scratch.
An app and its API. An iPhone app is mostly a screen. The real work happens on computers owned by the company, called servers. The app talks to those servers over the internet using an API. An API is a fixed set of addresses, like service windows in a building: the app walks up to a window, hands over a request, and gets an answer back. Each window has an address, called an endpoint. The report does not say what the particular endpoint in this story was for.
JSON and XML. When the app hands data to an endpoint, the data has to be written in a format both sides understand. Two common formats are JSON and XML. JSON looks like a shopping list with labels, for example a name followed by a value in curly brackets. XML looks more like a nest of tags, similar to HTML, the language web pages are written in: an opening tag, some content, a closing tag. Both are just ways of writing structured text.
Content type. Every request carries a label saying which format the body is in, called the content type. It is like writing "this envelope contains a form in English" on the outside. The server reads the label and picks the right clerk to handle it. If the label says JSON, the JSON clerk opens it; if it says XML, the XML clerk opens it.
The XML parser and entities. Inside XML you can define shortcuts called entities. An entity is a name that stands for some text, so you can write the name instead of repeating the text. Most entities are harmless. An external entity is one whose value is not written in the document but has to be fetched from somewhere else, such as a file on the server or a web address. That is the dangerous kind: it tells the parser to go and get something.
XXE. An XML External Entity attack is a type of attack against an application that parses XML input. It happens when XML input containing a reference to an external entity is processed by a weakly configured XML parser. In everyday terms: the form contains an instruction to fetch something from outside, and the clerk follows it without asking who wrote the instruction. The report's own summary says this attack may lead to the disclosure of confidential data, denial of service, server side request forgery, port scanning from the perspective of the machine where the parser is located, and other system impacts. Those terms are unpacked in the glossary at the end.
Out of band. Normally you see the result of a request in the response that comes back to you. Sometimes the result does not come back that way at all: the server does something elsewhere, for example contacts a different machine. Watching for that side effect is called out-of-band testing. It is like asking a friend to stand by a back door and tell you if anyone comes out, because you cannot see the back door from the front.
A listener. To do out-of-band testing you need a server you control that waits for incoming connections and records them. That is a listener. The researcher ran one on a remote server.
A DTD. XML documents can include a block called a Document Type Definition, or DTD, which declares entities and other rules for the document. It is the section of the form where you are allowed to define your own shortcuts. If an attacker can supply a DTD, they can define shortcuts that point at files or addresses of their choosing.
XXEserve. The researcher used a tool called XXEserve. The report describes it as a tiny Sinatra app that runs a web server, creates a DTD file and prints out the logs, which is useful in collecting data sent out of band. Sinatra is a small framework for building web applications in the Ruby programming language; you do not need to know Ruby to follow the story, only that XXEserve is a ready-made helper that plays the role of the friend at the back door and writes down what it sees.
How the bug was found
The first clue came from a simple experiment. The endpoint was designed for JSON, so the researcher changed the content type label to XML and sent a body in XML instead. This is sometimes called content type flipping: you take a window that expects one format and hand it another, to see whether the clerk behind it is more flexible than the sign says.
The reason to try this is that many applications reuse the same underlying code for several formats. The sign on the window may say JSON, but the machinery behind it may still be able to read XML. If it can, and if that XML reader is too trusting, the door is open.
The researcher sent a generic XML payload, meaning a simple, ordinary piece of XML not tailored to anything in particular, just enough to see whether the server would try to read it. The target returned an XML parsing error. That error confirmed the suspicion that the application was processing XML input: the server had tried to read the body as XML, failed on this particular content, and said so.

The screenshot shows the content type flipped to XML on a JSON endpoint. Sending a generic XML payload made the target return an XML parsing error, which confirmed that the application was processing XML input.
Why does this matter so much? Because the error was displayed to the end user. The report notes that detection was easy for exactly this reason. A well-behaved server usually answers with a short, generic message and keeps the details in its own logs. When it instead tells you that it could not parse your XML, it is effectively confirming which clerk opened your envelope. That is a gift to anyone testing the system.
At this point, though, all that is proven is that XML is being read. That alone is not a vulnerability. The next question is whether the parser also resolves external entities, because that is what turns plain XML parsing into an XXE vulnerability. Think of it as: we know the clerk reads forms; now we want to know whether the clerk will also run errands written on the form.
Step 1: does the server make requests to outside sites?
To answer that question, the researcher started a listener on a remote server and used an XML payload that makes the parser send a request to that server. The idea is simple: if the parser follows external references, it will try to fetch something from the address written in the XML, and the address is the researcher's own listener. If the listener records an incoming connection, the parser is following instructions from the document.
The report does not reproduce the payload used for this step, so there is no code to show here. What it does describe is the result.
The connection was received from the target IP address. An IP address is the numeric label that identifies a machine on a network, roughly like a postal address for computers; the report redacts the actual address. Receiving a connection from the target's address means the request did not come from the researcher's own machine or from some unrelated party, but from the company's server. The server had been made to reach out.
The user-agent of the incoming request indicated that the back-end server is processing Java. The user-agent is a small piece of text that software sends along with a request to say what it is, like a caller introducing themselves on the phone. Here it revealed that the software on the other end was Java-based. That is useful information for anyone testing, because it tells you what kind of machinery you are dealing with.

The screenshot shows the listener receiving the connection from the target IP address, with a user-agent indicating that the back-end server is processing Java.
This step confirms out-of-band interaction: the parser resolves external entities, and the server can be made to issue requests to a host controlled by the researcher. In plain terms, the clerk not only reads the form, but also runs the errand written on it, and the friend at the back door saw someone arrive.
Step 2: pulling files out of the server
With the interaction confirmed, the next goal was to exfiltrate data from the remote host. Exfiltrate simply means to get data out of a system you are not supposed to take it from. The researcher used XXEserve for this.
As described earlier, XXEserve runs a web server, creates a DTD file and prints out the logs. The DTD is the part that declares the entities, the shortcuts. By serving a DTD from a machine the researcher controls, the researcher can define an entity whose value is a file on the target server, and another entity that sends that value back to the researcher's server. The target's parser reads the DTD, follows the definitions, reads the local file, and transmits its contents out. The researcher's server writes the incoming data into its logs, where the researcher can read it.
Using XXEserve, it was possible to retrieve files from the target host via HTTP. The file shown in the report is /etc/resolv.conf. On Linux and similar systems, that is a small configuration file that tells the machine which DNS servers to use; DNS is the system that turns names like example.com into IP addresses. It is a convenient file to demonstrate with because it is small, readable, and its presence proves that local files can be read. The report does not include the DTD or the request payload used for this step, so there is no code to reproduce here.

The screenshot shows that files could be retrieved from the target host, with /etc/resolv.conf as the example, via HTTP using XXEserve.
Why does this matter? Because a file on the server is not something the app was ever meant to hand out. Once a parser can be told to read local files, the same mechanism can be pointed at other files, and the report's own summary lists the wider consequences: disclosure of confidential data, denial of service, server side request forgery, port scanning from the perspective of the machine where the parser is located, and other system impacts. The report does not enumerate which other files or data were reachable in this case; it demonstrates the two concrete outcomes, the outgoing request and the file retrieval.
Why it worked
The parsing functionality did not have XML External Entity Declaration disabled, which allowed an attacker to read files from the server. That is the root cause in one sentence.
Spelled out: the endpoint was intended for JSON, but the back end still fed the request body to an XML parser, and that parser was weakly configured. Weakly configured here means it was left with a feature switched on that should have been switched off, namely the processing of XML input containing a reference to an external entity. The parser did what it was told, and what it was told came from the attacker.
The parsing error returned to the end user made the behaviour visible, but the underlying weakness is the parser configuration, not the error message. The error was the clue, not the bug. Even if the error had been hidden, the parser would still have followed the external entities; the researcher would simply have had a harder time noticing.
The fix
To harden a JSON endpoint, XML parsing should be disabled altogether and/or inline DOCTYPE declarations should be disabled to prevent XML external entity injections. In everyday terms: either do not let the XML clerk near the envelope at all, or at least forbid the section of the form where people define their own shortcuts, since that is where the dangerous instructions live.
The vulnerability was reported and fixed in a few hours by the team. The report does not state which of the two measures was applied.
What to try if you are learning
- Content type flipping on JSON endpoints: send a body with the content type set to XML and a generic XML payload. A positive result is an XML parsing error in the response, which shows the body reaches an XML parser. Why: it costs almost nothing and tells you whether the window's sign matches the clerk behind it.
- External entity resolution: point an entity at a listener you control. A positive result is an incoming connection from the target's address, ideally with a user-agent that identifies the back-end stack. Why: this separates harmless XML parsing from the actual vulnerability.
- Out-of-band file retrieval: serve a DTD from a tool such as XXEserve and reference local files through it. A positive result is file contents appearing in the logs of your server. Why: it turns the confirmed interaction into demonstrated impact.
- Error visibility: watch for parser errors returned to the client, since they make the first step of detection trivial and suggest the parser is not hardened. Why: a chatty error message is a sign that the system is not being careful about what it reveals.
A word of caution for anyone starting out: only run these checks against systems you own or have explicit permission to test.
Glossary
- API: a fixed set of addresses and rules that lets one program ask another for data or actions, like service windows in a building.
- Endpoint: one specific address in an API that accepts a particular kind of request.
- JSON: a text format for structured data, built from labels and values in curly brackets and square brackets.
- XML: a text format for structured data, built from nested opening and closing tags.
- Content type: the label on a request saying which format the body is written in.
- Content type flipping: changing that label, for example from JSON to XML, to see whether the server handles a format it was not designed for.
- Parser: software that reads a structured text format and turns it into something the application can use.
- Entity: a named shortcut inside XML that stands for some text.
- External entity: an entity whose value is not written in the document but must be fetched from elsewhere, such as a file or a web address.
- XXE (XML External Entity): an attack against an application that parses XML input, where XML containing a reference to an external entity is processed by a weakly configured parser.
- Weakly configured: left with a feature switched on that should have been switched off for safety.
- Out of band: observing a result through a side effect elsewhere, such as a connection to another server, rather than in the direct response.
- Listener: a server you control that waits for incoming connections and records them.
- IP address: the numeric label that identifies a machine on a network.
- User-agent: a small piece of text software sends with a request to say what it is.
- Java: a programming language and runtime commonly used for back-end servers.
- DTD (Document Type Definition): a block in XML that declares entities and other rules for the document.
- DOCTYPE declaration: the part of an XML document that introduces the DTD; inline DOCTYPE declarations are the ones written directly in the document.
- XXEserve: a tiny Sinatra app that runs a web server, creates a DTD file and prints out the logs, used to collect data sent out of band.
- Sinatra: a small framework for building web applications in the Ruby programming language.
- Exfiltrate: to get data out of a system you are not supposed to take it from.
/etc/resolv.conf: a small configuration file on Linux-like systems that tells the machine which DNS servers to use.- DNS: the system that turns names like example.com into IP addresses.
- Disclosure of confidential data: private information becoming visible to someone who should not see it.
- Denial of service: making a system unavailable to its normal users.
- Server side request forgery: making a server send requests to addresses chosen by an attacker.
- Port scanning: probing which network services a machine is running, here from the perspective of the machine where the parser is located.
- Bug bounty: a programme where a company invites people to look for problems in its systems and report them, usually under rules about what is allowed.
- Harden: to reduce the ways a system can be misused, usually by switching off features that are not needed.