HTML5 Attack and Secure was a two-day application security training, recorded on the site as held in Kochi, India, in 2015. Day 1 built the developer-side picture of HTML5: new tags and input types, local storage and application cache, the DOM, WebSockets, web workers, server-sent events, and iframe sandboxing, each backed by hands-on page writing. Day 2 flipped to the attack side, working through XHR and CORS weaknesses and finishing with DOM-based XSS exploitation. The course materials were later released publicly on GitHub in April 2020.
Summary
The session was structured build first, break second. Day 1 covered the HTML5 vocabulary: CORS, JSON, the newer tags, local storage and WebSQL, the DOM, web workers, Web APIs, WebSockets, and iframe sandboxing, with participants writing simple pages against each concept. Day 2 attacked, first XHR and CORS, then DOM exploitation. The opening slides set context: the instructor’s profile (web, mobile, and Linux server specialization, SANS GWAPT, RHCE, and CEH certifications, co-author of the OWASP Testing Guide, project lead of Android Tamer and CodeVigilant) and an audience round collecting names or nicknames, HTML5 comfort levels, and expectations for the course.
Day 1 positioned HTML5 as created by WHATWG and W3C and released as a stable W3C Recommendation on October 28, 2014, with eliminating Flash named as the limelight point. Syntax modernization ran from the collapsed DOCTYPE through figure and figcaption, semantic header, footer, and article elements, contenteditable, new input types with pattern validation and placeholder text, and the geolocation API. Storage followed: localStorage and sessionStorage holding key/value pairs with 5 to 10 MB offered per domain, and application cache manifests served as text/cache-manifest for offline browsing, caching fonts, splash images, app icons, and entry pages while never caching CSS, HTML, or JavaScript. The remaining survey covered the WebSocket handshake with its Upgrade and Sec-WebSocket headers and the ws and wss schemes, background web workers, automatically pushed server-sent events, and a frame-busting bypass where an iframe carrying the sandbox attribute frames a page protected by if(self == top) code anyway.
Day 2 opened with XMLHttpRequest: a callback-based sample request, then the verdict that XHR is not a silver bullet, since the same origin policy blocks cross-origin reads until CORS relaxes it. Origin was defined strictly by protocol, host, and port, and cross-origin interactions were sorted into writes (redirects, links, form actions), embedding (script, CSS, img, media, fonts, frames), and reads, which are not allowed without CORS. Simple requests (HEAD, GET, or POST without custom headers, a text/plain body, no cookies in request or response) skip preflight; everything else triggers an OPTIONS exchange carrying Origin and Access-Control-Request-Method with optional Access-Control-Request-Headers, answered by the Access-Control-Allow response headers and their Max-Age caching. Marking Access-Control-Allow-Origin with * was flagged as bad practice that turns the content into a public resource.
Five CORS weaknesses followed: universal allow, which lets an attacker reach intranet data through a victim’s browser; the Origin header indicating but never guaranteeing the requesting domain, so access control based on it falls to spoofing; long Access-Control-Max-Age values keeping stale preflight policies alive in the browser cache; misplaced trust, where compromising either end of a CORS exchange yields XSS against the other; and CSRF with CORS, where .withCredentials = true replays cookies so a victim viewing trusted site A triggers a non-idempotent action at site B. Preventive checks asked for single non-empty Origin and Host headers validated against an internal whitelist, sender IP caching with HTTP 403 after one non-whitelisted origin, strict IP filtering for B2B setups, and per-origin permission sets.
The DOM exploitation block defined the model as a hierarchy of nodes navigable through firstChild, childNodes, and nextSibling, then mapped sources (document.cookie, window.name, document.URL and URLUnencoded, the location variants, and the referrer) into sinks (innerHTML, outerHTML, document.write, eval, execScript, setTimeout, setInterval, script.src, iframe.src, and location.replace or assign). Regular expressions were provided for locating sources, sinks, and jQuery specific sinks, with andlabs.org, DOMSnitch, RA2, and Dominator listed as tooling. Exercises spanned an HTML4 to HTML5 conversion, a storage-backed form, and framing a frame-busting page, and the materials were later published at github.com/anantshri/html5_attack_and_secure.
Key Themes
- Build First, Break Second: Day 1 develops working knowledge of the HTML5 surface and Day 2 attacks CORS, XHR, and the DOM, so each attack technique lands on technology the audience has just built with.
- HTML5 as the Current Generation: standardized as a W3C Recommendation in October 2014 and framed as the technology that can retire Flash from the web.
- Client-Side Storage and Offline Apps: localStorage, sessionStorage, and manifest based application cache move real data into the browser, with caching rules that deliberately exclude CSS, HTML, and JavaScript.
- Real-Time and Background APIs: WebSockets, web workers, and server-sent events change what a page can do without user action, expanding the attack surface accordingly.
- Sandboxing Against Frame-Busting: the iframe sandbox attribute defeats JavaScript frame-busting checks, showing new HTML5 protection interacting with older defense code.
- CORS Mechanics and Failure Modes: simple versus preflighted requests, the full header set, and five weaknesses running from universal allow to CSRF via withCredentials.
- DOM-Based XSS as Source and Sink Analysis: attacker-controlled values enter through document properties and exit through HTML creating or code executing sinks, found with regex patterns and dedicated tools.
Notable Points
- HTML5 was released as a stable W3C Recommendation on October 28, 2014; the deck credits WHATWG and W3C as its creators.
- Origin is protocol plus host plus port: http://127.0.0.1, https://127.0.0.1, and http://127.0.0.1:8080 are three different origins, and path differences matter too.
- Browsers of the period offered 5 to 10 MB of local storage per domain; sessionStorage parallels localStorage but is limited to the current browser session.
- App cache manifests are served with Content-Type: text/cache-manifest and divide resources into CACHE, NETWORK, and FALLBACK sections; fonts, splash image, app icon, entry page, and fallback bootstrap belong in cache, never CSS, HTML, or JavaScript.
- The WebSocket handshake example uses Sec-WebSocket-Key on the request and Sec-WebSocket-Accept in the HTTP/1.1 101 Switching Protocols response, with Sec-WebSocket-Version: 13.
- Frame-busting code checking self against top is bypassed by
<iframe sandbox src="/examples/framebuster.html" />.
- Simple CORS requests require HEAD, GET, or POST via XHR, no custom headers, a text/plain body, and no cookies; preflight triggers on PUT or DELETE, custom headers like X-PINGBACK, or content types beyond application/x-www-form-urlencoded, multipart/form-data, and text/plain.
- The example preflight response lists Access-Control-Allow-Origin for http://www.example.com and https://login.example.com with Access-Control-Max-Age: 86400.
- The origin spoofing demo used
curl --header 'origin:http://someserver.com' against an origin_spoof.php target; the CSRF scenario has site B create a user account without the victim’s knowledge via .withCredentials = true.
- DOM sources such as document.cookie, window.name, the document.URL and location variants, and the referrer flow into sinks like innerHTML, outerHTML, document.write, eval, execScript, setTimeout, setInterval, script.src, iframe.src and location.replace or assign, with andlabs.org, DOMSnitch, RA2 and Dominator listed as tooling.
Notable Quotes
“Next generation of HTML (now current generation)”
“Limelight Point: Can eliminate flash from web”
“Web Storage is more secure and faster.”
“I can never be framed”
“So XHR allows me to fetch content and get response too so what’s the problem”
“Relax same origin policy and allow third party read”
“Can be set to * to make resources public (bad practice!)”