OAuth `redirect_uri` bypass using IDN homograph attack resulting in user's access token leakage
The OAuth implementation failed to properly validate the redirect_uri parameter, allowing an attacker to use an IDN homograph domain that looks like the legitimate one. An attacker could register the punycode version of that domain and receive the user's OAuth code, leading to unauthorised access to the user's account data.
Originally disclosed on HackerOne
- Triaged in 32 hours
- Fixed in 13 days
- Paid in 9 days
- Disclosed after 50 days
Issue Summary:
It was found that SEMrush OAuth implementation fails to properly validate the value of redirect_uri parameter which was bypassed using IDN homograph attack which results in leaking the user's access token to an attacker-controlled domain name.
IDN homography attack exploits the fact that many different characters look alike such as semrush.com is different from sеmrush.com because in the latter we used the Cyrillic letter е which looks exactly like the latin e.
Similarly, all below domain names will be treated as valid since the backend is somehow not idempotent since it will be fooled to map those to semrush.com.
- sémrush.com
- sêmrush.com
- sèmrûsh.com
- šemrush.com
- etc.
Proof of concept:
- Authenticate to your account then browse to (Note the
redirect_uriis set tooauth.šemrush.com):
https://oauth.semrush.com/oauth2/authorize?response_type=code&scope=user.info,projects.info,siteaudit.info&client_id=seoquake&redirect_uri=https://oauth.šemrush.com/oauth2/success
2 . Once you approve the SEMrush application, your OAuth code will be sent to oauth.šemrush.com which is equivalent to oauth.xn--emrush-9jb.com since the browser will translate it to the punycode version which is way to represent IDNs with characters (A-Z, 0-9) supported by DNS.
████
The attacker will simply register the following domain name xn--emrush-9jb.com for this purpose. See:
█████
Impact
As demonstrated earlier, a successful attack will result in leaking the user's OAuth code to an attacker-controlled domain name giving them unauthorized access to properties and data of the user's account.
Regards, Yassine Aboukir
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
Likely the OAuth server validated the redirect_uri by comparing it to an allowed domain after normalising or decoding internationalised domain names, without converting to punycode or enforcing an exact match, so visually similar domains were accepted.
Impact
A successful attack could leak the user's OAuth code to an attacker-controlled domain, giving the attacker unauthorised access to the user's account properties and data.
What the attacker needed
Victim has an account; victim clicks a crafted OAuth link; attacker registers a homograph domain
How it was found
- Authenticate to your account.
- Browse to the OAuth authorisation URL with the redirect_uri set to the homograph domain.
- Approve the SEMrush application.
- The OAuth code is sent to the attacker-controlled homograph domain.
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 website sends you to that service and then back. The 'redirect_uri' tells the service where to send you back. If the service doesn't check this address carefully, an attacker can trick it into sending the login code to a fake website that looks almost identical to the real one, because some letters from other alphabets look the same. The attacker then uses that code to access your account.
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.