Sie kennen die bekannten Angriffsvektoren wie SQL-Injections oder XSS. Ihre Anwendung ist sicher. Ist Sie das wirklich? Auch wenn Sie in Ihrer Webanwendung kein HTML5 einsetzen, die Browser sind bereit! Kennen Sie alle neuen Markups? Haben Sie bereits die Potentiale von Cross Origin Requests, WebSockets oder Local Storage auf dem Radar? Lernen Sie neue Gefahrenpotentiale kennen, die durch die Unterstützung von HTML5 und dessen APIs entstanden sind. - See more at: http://www.developer-week.de/Programm/Veranstaltung/(event)/11133#sthash.ZRPweawl.dpuf
15. 1.Hier sollten dynamische
Daten niemals verwendet werden
<script> </script>
<!-- HIER -->
<div HIER="test"/>
<HIER href="test" />
<style> </style>
HIER
HIER
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 - <b>TEST</b> - 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=""">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=""">Test</a>'.
Error: Expected '<a title=""">Test</a>' to equal '<a title=""">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
37. SOP
Same origin policy → Not macht erfinderisch (JSONP)
CORS
Cross-Origin Resource Sharing → Access-Control-Allow-Origin: *
WebSockets
do what you want