Today we looked at 3rd party authentication and web security.
We built a simple Express.js web app that uses Passport to allow users to sign in with Google.
After that we used Wireshark to snoop on network trafic to that web app to get an authenticated user's session id to make HTTP requests to the app as them.
We tried to inject a script in the URL, but Chrome blocked it. However, we then put a script in the "database" and it was successfully executed in the browser.
We took a look at a cross-site request forgery. We made a malicious web page with a form that submits to our app and saw that the app cookies were sent along with the request from our malicious site.
We telnet
ed into our app to see that an HTTP request can be hand-crafted
including the Referer header, which is supposed to say where the request
originated, but is easily spoofed.
GET / HTTP/1.1
Host: 127.0.0.1
Referer: http://this-isnt-the-website-youre-looking-for.com/index.html
We saw what happens when your app redirects the user to a path that was provided by the user. We saw that user info is not trustable and that if a redirect url is provided in user content (the query string, user content in the database, etc.) it must be validated before issuing a redirect.
We went over and talked about each of the OWASP Top 10 security issues.
https://www.owasp.org/index.php/Top_10_2013-Top_10
There is a developer cheat sheet here: