Prevent DOM access (i.e. XHR and such)

Open
#2 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
security

Research direction

Start with the sandboxing discussion and evel.js around line 49, along with the iframe.contentWindow.eval approach cited in the issue. The payload names no vm-browserify file, test, or complete acceptance condition, so the intended DOM/XHR restrictions would need to be defined before implementation.

Written by the indexing model from the issue text.

Description

Just spent today working on a sandboxing thing from a different angle before I found this. Turns out it's actually somewhat complementary!

  1. The iframe.contentWindow.eval trick does a great job preventing an untrusted script from messing with other people's object prototypes.
  2. Combining "use strict"; with a silly closure trick it seems possible to prevent access to all global objects…except object literal prototypes!

You can take a look at what I got on this in https://github.com/natevw/evel/blob/master/evel.js#L49 — I do whitelist the ES5 globals because I assume most code should be allowed to expect them. I'll be the first to admit that masking every global every function call is kind of "not ideal" but AFAICT combining https://github.com/natevw/evel's tricks with this iframe stuff yields a fairly declawed environment.

Dominant language
JavaScript
Stars
205
Forks
41
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from browserify/vm-browserify

All issues in browserify/vm-browserify

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.