Skip to content

chore: tighten up REPL security #300

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

Merged
merged 2 commits into from
Oct 9, 2024
Merged

chore: tighten up REPL security #300

merged 2 commits into from
Oct 9, 2024

Conversation

dummdidumm
Copy link
Member

  • don't allow top level navigations without user interaction (prevents stuff like an eager window.load())
  • don't allow links to other pages to escape sandbox restrictions (as a result most links don't work) if you're visiting a hashed REPL (we can't remove maliscous code from them since code is encoded into the URL)

Copy link

vercel bot commented Oct 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
omnisite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 3:09pm

- don't allow top level navigations without user interaction (prevents stuff like an eager `window.load()`)
- don't allow links to other pages to escape sandbox restrictions (as a result most links don't work) if you're visiting a hashed REPL (we can't remove malicious code from them since code is encoded into the URL)
Comment on lines 257 to 259
'allow-modals',
can_escape ? 'allow-popups-to-escape-sandbox' : '',
relaxed ? 'allow-same-origin' : ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question

Suggested change
'allow-modals',
can_escape ? 'allow-popups-to-escape-sandbox' : '',
relaxed ? 'allow-same-origin' : ''
'allow-modals'

Copy link
Member Author

@dummdidumm dummdidumm Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without allow-popups-to-escape-sandbox, when you click on an outgoing link, you'll get a "browser has blocked the response" on the page that opens. It's an edge case for sure, but maybe there's playgrounds which showcase a certain aspect of their library and have a link with "you can read more about this here". Because it's potentially malicious it's only allowed on saved-to-db-REPLs which we could delete if the need arises.

Without allow-same-origin you can't access the parents localstorage,cookies, etc. With the headers being set due to the web container stuff, you also can't access the static images served from the parent domain (e.g. the Rick Roll wouldn't work anymore in the tutorial) - though that part could also be solved through #301. Currently this is only set for things that aren't user-content, i.e. the tutorial, because else this would be dangerous. I'm not sure why this was originally added (preceedes my time at Svelte)

@Rich-Harris Rich-Harris merged commit 2550097 into main Oct 9, 2024
3 checks passed
@Rich-Harris Rich-Harris deleted the repl-security branch October 9, 2024 15:25
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

Successfully merging this pull request may close these issues.

2 participants