From the course: Security in ASP.NET Core
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Cross-site scripting (XSS): The defense - ASP.NET Tutorial
From the course: Security in ASP.NET Core
Cross-site scripting (XSS): The defense
- [Instructor] In order to defend against cross-site scripting, let's have a closer look why the attack worked in the first place. When we look at the source code, then we'll find the place where the search term is output. So here it's output verbatim. So there is now a script tag in the HTML and script tag is an indicator for the browser to essentially say, 'Okay, this is JavaScript code, let's run it.' Here, the search term appears again, but here we also have some kind of HTML escaping in place. So the angular brackets, which denote an HTML tag, they're properly escaped. But we are here in JavaScript, we are not in HTML. So here it doesn't actually help us that much. But the problem indeed is up here. Let's have a look at the implementation. So we had Html.Raw which did not do any HTML escaping, verbatim output, that was a problem and we saw that when just outputting something with @, it looked a little bit better. And indeed that's an important countermeasure. If we are outputting…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
OWASP Top Ten2m 45s
-
(Locked)
Cross-site scripting (XSS): The attack4m 33s
-
(Locked)
Cross-site scripting (XSS): The defense3m 25s
-
(Locked)
Cross-site scripting (XSS) in JavaScript4m 40s
-
(Locked)
Cross-site scripting (XSS) in single-page applications3m 30s
-
(Locked)
Same-origin policy and CORS4m 26s
-
(Locked)
Enabling CORS in ASP.NET Core web API6m 23s
-
(Locked)
SQL injection with ADO.NET2m 25s
-
(Locked)
SQL injection with Entity Framework Core2m 34s
-
(Locked)
Fixing SQL injection5m 23s
-
(Locked)
Cross-Site Request Forgery (CSRF): The attack5m 25s
-
(Locked)
Cross-Site Request Forgery (CSRF): The defense7m 11s
-
-
-
-
-