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

    Twitter misidentifying context

    By Gareth Heyes (@hackvertor)

    Published 16 years 5 months ago • Last updated April 1, 2025 • ⏱️ 2 min read

    ← Back to articles

    This is an important post for me, not because it's ground breaking but people don't seem to get this when using data in certain context. If you are a dev please read this and read it until you understand it because if you misidentify context you fail and you fail pretty badly.

    I reported this to twitter about two months ago, they responded and fixed four xss holes but two remain and they didn't contact me to test the fix.

    When you are including user input inside a javascript event within a string what do you have to escape? If you answered: '"<>\
    You are wrong. Twitter is wrong.

    Take the following example:-

    <a href=# onclick="x= 'USERINPUT' ">test</a>

    So you can place your input within the single quotes and there is a place on twitter that does this:- twitterTheseResults(' &amp;quot;'xss','/search?q=&a...

    Here they are escaping &quot; with &amp;quot; and ' with '. But that isn't enough! Why? Because it's a javascript onclick event! Inside an event you have to escape entities! All of them!

    Consider the following vector:-

    &apos;,alert(1),&apos;

    No single quotes but &apos; still acts as one. Please look at this test and make sure you understand how it works:- http://tinyurl.com/xssyoda

    Don't forget other entities work too &#39; &#x27; &#39 &#x27 so make sure you escape all characters within a js event like so:-

    <a href="#" onclick="x='USERINPUT\x27\x22\x3c\x3e'">test</a>

    and Twitter PLEASE fix this and related holes c'mon it's been two months, it's not rocket science to fix.

    &apos; works on non-IE browsers but the other entities mentioned work fine on IE too.

    ← Back to articles