21.2 Lab: Forced OAuth profile linking | 2024

This lab gives you the option to attach a social media profile to your account so that you can log in via OAuth instead of using the normal username and password. Due to the insecure implementation of the OAuth flow by the client application, an attacker can manipulate this functionality to obtain access to other users’ accounts. To solve the lab, use a CSRF attack to attach your own social media profile to the admin user’s account on the blog website, then access the admin panel and delete carlos | Karthikeyan Nagaraj

Karthikeyan Nagaraj
3 min readMay 13, 2024

Description

This lab gives you the option to attach a social media profile to your account so that you can log in via OAuth instead of using the normal username and password. Due to the insecure implementation of the OAuth flow by the client application, an attacker can manipulate this functionality to obtain access to other users’ accounts.

To solve the lab, use a CSRF attack to attach your own social media profile to the admin user’s account on the blog website, then access the admin panel and delete carlos.

The admin user will open anything you send from the exploit server and they always have an active session on the blog website.

You can log in to your own accounts using the following credentials:

  • Blog website account: wiener:peter
  • Social media profile: peter.wiener:hotdog

Solution

  1. While proxying traffic through Burp, click “My account”. You are taken to a normal login page, but notice that there is an option to log in using your social media profile instead. For now, just log in to the blog website directly using the classic login form.
  2. Notice that you have the option to attach your social media profile to your existing account.
  3. Click “Attach a social profile”. You are redirected to the social media website, where you should log in using your social media credentials to complete the OAuth flow. Afterwards, you will be redirected back to the blog website.
  4. Turn on proxy interception and click the “Attach a social profile” option again.
  5. Go to Burp Proxy and forward any requests until you have intercepted the one for GET /oauth-linking?code=[...]. Right-click on this request and select "Copy URL".
  6. Drop the request. This is important to ensure that the code is not used and, therefore, remains valid.
  7. Turn off proxy interception and log out of the blog website.
  8. Go to the exploit server and create an iframe in which the src attribute points to the URL you just copied. The result should look something like this:
    <iframe src="https://YOUR-LAB-ID.web-security-academy.net/oauth-linking?code=STOLEN-CODE"></iframe>
  9. Click Deliver the exploit to the victim.
  10. Go back to the blog website and select the “Log in with social media” option again. Observe that you are instantly logged in as the admin user. Go to the admin panel and delete carlos to solve the lab.

--

--

Karthikeyan Nagaraj

Security Researcher | Bug Hunter | Web Pentester | CTF Player | TryHackme Top 1% | AI Researcher | Blockchain Developer