Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code can break out of the iframe and modify parent page (XSS) #125

Closed
tom-sherman opened this issue Feb 13, 2020 · 1 comment
Closed

Code can break out of the iframe and modify parent page (XSS) #125

tom-sherman opened this issue Feb 13, 2020 · 1 comment

Comments

@tom-sherman
Copy link

tom-sherman commented Feb 13, 2020

It is currently possible to access window.parent inside of the render iframes which allows a malicious actor to take advantage of XSS or some accidentally dodgy code to crash the Playroom environment.

Is it within the scope of this project to guard against these sorts of problems?

Example

<div>
	{window.parent.document.body.innerHTML = '<h1>You\'ve been hacked lol</h1>'}
</div>

https://seek-oss.github.io/braid-design-system/playroom/#?code=N4Igxg9gJgpiBcIA8AhCAPAfAHQHbAHcBLXKCAgOgAcBDAJxlwBcKywBXAW0ZYCNoAnhRK4YdABIAVALIAZAAQBeeQHIkACwCMmAJoR22bCoBuMebxiN56mmADWMKPIA2EZ0gD0WzCoC+ntCwQXyA

Potential fixes

Adding sandbox="allow-scripts" to the iframe component fixes this issue at the cost of completely breaking HMR.

I tried evaling the code in a worker but I don't think React components are structured-clonable

Maybe it's possible to use realms-shim with a bit of work?

@mattcompiles
Copy link
Contributor

This should be resolved by #157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants