Taking down the SSO, Account Takeover in the Websites of Kolesa due to Insecure JSONP Call
An insecure JSONP endpoint on the SSO server returned an authentication token to any origin, bypassing the Same Origin Policy. An attacker could trick a logged-in user into visiting a malicious page, steal the token, and use it to log in as the victim on any of the three Kolesa websites.
Published on medium.com
{{media:0}}
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
Kolesa runs three websites that share a single authentication server:
The authentication server was:
https://id.kolesa.kz
Because each site lives on a different origin, a domain cannot set an authentication cookie for the others. The SSO model therefore transfers an authentication token between the authentication server and the other domains, and each site saves its own cookie after verifying that token. The authentication server also keeps its own cookie. After a few HTTP requests the researcher identified the authentication cookie name for each Kolesa website.
Setup
The work was done against the live Kolesa sites and their SSO server. No special accounts, roles or tool versions are described. The precondition for the attack is simply that a victim is already logged in to one of the three sites, so that id.kolesa.kz holds the authentication cookie and can issue tokens on request.
Finding it
JSONP is a method for sending JSON data to another domain. As the researcher summarises it, JSONP:
- can load an external JavaScript object;
- does not use the XMLHttpRequest object;
- is less secure;
- bypasses the Same Origin Policy in browsers.

Example of JSONP request/response
The JSONP call on Kolesa is used for further authentications. If a user has already logged in on any of the three websites, a JSONP call is made to authenticate the user on the site being visited. The reason given is ease of implementation: since the origins differ, the sites should have implemented Cross Origin Resource Sharing to transfer the authentication, but they chose JSONP to avoid CORS setup.

Once a user is logged in, for example on kolesa.kz, they have a ccid cookie in id.kolesa.kz, an authentication token to transfer the authentication, and an ssid cookie in kolesa.kz. When the user then visits another of the sites, login happens with just a click: because id.kolesa.kz holds the authentication cookie, it immediately generates an authentication token and the user receives the corresponding authentication cookie on that site.
Phase 4 of the workflow shows how the JSONP call is made and how the authentication token is turned into an authentication cookie in a domain.
If the user has already been authenticated by id.kolesa.kz, the expected response is:
The body defines an object named sess with two properties, is_authenticated and token. This object is what transfers the authentication. At this point the user has an authentication token but not the authentication cookie of the current website, so a second call is made.
The JavaScript code involved:
Exploitation
The question the researcher asked was whether an arbitrary origin can extract the authentication token. It can, because the JSONP call bypasses the Same Origin Policy.
The result is account takeover by a single click.
Step 1: Set up a page that calls JSONP on behalf of any user
The attacker hosts a page that issues the JSONP call to the authentication server. The attacker hosts a page that issues the JSONP call to the authentication server, and because the JSONP call bypasses the Same Origin Policy, the token can be extracted.
Step 2: Trick an authenticated user into visiting the malicious site
The victim must already be authenticated by id.kolesa.kz. The victim must already be authenticated by id.kolesa.kz for the JSONP call to return a token.
Step 3: Send the authentication token to the attacker's server
The authentication token is sent by the user to the attacker's website.
Step 4: Log in as the victim and do bad things
With the token, the attacker logs in as the victim and does bad things.
The exploit code is described in the report as client-side plus server-side call, and a video POC was published alongside it. The report does not reproduce the exploit source itself.
Root cause
The authentication token is delivered through a JSONP endpoint that any origin can include as a script. JSONP exists precisely to bypass the Same Origin Policy, so the response is executable by any site that references it, and the sess.token value inside it is readable by that site. The sites should have implemented Cross Origin Resource Sharing to transfer the authentication, but chose JSONP to avoid CORS setup.
Impact
An attacker who can get an authenticated user to visit a malicious page obtains that user's authentication token and can take over the account on the Kolesa websites that rely on this SSO. The attack requires the victim to be logged in and to be tricked into visiting the attacker's page; it is a single click. The report does not state which accounts or data were affected beyond the account takeover itself.
Fix
The report does not describe a fix or a vendor response. The direction implied by the analysis is to stop transferring the authentication token through JSONP and use a CORS-protected endpoint instead, so that only the intended origins can read the token.
Variants to test
- Look for JSONP endpoints on authentication or session servers that return tokens, session identifiers or user objects. A positive result is a response whose body assigns such data to a global object and that executes when included as a script from a different origin.
- Check whether the JSONP callback parameter is reflected without restriction. A positive result is arbitrary JavaScript executing in the context of the responding origin.
- Test SSO flows across sibling domains for token transfer over JSONP rather than CORS. A positive result is a token readable from an attacker-controlled page while the victim is logged in.
- Review whether CSP on the JSONP response restricts script inclusion. A positive result is a CSP that only sets
frame-ancestorsand therefore does not stop cross-origin script loads.
What happened, in plain words
Kolesa runs three websites that all share one login system. If you sign in on one of them, you are signed in on the others too. That shared login is called Single Sign-On, or SSO. The researcher, Yashar Shahinzadeh, found that the JSONP call which hands your login from one site to another could be read by an arbitrary origin. By getting a logged-in person to open a page he controlled, he could collect that person's login token and then act as them. He calls it account takeover with a single click.
This article walks through the same steps he did, in the same order, but explains every idea from the beginning. You only need to know how to use a browser.
What is JSONP?
Before the details, one concept: JSONP.
A normal web page can only read data from the same website it came from. This rule is called the Same Origin Policy, and it is a browser safety rule. It stops a page on evil.example from quietly reading your bank's pages. An origin is the combination of protocol, host and port, so https://market.kz and https://krisha.kz are two different origins even though they look similar.
Sometimes a site genuinely needs to send data to another origin. One old workaround is JSONP. Instead of sending back plain data, the server sends back a small piece of JavaScript that stores the data in a variable. The browser treats it as a script, and scripts are allowed to be loaded from anywhere. So the receiving page can read the data even though it comes from another origin.
The researcher summarises JSONP like this:
- Can load an external JavaScript object
- Does not use the XMLHttpRequest object
- Less secure
- Bypassed SOP in browsers

Example of JSONP request/response
In everyday terms: the Same Origin Policy is like a building where each office can only read its own mail. JSONP is a trick where the mail is delivered as a parcel that anyone in the building is allowed to open. It works, but anyone who can intercept the parcel can read it too.
Single Sign-On
Information gathering revealed that Kolesa websites use SSO, the authentication server was:
https://id.kolesa.kz
An authentication server is the central place that checks who you are. Instead of each website keeping its own password list, they all ask this one server. The three websites that used SSO were:
The general workflow of how SSO works:
In this authentication model since a domain can not set an authentication cookie for the others, an authentication token should be transferred between the authentication server and other domains. Considering the orange box in the image above, each site should save a cookie after verifying the authentication token. In addition, authentication server also saves its cookie, so after a couple of HTTP requests I found the authentication cookie name for each Kolesa website:
Two words need explaining here.
A cookie is a small piece of text that a website asks your browser to store and to send back on every later request to that same site. It is how a website remembers that you already logged in. Think of it as a wristband you get at a festival: you show it once at the gate, and after that the staff just glance at your wrist.
A token is a longer piece of text that stands in for your login. It is not your password, but whoever holds it can act as you until it expires. Think of it as a cloakroom ticket: the ticket is not your coat, but handing it over gets you the coat.
Because each site lives on a different origin, one site cannot write a cookie for another. So the login server hands out a token, and each site swaps that token for its own cookie. The login server keeps its own cookie too. After a couple of HTTP requests the researcher found the authentication cookie name for each Kolesa website.
JSONP Call to Handle SSO
The JSONP call is used for further authentications. If a user has already logged-in in any of three websites, a JSONP call is made to authenticate the user in. The reason for this action is the ease of implementation. Since the origins of domains are different, the Kolesa websites should have implemented the Cross Origin Resource Sharing to transfer the authentication, but they've decided to use JSONP to avoid CORS setup.

Cross Origin Resource Sharing, or CORS, is the modern, safe way to let one origin read data from another. The server explicitly lists which origins are allowed. It takes a little configuration, and the team skipped that configuration by using JSONP instead. That shortcut is the heart of the problem.
The point is, once a user is logged in for examplekosela.kz, they have a ccid cookie in id.kolesa.kz, an authentication token to transfer the authentication, and a ssid cookie in kosela.kz. After that, if the user wants to log-in in the other websites, it happens by just a click, since id.kosela.kz has authentication cookie, it immediately generates authentication token and the user will have the corresponded authentication cookie on the website.
In plain words: you log in once on one site. The login server gives you a ccid cookie. The site you are on gives you an ssid cookie. When you later click login on a sister site, the login server sees its own cookie, mints a fresh token, and the sister site turns that token into its own cookie. No password is typed again.
Based on the picture above, phase 4 shows how the JSONP call is made and how the authentication token can be turned into authentication cookie in a domain. The cause of JSONP call:
If the user has already been authenticated by id.kolesa.kz, the following response is expected:
This is an HTTP response, the raw text a server sends back to a browser. Line by line:
HTTP/1.1 200 OKmeans the request succeeded.Server: openresty/[redacted]names the web server software.Dateis when the response was produced.Content-Type: text/javascript;charset=UTF-8is the important one: the server is saying this is JavaScript, not data. That is what makes the browser run it.Connection: closesays the connection will be closed after this response.ExpiresandCache-Control: no-store, no-cache, must-revalidateandPragma: no-cacheall tell the browser and any proxy not to store this response. Sensible for something containing a login token.Backend-Servernames the internal machine that handled the request.X-Bug-Bountyis a friendly note inviting people to report bugs.Content-Security-Policy: frame-ancestors 'self' ...restricts which pages may put this response inside a frame. It says nothing about who may load it as a script, which matters later.Strict-Transport-Securitytells the browser to keep using HTTPS for this site.Content-Length: 627is the size of the body.- The body itself sets
window.xdmto an object with asessproperty. Insidesessareis_authenticated: 1and a longtoken. The last line is a small jQuery snippet that copies the object onto jQuery's$.xdm.
As it's been seen there is an object named sess containing the two properties named is_authenticated and token. This object is responsible to transfer authentication. At this moment the user has authentication token but not authentication cookie of the current website, so the second call is made:
The JavaScript code:
Vulnerable External JavaScript Object
The question is, an arbitrary origin can extract the authentication token? of course, it can because the JSONP call bypasses the Same Origin Policy.
Arbitrary origin simply means any website on the internet, including one run by an attacker. Because the JSONP call bypasses the Same Origin Policy, an arbitrary origin can extract the authentication token. The Same Origin Policy would normally stop that read, but JSONP is designed to get around it.
The vulnerability found, account takeover by a single click :)
Account takeover means logging in as someone else without their password. Here it needs only that the victim is already logged in and clicks a link.
The Exploitation Phase
The scenario is simple:
- Setting up a page calling JSONP on behalf of any user
- Tricking authenticated user to visit our malicious website
- Sending
authentication tokenby the user to our website - logging-in as the victim and doing bad stuff
The exploit code (client-side + server-side call):
Here is the video POC:
Step by step, and why each step is needed:
- Set up a page that calls JSONP on behalf of any user. The attacker writes a page that includes the login server's JSONP URL as a script.
- Trick an authenticated user into visiting the malicious site. If the user has already been authenticated by
id.kolesa.kz, the JSONP response contains the token. So the victim must be logged in and must open the attacker's page. This is why the attack is described as a single click: the click is the visit. - Send the authentication token to the attacker's server. The authentication token is sent by the user to the attacker's website.
- Log in as the victim and do bad things. With the token, the attacker logs in as the victim and does bad things.
The report describes the exploit as client-side plus server-side code and published a video proof of concept, but it does not reproduce the exploit source itself.
Why it worked
The token is delivered by a JSONP endpoint that any origin can include as a script. JSONP exists to bypass the Same Origin Policy, so any site that references it can run the response and read sess.token. The sites should have implemented Cross Origin Resource Sharing to transfer the authentication, but chose JSONP to avoid CORS setup.
What it means
Anyone who can get a logged-in user to open a malicious page gets that user's authentication token and can take over the account on the Kolesa sites that rely on this SSO. The victim has to be logged in and has to be tricked into the visit. The report does not say which accounts or data were affected beyond the takeover itself.
How to fix it
The report does not describe a fix or a vendor response. The direction implied by the analysis is to stop sending the authentication token through JSONP and to use a CORS-protected endpoint instead, so that only the intended origins can read the token.
Where else to look
- Look for JSONP endpoints on login or session servers that return tokens, session identifiers or user objects. A positive result is a response whose body assigns such data to a global object and that runs when included as a script from a different origin.
- Check whether the JSONP callback parameter is reflected without restriction. A positive result is arbitrary JavaScript running in the context of the responding origin.
- Test SSO flows across sister domains for token transfer over JSONP rather than CORS. A positive result is a token readable from an attacker-controlled page while the victim is logged in.
- Review whether CSP on the JSONP response restricts script inclusion. A positive result is a CSP that only sets
frame-ancestorsand therefore does not stop cross-origin script loads.
Glossary
- Account takeover: logging in as another person without their password, usually by stealing something that stands in for it.
- API: a defined way for one piece of software to ask another for data or actions, like a service counter with set requests.
- Authentication: proving who you are, normally by logging in.
- Authentication cookie: a cookie that a site uses to remember that you are logged in.
- Authentication server: the central service that checks logins for several sites.
- Authentication token: a piece of text that stands in for a login and can be exchanged for a cookie.
- Browser: the program you use to view web pages, such as Firefox or Chrome.
- CORS (Cross Origin Resource Sharing): a way for a server to say which other origins are allowed to read its responses.
- Cookie: a small piece of text a site asks your browser to store and send back on later requests to that site.
- CSP (Content Security Policy): response headers that tell the browser what a page may load or embed.
frame-ancestors: a CSP setting that says which pages may embed this response in a frame.- HSTS (Strict-Transport-Security): a header telling the browser to keep using HTTPS for a site.
- HTTP: the language browsers and servers use to exchange requests and responses.
- HTTP request: a message a browser sends to a server asking for something.
- HTTP response: the message a server sends back.
- JavaScript: the programming language that runs in web pages.
- JSON: a text format for structured data, made of names and values.
- JSONP: a way of sending data as JavaScript so another origin can read it, which bypasses the Same Origin Policy.
- jQuery: a popular JavaScript library that simplifies common tasks.
- Origin: the combination of protocol, host and port, such as
https://market.kz. - Same Origin Policy (SOP): the browser rule that a page may only read data from its own origin.
- Single Sign-On (SSO): one login that works across several related websites.
- Token: see authentication token.
- Vulnerability: a weakness in software that someone can abuse.
- XMLHttpRequest: the older browser mechanism for fetching data from a server in the background.