The Spanner logo
    • Home
    • Blog
      • Blog home
      • RSS
    • Login
    • Home
    • Blog
      • Blog home
      • RSS
    • Login
    The Spanner logo

    The Spanner
    Web security blog

    Made by Gareth Heyes
    Follow me on Twitter: @garethheyes

    Javascript for hackers!

    Hackvertor logo
    Shazzer logo
    My Github account
    Recent posts
    Introducing Feedworm: A Privacy-First RSS Reader That Lives in DevToolsSpeedy RSVP extensionAutoVaderHackvertor history and tag finderShadow Repeater v1.2.3 releaseBurp Hackvertor v2.1.24 releaseHacking roomsXSSing TypeErrors in SafarivalueOf: Another way to get thisMaking the Unexploitable Exploitable with X-Mixed-Replace on FirefoxThe curious case of the evt parameterCSS-Only Tic Tac Toe ChallengeRewriting relative urls with the base tag in SafariBypassing DOMPurify with mXSSNew IE mutation vectorHow I smashed MentalJSMentalJS DOM bypassAnother XSS auditor bypassXSS Auditor bypassBypassing the IE XSS filterUnbreakable filterMentalJS bypassesmXSSJava SerializationBypassing the XSS filter using function reassignmentRPOSandboxed jQueryX-Domain scroll detection on IE using focusEpic fail IEnew operatorDecoding complex non-alphanumeric JavaScriptHacking FirefoxDOM ClobberingBypassing XSS AuditorThe evolution of codeNon-Alpha PHP in 6-7 charsetTweetable PHP-Non AlphaMentalJS for PHPOpera x domain with video tutorialSandboxing and parsing jQuery in 100ms

    Cross browser javascript sandbox

    By Gareth Heyes (@hackvertor)

    Published 17 years 2 months ago • Last updated March 22, 2025 • ⏱️ < 1 min read

    ← Back to articles

    I think I've managed to create a good sandboxing system using same origin policy. The only downside is that it uses new windows to prevent top.location assignments. It works by injecting code into another domain (sandbox.businessinfo.co.uk) and executing the code in the context of that domain and returning the result of the code in the location.hash and returning it to the original domain.

    As SOP is used the sandbox shouldn't be able to be bypassed without a browser exploit, sure you could change the window reference but the result would always be a string. The domain sandbox.businessinfo.co.uk is vulnerable though as it allows you to execute code, maybe using referrer checking this could be minimized which I may add in future.

    So the question is can you beat it? By injecting code in the sandbox that will control the parent. For example it was vulnerable to modifying the parent location by passing "top.location=1" this has now been closed.

    Update...

    I found and fixed an exploit myself. Using opener.location=1, it was possible to control the parent location. I've closed this by removing the opener from the sandbox.

    Demo here

    ← Back to articles