From CRLF Injection to XSS: Elevating the Stakes in Apple iTunes Security
A CRLF injection in an Apple iTunes API endpoint allowed an attacker to inject a Set-Cookie header, and by changing the request content-type the reflected cookie could be rendered as HTML, leading to XSS. A colleague also found a CORS issue on the same endpoint that could let a third-party domain read cookies.
Published on xelkomy.medium.com
Approximately eighteen months ago, I discovered a significant vulnerability within Apple iTunes, starting with a Carriage Return Line Feed (CRLF) issue. Through persistent effort, this initial finding was escalated to reveal a Cross-Site Scripting (XSS) vulnerability, showcasing the potential for extensive…
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
Apple's main site, apple.com, uses a subdomain inside the iTunes.apple.com domain as an API to fetch iTunes offer data. The main site's source code references that subdomain and shows that it accepts certain parameters. The researcher's write-up does not name the subdomain or the parameters.
The finding started as a CRLF injection in that endpoint and was later combined with a CORS issue on the same endpoint. In the later stages a colleague, Zyead, found a CORS issue on the same endpoint.
Setup
The work was done with a bash script that aggregated subdomains and Wayback Machine URLs for each, which were then analysed with Dalfox and Nuclei. Traffic was monitored through the Burp Suite proxy, and the Burp Suite repeater was used for manual testing. The write-up gives no versions for any of these tools and does not describe any account or role.
Finding it
On a Friday, the automated pass over the aggregated subdomains and Wayback URLs found nothing. The researcher then turned to the main Apple domain. While watching traffic in the Burp Suite proxy, he noticed a subdomain being used as an API by the main domain to fetch iTunes offer data. Reading the main domain's source code showed that this subdomain accepted certain parameters, which made it the target.
Exploitation
Step 1: CRLF injection and cookie reflection
Using Burp Suite's repeater, the researcher fuzzed the parameters for issues such as XSS and LFI. Injecting the following payload produced a breakthrough: the attacker=exploit cookie was reflected in the response page.
%0d%0aSet-Cookie:%20attacker=exploit
The %0d%0a sequence is a carriage return and line feed, which ends the current header line and starts a new one. The rest of the payload, Set-Cookie:%20attacker=exploit, is then interpreted as a new response header, and the attacker=exploit cookie was reflected in the response page. The reflection of that cookie in the response page indicated a potential security exploit.

The response from the Apple subdomain with the cookie reflected.
Step 2: Getting past the JSON content type
The response came back with a JSON content type. The researcher had met this before: reflection inside a JSON response makes the exploit less impactful. After research and experimentation, he found that manually adjusting the content type in the request bypassed the limitation. This allowed the exploit to be reflected outside the JSON response.

The response from the Apple subdomain with the content type reflected.
The write-up does not show the exact header value used for this adjustment.
Step 3: Cookie capture through a third-party domain
After the content type was manipulated, the researcher was able to intercept and reflect cookies back to himself. Combined with the CORS issue that Zyead identified on the same endpoint, the two were able to capture cookies via a third-party domain.
Root cause
The endpoint reflected the injected carriage return and line feed sequence, and the attacker=exploit cookie appeared in the response page. The JSON content type limited the impact at first, but because the content type could be changed through the request, the reflection could be moved outside the JSON body. The write-up does not describe the server-side code or any specific defence that was in place, so the exact mechanism is not stated.
Impact
Under the conditions shown, an attacker could inject a cookie into the response and, with the CORS issue on the same endpoint, capture cookies via a third-party domain. The write-up describes this as a significant security flaw that could potentially be exploited by unauthorised entities to gain access to sensitive information.
Fix
Based on the behaviour described, the endpoint should reject or strip carriage return and line feed characters from any input that reaches response headers, and should not let a request change the response content type in a way that moves reflected input out of the JSON body.
Variants to test
- Send
%0d%0aSet-Cookie:%20attacker=exploitin each parameter of an API endpoint that reflects input. A positive result is aSet-Cookieheader forattacker=exploitin the response. - Try the same payload with a manually adjusted content type in the request. A positive result is the payload reflected outside the JSON body.
- Test the same endpoint for CORS misconfiguration alongside the CRLF issue. A positive result is a third-party domain able to read the response and capture cookies.
- Run the same fuzzing with Dalfox and Nuclei over subdomains and Wayback URLs. A positive result is a reflected payload in a response header or body.
What happened, in plain words
A security researcher found a bug in a part of Apple's iTunes website. The bug let him slip extra instructions into the website's reply, and a cookie he chose appeared reflected in the response page. Later he found a way to make that trick work outside the normal data format the server used, and a colleague found a related weakness on the same address that let them read cookies from another website. Together these issues could be used to get at sensitive information.
The write-up does not name the exact subdomain or the parameters involved, and it does not give a bounty amount or a severity score.
Before going further, a few everyday ideas will help.
- A website is a set of pages your browser loads from a server. The server is just a computer somewhere that answers requests.
- A subdomain is a name that sits in front of a main domain. If
apple.comis the main building,itunes.apple.comis a named office inside it. Each subdomain can be a separate service. - An API is a way for one piece of software to ask another for data, like a waiter taking your order to the kitchen and bringing back a plate. Here, the main Apple site asked a subdomain for iTunes offer data.
- A parameter is a named value you attach to a request, like a label on a form field. The server reads the label and uses the value.
- A cookie is a small piece of text a website asks your browser to store and send back on later requests. It is how a site remembers who you are between page loads, similar to a cloakroom ticket: you keep the ticket, the site keeps the coat.
- CRLF stands for Carriage Return Line Feed. In text sent over the web, these two invisible characters mark the end of one line and the start of the next. Think of them as pressing Enter in a document.
- XSS, or Cross-Site Scripting, is a bug where a site lets an attacker's content run as if it came from the site itself. It is like someone slipping a fake notice onto a company bulletin board so visitors believe the company wrote it.
- CORS, or Cross-Origin Resource Sharing, is a set of rules that decides whether a page from one website may read a response from another website. Without permission, browsers block that reading, like a library that will not hand your records to a stranger from another building.
The setup
The researcher did not start by staring at one page. He ran a bash script, which is a list of commands a computer carries out in order, to collect two things:
- subdomains of Apple, gathered from public sources;
- archived URLs for each of those subdomains from the Wayback Machine, a service that keeps old copies of web pages.
He then fed that collection to two tools, Dalfox and Nuclei, which automatically try known patterns against many addresses and report anything that looks odd. This is like sending a inspector to walk every corridor of a large building and note doors that are unlocked.
He also watched his own web traffic through Burp Suite, a program that sits between the browser and the internet and lets you see and edit every request and reply. Its proxy mode is the watching part; its repeater mode lets you take one request and send it again and again with small changes, which is how you test a single door carefully.
The write-up gives no versions for these tools and does not mention any account or user role being used.
Finding it
On a Friday, the automated pass over all those subdomains and archived URLs found nothing. So the researcher changed approach and looked at the main Apple domain, apple.com, directly.
While watching traffic in the Burp Suite proxy, he noticed a subdomain that the main site was using as an API to fetch iTunes offer data. In other words, the main page was quietly asking this other address for information and then displaying it.
He then read the main site's source code, the underlying text a browser receives before it draws the page. That code showed the subdomain accepted certain parameters. A parameter is the part of a request that carries a value, so seeing parameters told him there was input he could control. That made the subdomain the target.
The write-up does not name the subdomain or the parameters.
Exploitation
Step 1: CRLF injection and cookie reflection
Using Burp Suite's repeater, the researcher sent many variations of the parameters, looking for problems such as XSS and LFI. LFI, or Local File Inclusion, is a bug where a site can be tricked into reading a file from its own server that it should not show, like a receptionist reading out the staff filing cabinet because someone asked nicely.
One variation produced a breakthrough. He injected this text:
%0d%0aSet-Cookie:%20attacker=exploit
Line by line, in plain words:
%0dis the encoded form of a carriage return, one of the two characters that ends a line.%0ais the encoded form of a line feed, the other half of the line ending. Together,%0d%0ameans "end this line and start a new one".Set-Cookie:is the name of a real instruction a server uses to tell a browser to store a cookie.%20is an encoded space, so the next part is separated properly.attacker=exploitis the cookie name and value the researcher wanted the browser to store.
The trick works because the injected line-ending characters were reflected in the reply. The server thought it was writing one value, but the %0d%0a ended that line early, and everything after it looked like a brand new instruction to the browser. The result was that the attacker=exploit cookie appeared reflected in the response page. That reflection was the sign of a real security problem.

The image shows the response from the Apple subdomain with the cookie reflected.
Step 2: Getting past the JSON content type
There was a catch. The server's reply came back with a JSON content type. JSON is a plain text format for structured data, a bit like a very strict shopping list with labels and values. A content type is the label on the reply that tells the browser what kind of data is inside.
The researcher had met this before: when your injected text lands inside a JSON reply, the browser treats it as data to display, not as instructions to follow, so the trick has much less effect.
After some research and experimentation, he found that manually changing the content type in his request got around the limitation. This let the injected text be reflected outside the JSON reply, where it could act as instructions again.

The image shows the response from the Apple subdomain with the content type reflected.
Step 3: Cookie capture through a third-party domain
Once the content type had been manipulated, the researcher was able to intercept and reflect cookies back to himself. In the later stages of the investigation, a colleague, Zyead, found a CORS issue on the same endpoint, the same address where the CRLF problem lived.
CORS is the browser rule that normally stops one website from reading another website's response. A CORS issue means that rule is too loose, so a page on a different site can read data it should not. Combining the two findings, the researcher and his colleague were able to capture cookies via a third-party domain. In everyday terms, the first bug let them plant a ticket, and the second let a stranger's building read the ticket back.
Why it matters
The endpoint reflected the injected carriage return and line feed sequence, and the attacker=exploit cookie appeared in the response page. The JSON content type limited the damage at first, but because the content type could be changed through the request, the injected text could be moved outside the JSON body.
Under the conditions shown, an attacker could inject a cookie into the reply and, with the CORS issue on the same endpoint, capture cookies via a third-party domain. The write-up calls this a significant security flaw that could potentially be exploited by unauthorised parties to gain access to sensitive information.
The fix
Based on the behaviour described, the endpoint should reject or strip carriage return and line feed characters from any input that reaches response headers, and it should not let a request change the response content type in a way that moves reflected input out of the JSON body.
Variants to test
If you want to practise the same ideas on a system you are allowed to test, these are the variations the write-up points to:
- Send
%0d%0aSet-Cookie:%20attacker=exploitin each parameter of an API endpoint that reflects input. A positive result is aSet-Cookieheader forattacker=exploitin the response. - Try the same payload with a manually adjusted content type in the request. A positive result is the payload reflected outside the JSON body.
- Test the same endpoint for a CORS misconfiguration alongside the CRLF issue. A positive result is a third-party domain able to read the response and capture cookies.
- Run the same fuzzing with Dalfox and Nuclei over subdomains and Wayback URLs. A positive result is a reflected payload in a response header or body.
Glossary
- API: a way for one piece of software to ask another for data, like a waiter carrying an order to the kitchen.
- Bash script: a file of commands a computer runs in order.
- Burp Suite: a tool that sits between your browser and the internet so you can see and edit requests and replies.
- Burp Suite proxy: the part of Burp Suite that watches traffic passing through it.
- Burp Suite repeater: the part of Burp Suite that resends one request with changes so you can test a single address carefully.
- Content type: the label on a reply that says what kind of data it contains, such as JSON or HTML.
- Cookie: a small piece of text a site asks your browser to store and send back later, like a cloakroom ticket.
- CORS (Cross-Origin Resource Sharing): browser rules that decide whether a page from one site may read a reply from another site.
- CRLF (Carriage Return Line Feed): the two invisible characters that mark the end of a line and the start of the next.
- Dalfox: an automated tool that tries known patterns against addresses and reports suspicious results.
- Endpoint: a specific address on a server that accepts requests and returns replies.
- Fuzzing: sending many variations of input automatically to see which ones cause an unexpected result.
- Header: a labelled line in a request or reply that carries information about it, such as its content type or a cookie instruction.
- JSON: a plain text format for structured data, with labels and values.
- LFI (Local File Inclusion): a bug where a site can be tricked into reading a file from its own server that it should not show.
- Nuclei: an automated tool that checks many addresses against known patterns and reports matches.
- Parameter: a named value attached to a request, like a label on a form field.
- Reflection: when input you sent comes back in the server's reply.
- Subdomain: a name in front of a main domain, such as
itunes.apple.comunderapple.com. - Wayback Machine: a service that keeps archived copies of web pages and their addresses.
- XSS (Cross-Site Scripting): a bug where a site lets an attacker's content run as if the site itself had written it.