TeachLAFrontend icon indicating copy to clipboard operation
TeachLAFrontend copied to clipboard

Arbitrary Same-Origin Stored XSS on React + HTML Outputs

Open bliutech opened this issue 2 years ago • 2 comments

Initially disclosed to @mizlan privately. Opening this issue for easier tracking and documentation.

Vulnerability

On https://editor.uclaacm.com, there is an arbitrary Same-Origin Stored XSS for outputs of the editor specifically for both React & HTML. The issue arrises from lack of sandboxing of the output while using srcdoc causing the embedded content to be on the same origin as the editor (source code). The impact could be that an adversary is able to share a page with a payload which could exfiltrate private data about a user or lead to arbitrary writes or downloads.

POC

React: image

HTML: image

Fix

The solution to this is to introduce the sandbox property to the output iframe. This can be done in the following source code with a behavior of sandbox="allow-scripts allow-modals". This would allow many of the current features to be maintained while allowing resources to be isolated by the Same-Origin Policy.

image

bliutech avatar Aug 30 '23 21:08 bliutech

What are some tests I can do after a fix to ensure I've resolved the problem? @bliutech

Is it enough to check the document.domain property?

mizlan avatar Aug 31 '23 02:08 mizlan

Yes. If the origins are not the same, then the Same-Origin Policy applies which should address this issue. 👍

bliutech avatar Aug 31 '23 02:08 bliutech