Skip to content
XSS Write-up Intermediate

Single Sign On (SSO) Login vulnerabilities

A silent single sign-on flow loads the identity provider's callback inside a hidden iframe, and that callback forwards its own URL, which contains a token or authorisation code, to the parent window using a wildcard postMessage target. Because the target origin is not restricted and the iframe endpoint lacks framing protections, an attacker who gets a victim to load a crafted page could receive the leaked token or code.

medium.com

Published on medium.com

Bugbounty

wann4beSh3rl0ck, on 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. 5 min read.

Context

This write-up looks at a pattern seen in Single Sign On (SSO) implementations: a silent login flow that loads an authentication callback inside a hidden iframe instead of performing a full-page redirect. In a normal login flow the whole page is redirected to the identity provider (IdP) and back. In the silent variant the application creates a hidden iframe pointed at the IdP's auth endpoint with prompt=none, the IdP checks whether the user already has a session, and the iframe is redirected to a callback page carrying a token or authorization code in its URL. That callback page then has to hand the token or code back to the main application, because JavaScript in the parent page cannot read the URL of a cross-origin iframe.

The report describes the mechanism and lists the conditions commonly seen alongside it. It does not name a specific target, program, endpoint, parameter or version, and it gives no bounty or severity figures.

Setup

The report does not describe accounts, roles, tools or versions. The only precondition it sets out is the shape of the flow itself: an application that performs silent SSO through a hidden iframe, and a callback page inside that iframe that forwards its own URL to the parent window with postMessage.

Finding it

The researcher starts from the three steps of the silent flow:

  1. The app loads a hidden iframe pointing at the IdP's auth endpoint with prompt=none.
  2. The IdP silently checks whether the user is already logged in, then redirects the iframe to a callback page with a token or code attached to the URL.
  3. The callback page running inside the hidden iframe needs to get the token or code out of the iframe and into the main app, since JavaScript in the parent page cannot directly read the iframe's URL if it is cross-origin.

The only way to pass data across the origin boundary is postMessage. The issue is the way that call is written:

JavaScript
parent.postMessage({type: 'onload', data: window.location.href}, '*')
From the original on medium.com

This is doing exactly step 3: it grabs its own current URL, which now contains the silently issued token or authorization code, and forwards it to window.parent, the main application window that created the iframe in the first place. The type: 'onload' label suggests the message fires as soon as the iframe finishes loading the callback, effectively telling the parent that it is done and what it ended up with.

The postMessage bridge is the standard mechanism for getting the result out of the hidden iframe back to the app, because there is no other way for the parent page's JavaScript to read a cross-origin iframe's URL directly. Seeing this pattern, a hidden iframe plus a postMessage that reports window.location.href on load, is essentially the fingerprint of a silent-SSO or silent-token-renewal implementation.

From the original on medium.com

Exploitation

The report does not walk through a live exploitation against a named target. It describes the attack in general terms and lists the conditions commonly seen alongside it. The researcher notes that this exact pattern has shown up in real bug bounty reports against major SSO and IdP implementations, and lists the common denominators:

  • postMessage(data, '*') instead of a specific origin.
  • Missing or weak X-Frame-Options or frame-ancestors CSP on the silent-auth iframe endpoint.
  • Missing origin validation.

Step 1: Get the victim to load the attacker's page

The attacker distributes a link through phishing email, a malicious ad campaign, a link in a Discord or Slack channel, a QR code, a compromised third-party widget embedded on other sites, SEO poisoning, or anything else that gets a victim to load that page in their browser. The report describes this as the embedding of the redirect URI.

Step 2: The page frames the silent-auth endpoint

Where the silent-auth iframe endpoint lacks or has weak X-Frame-Options or frame-ancestors CSP, the attacker's page can embed it in an iframe.

Step 3: The callback posts the token to the wrong parent

The callback page inside the iframe runs parent.postMessage({type: 'onload', data: window.location.href}, '*'). The '*' target origin means the browser delivers the message to whatever window is the parent, regardless of its origin. If the iframe is embedded by the attacker's page rather than the legitimate application, the parent would be the attacker's window.

Root cause

The mistake is in the callback page's postMessage call. The target origin is '*', so the message is sent to any parent window, and the report also lists missing origin validation as a contributing factor. Combined with a silent-auth iframe endpoint that can be framed from other origins, this lets a page controlled by an attacker receive the message that contains the token or authorization code.

The pattern is risky because the silent-auth iframe endpoint may lack or have weak X-Frame-Options or frame-ancestors CSP, and the '*' target origin lets any parent receive the message.

Impact

When the conditions above hold, a page controlled by an attacker could receive the message that the callback page sends to its parent, and that message contains the URL with the silently issued token or authorization code. The pattern relies on the victim having an active IdP session, the silent-auth endpoint being frameable and the callback using a wildcard target origin.

Fix

Based on the conditions it lists, the changes that address the pattern are: send the message to a specific origin instead of '*', validate the origin of incoming messages, and set X-Frame-Options or a frame-ancestors CSP on the silent-auth iframe endpoint so it cannot be framed by other origins.

Variants to test

  • Look for hidden iframes pointed at an IdP auth endpoint with prompt=none. A positive result is a callback page that reports window.location.href to its parent on load.
  • Check the target origin argument of the postMessage call. A positive result is '*' rather than a specific origin.
  • Request the silent-auth iframe endpoint from a page on another origin. A positive result is that the response can be framed, meaning X-Frame-Options is missing or weak and frame-ancestors does not restrict the origin.
  • Check whether the receiving application validates the origin of incoming messages. A positive result is that messages from an unexpected origin are accepted.
  • Try the same pattern on silent-token-renewal flows, which the report groups under the same fingerprint.

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. 11 min read.

What happened, in plain words

This write-up is about a pattern in Single Sign On (SSO) systems. SSO is the "log in with Google" or "log in with your company account" button you have probably clicked: instead of making a new password for every site, you log in once with an account you already have, and other sites trust that account. The company that owns the account is called the identity provider, or IdP.

The pattern described here is a silent login. In a normal login the whole browser page jumps to the IdP, you log in, and you are sent back. In a silent login the application does not move the page at all. It quietly loads a small hidden window inside the page, asks the IdP "is this person already logged in?", and if the answer is yes, the IdP sends back a token or code. That credential has to travel from the hidden window back into the main page, and the way it travels is where things can go wrong.

The report does not name a specific company, website, endpoint, parameter or version, and it gives no bounty or severity figures. It describes the mechanism and the conditions under which it becomes dangerous.

The setup

The report does not describe accounts, roles, tools or versions. The only precondition it sets out is the shape of the flow itself: an application that performs silent SSO through a hidden iframe, and a callback page inside that iframe that forwards its own URL to the parent window with postMessage.

A few words before we go further, because the rest of the article leans on them:

  • Iframe: a window inside a window. A web page can contain a rectangle that loads another page, from the same site or from a different one. Think of a picture frame hanging on a wall: the wall is the main page, the picture is the other site.
  • Origin: the combination of protocol, hostname and port, for example https://example.com. Browsers treat two pages from different origins as strangers, and stop them from reading each other's contents. This is a core safety rule of the web.
  • Token or authorization code: a short string that proves "this person logged in". It is like a cloakroom ticket: whoever holds it can collect the coat. If someone else gets the ticket, they can collect the coat too.
  • postMessage: the browser's official way for two windows from different origins to send each other a message. Since they cannot read each other directly, they pass notes instead.

Finding it

The researcher starts from the three steps of the silent flow:

  1. The app loads a hidden iframe pointing at the IdP's auth endpoint with prompt=none.
  2. The IdP silently checks whether the user is already logged in, then redirects the iframe to a callback page with a token or code attached to the URL.
  3. The callback page running inside the hidden iframe needs to get the token or code out of the iframe and into the main app, since JavaScript in the parent page cannot directly read the iframe's URL if it is cross-origin.

Step by step in plain words:

  1. The application creates an invisible frame and points it at the IdP's login address. The extra instruction prompt=none means "do not show me a login screen; just tell me quietly whether this person is already logged in".
  2. The IdP looks at the browser's existing session (the cookie that says "this person logged in earlier") and, without any user interaction, sends the frame onward to a callback page. That callback address has the token or code stuck onto the end of it, in the URL.
  3. Now the token sits inside the hidden frame, but the main page needs it. Because the frame and the main page are usually on different origins, the main page's JavaScript is not allowed to look inside the frame or read its address. The only bridge between them is postMessage.

The issue is the way that call is written:

JavaScript
parent.postMessage({type: 'onload', data: window.location.href}, '*')
From the original on medium.com

Line by line:

  • parent is the window that created this iframe, in other words the main application page.
  • .postMessage(...) sends a message to that window.
  • {type: 'onload', data: window.location.href} is the content of the message. window.location.href is the callback page's own current address, the one with the token or code on the end. The type: 'onload' label is just a tag saying what kind of message this is.
  • '*' is the target origin. It means "deliver this to whatever window is my parent, no matter which website it belongs to". That is the part that matters, and we will come back to it.

This is doing exactly step 3: it grabs its own current URL, which now contains the silently issued token or authorization code, and forwards it to window.parent, the main application window that created the iframe in the first place. The type: 'onload' label suggests the message fires as soon as the iframe finishes loading the callback, effectively telling the parent that it is done and what it ended up with.

The postMessage bridge is the standard mechanism for getting the result out of the hidden iframe back to the app, because there is no other way for the parent page's JavaScript to read a cross-origin iframe's URL directly. Seeing this pattern, a hidden iframe plus a postMessage that reports window.location.href on load, is essentially the fingerprint of a silent-SSO or silent-token-renewal implementation.

From the original on medium.com

"Fingerprint" here means a recognisable shape. If you are testing a site and you see an invisible frame plus a message that reports its own address when it loads, you are probably looking at silent SSO or at silent token renewal (the same trick used to refresh a login without bothering the user).

Exploitation

The report does not walk through a live exploitation against a named target. It describes the attack in general terms and lists the conditions commonly seen alongside it. The researcher notes that this exact pattern has shown up in real bug bounty reports against major SSO and IdP implementations, and lists the common denominators:

  • postMessage(data, '*') instead of a specific origin.
  • Missing or weak X-Frame-Options or frame-ancestors CSP on the silent-auth iframe endpoint.
  • Missing origin validation.

Those three need a short explanation each:

  • postMessage(data, '*') instead of a specific origin: the second argument of postMessage is supposed to name the one website allowed to receive the message, for example 'https://app.example.com'. Writing '*' is like addressing a letter "to whoever is standing outside" instead of to a named person.
  • X-Frame-Options and frame-ancestors CSP: two response headers a website can send to say "other sites are not allowed to put me in an iframe". X-Frame-Options is the older one; frame-ancestors is the modern one, set inside a Content Security Policy. If they are missing or weak, any site can frame the page.
  • Origin validation: when a window receives a message, it can check where the message came from. If it does not check, it accepts notes from anyone.

Step 1: Get the victim to load the attacker's page

The attacker distributes a link through phishing email, a malicious ad campaign, a link in a Discord or Slack channel, a QR code, a compromised third-party widget embedded on other sites, SEO poisoning, or anything else that gets a victim to load that page in their browser. The report describes this as the embedding of the redirect URI.

In plain words: the attacker needs the victim to open a page the attacker controls. Phishing email is the obvious route; SEO poisoning means rigging search results so the malicious page ranks highly; a compromised widget means a small piece of code that many sites embed (a chat box, a comment plugin) starts serving the attacker's content. The victim does not have to type a password or click a login button. They only have to land on the page while still logged in to the IdP.

Step 2: The page frames the silent-auth endpoint

Because the silent-auth iframe endpoint lacks or has weak X-Frame-Options or frame-ancestors CSP, the attacker's page can embed it in an iframe.

In plain words: the attacker's page contains a hidden frame pointing at the IdP's silent login address. If the endpoint can be framed and the victim still has an IdP session, the silent check can succeed.

Step 3: The callback posts the token to the wrong parent

The callback page inside the iframe runs parent.postMessage({type: 'onload', data: window.location.href}, '*'). The '*' target origin means the browser delivers the message to whatever window is the parent, regardless of its origin. When the iframe is embedded by the attacker's page rather than the legitimate application, the parent is the attacker's window, and the message carrying the URL with the token or code is delivered there.

In plain words: the callback page does not ask who its parent is. It hands the cloakroom ticket to whoever is holding the frame, which in this scenario would be the attacker's page.

Root cause

The mistake is in the callback page's postMessage call. The target origin is '*', so the message is sent to any parent window, and the report also lists missing origin validation as a contributing factor. Combined with a silent-auth iframe endpoint that can be framed from other origins, this lets a page controlled by an attacker receive the message that contains the token or authorization code.

The pattern is risky because the silent-auth iframe endpoint may lack or have weak X-Frame-Options or frame-ancestors CSP, and the '*' target origin lets any parent receive the message.

Two small mistakes add up to one big hole: the frame can be borrowed by anyone, and the message inside it is addressed to anyone. Either one alone would be much less useful to an attacker.

Impact

When the conditions above hold, a page controlled by an attacker could receive the message that the callback page sends to its parent, and that message contains the URL with the silently issued token or authorization code. The impact depends on the victim having an active IdP session so that the silent check succeeds, and on the silent-auth endpoint being frameable and the callback using a wildcard target origin.

In plain words: the attacker could end up holding a credential for the victim's account. It also does not claim that a full account takeover was demonstrated.

Fix

Based on the conditions it lists, the changes that address the pattern are: send the message to a specific origin instead of '*', validate the origin of incoming messages, and set X-Frame-Options or a frame-ancestors CSP on the silent-auth iframe endpoint so it cannot be framed by other origins.

In plain words: address the letter to a named person, check the sender of every note you receive, and do not let strangers put your page in a frame.

Variants to test

If you want to look for this yourself, these checks follow from the conditions the report lists:

  • Look for hidden iframes pointed at an IdP auth endpoint with prompt=none. A positive result is a callback page that reports window.location.href to its parent on load.
  • Check the target origin argument of the postMessage call. A positive result is '*' rather than a specific origin.
  • Request the silent-auth iframe endpoint from a page on another origin. A positive result is that the response can be framed, meaning X-Frame-Options is missing or weak and frame-ancestors does not restrict the origin.
  • Check whether the receiving application validates the origin of incoming messages. A positive result is that messages from an unexpected origin are accepted.
  • Try the same pattern on silent-token-renewal flows, which the report groups under the same fingerprint.

You do not need special tools for the first two: open the browser's developer tools, watch the network requests while the page loads, and read the JavaScript of the callback page. The third check is a matter of building a small page of your own that frames the endpoint and seeing whether the browser displays it or blocks it.

Glossary

  • SSO (Single Sign On): logging in once with one account and being trusted by several other sites.
  • IdP (identity provider): the service that holds the account and confirms who you are, for example a company login system.
  • Silent login: a login check that happens without showing the user any screen, used when the user is probably already logged in.
  • Silent token renewal: the same hidden check, used to refresh an expiring credential without interrupting the user.
  • Iframe: a page embedded inside another page, in its own little window.
  • Origin: protocol plus hostname plus port; the browser's unit of trust between pages.
  • Cross-origin: belonging to a different origin than the page you are on.
  • Token: a short string that proves a login and can be exchanged for access.
  • Authorization code: a short-lived code issued after login, later exchanged for a token.
  • Callback page: the page the IdP sends the browser to after login, carrying the token or code in its address.
  • URL: the address of a page, including any data appended to it.
  • window.location.href: JavaScript's way of reading the current page's full address.
  • postMessage: the browser feature that lets windows from different origins send each other messages.
  • Target origin: the second argument of postMessage, naming which website may receive the message; '*' means any website.
  • parent / window.parent: the window that contains the current iframe.
  • prompt=none: an instruction to the IdP to answer quietly, without showing a login screen.
  • X-Frame-Options: a response header that tells the browser whether a page may be put in an iframe.
  • CSP (Content Security Policy): a set of rules a site sends to the browser; frame-ancestors is the rule about who may frame the page.
  • Origin validation: checking where an incoming message came from before trusting it.
  • Phishing: tricking someone into opening a link or page controlled by an attacker.
  • SEO poisoning: rigging search engine results so a malicious page appears near the top.
  • Bug bounty: a programme that pays researchers for reporting security flaws.
  • Fingerprint: a recognisable combination of details that identifies a particular implementation.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.