-
Attacks
- XSS
- Social Engineering right to Privacy
- XSRF
- Form Spoofing
-
Avoidance
- never trust data
-
HtmlEncoding
- avoid WebForms view engine
- use Spark or nHaml
- use Html.AntiforgeryToken
- respect user's privacy
-
XSS Demo
- it's OK to use Asp.Net Membership
-
a ton of settings
- hashed password format
- alter ApplicationName
- require 8 pwd chars
- invalid pwd attempts
- require some non-alpha chars
- change <forms path=
-
the problem
- enter some JS script into textbox
- disable auto page validation
- [ValidateInput(false)]
- arbitrary JS could scrape cookies etc...
- Html.Encode - easy to forget
- how to allow input of Html?
-
AntiXSS library
- sanitize HTML
- perf. benefit
- enocdes for:
- JavaScript
- HTML
- XML
-
using AntiXss lib
- static XssHelper
- HtmlEncode
-
GetSafeHtml
- strips bad stuff out
- use Spark - encoding on by default
-
Trickery Demo
- using your users against you
- getting a site to divulge
- mining personal data on the web
- you've been HAACKED
-
Form spoofing Demo
- copy form contents
- alter the form post to post to (full) originating URL
- alter hidden field (username=admin)
- change the admin password
-
ValidateAntiforgeryToken
- get the token from the hidden field
- (requires same browser)
- only guarantees post is coming from same user
- don't accept the username as a param from the form
- use [Authorize]
-
Right-highjacking
- user could alter an IsAdmin property
- whitelist the properties allowed to include on UpdateModel
-
CSRF demo
-
the problem
- the Black Hats are always smarter than you
- see also the HaaHa show
- the html contains no info to uniquely identify the user
- the 'remember me' cookie
- allowing an Avatar without sanitization
- script injection
- "textarea is an XSS IDE"
- invisible IFrame filled with some HTML
- broken IMG tags are always a clue
- injected JS calls submit on the injected invisible form
- any visitor to the site who is ALSO logged into the victim site will execute the bad actions
-
avoidance
- ValidateAntiForgery