Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to Secure an Angular Web Application

How to Secure an Angular Web Application

n this presentation, we will cover all the elements required to build a secure web application with Angular and Node.

We will discuss SSL/TLS, authentication and authorization, cookies vs JSON Web Tokens (JWT) for session management, password hashing, salting and enforcing password policy. Finally, we will look at how this can be implemented in an example Angular/Node application.

Doug Corbett

May 02, 2018
Tweet

More Decks by Doug Corbett

Other Decks in Programming

Transcript

  1. Mission Accomplished! 1 Counters 3 Router Guards and Roles 4

    What Could Go Wrong? 2 Agenda Final Thoughts 5
  2. Our Mission To build a hospital information to make our

    users dance with joy. * https://i.makeagif.com/media/6-08-2015/KdEXC-.gif
  3. Ingredients • 2 developers • 9 months • 180 pizzas

    * https://cdn-images-1.medium.com/max/1024/1*zRrkoarX94CUZe3-NrSYGg.png * https://memegenerator.net/img/instances/400x/54225850/9-months-later.jpg * https://memegenerator.net/img/instances/400x/54225850/9-months-later.jpg
  4. Ingredients • 2 developers • 9 months • 180 pizzas

    • 1 Designer * https://cdn-images-1.medium.com/max/1024/1*zRrkoarX94CUZe3-NrSYGg.png * https://memegenerator.net/img/instances/400x/54225850/9-months-later.jpg * https://memegenerator.net/img/instances/400x/54225850/9-months-later.jpg * https://i.pinimg.com/origin als/da/a3/55/daa3555f434 9314994b753b4467b88af.j pg
  5. Flow - Login network sniffer network sniffer plain text passwords

    disabled security dictionary attack weak passwords
  6. Flow - Login network sniffer network sniffer plain text passwords

    disabled security dictionary attack dictionary attack weak passwords
  7. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords
  8. Cookie Hijacking The stealing of a sessionid store as a

    cookie in the victims browser and passed with every call to the server.
  9. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF
  10. Cross Site Request Forgery (CSRF) • An attack whereby the

    attacker only needs your email or for you to click on a link to send a get or post request to an api, possibly triggering an action. • Especially dangerous for restful apis that do not rely on request bodies. • A “blind” attack. Attacker is limited in what they can do.
  11. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF
  12. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF password policy
  13. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls
  14. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls hashing
  15. Hashing • An algorithm used to convert a string into

    a fixed length alphanumeric string Characteristics 1. Easy to create a hash value from an input 2. Extremely difficult, if not impossible, to determine the input from a hash value 3. While possible it is extremely unlikely for two inputs to produce the same hash value
  16. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls hashing require admin user password
  17. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls hashing require admin user password 3x lockout or time delay
  18. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls hashing require admin user password 3x lockout or time delay dictionary attack salting
  19. Salt Random data that is used as additional input in

    hashing algorithms. Minor changes make a big difference in the hash value.
  20. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls hashing require admin user password 3x lockout or time delay dictionary attack salting double cookie
  21. Double cookie Add extra header called “crf-token”. Then the server

    will look for both cookies to verify the request is legitimate.
  22. Flow - Login network sniffer network sniffer plain text passwords

    disabled security cookie hijacking dictionary attack weak passwords CSRF password policy ssl / tls ssl / tls hashing require admin user password 3x lockout or time delay dictionary attack salting double cookie Gets with no side effects
  23. Open Web Application Security Project (OWASP) A worldwide not-for-profit charitable

    organization focused on improving the security of software. https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
  24. JSON Web Tokens An alphanumeric string representing claims between parties

    enabling stateless servers and third party authentication. Parts • Header • Payload • Signature HS256 – signature algorithm that based on secrets RS256 – signature algorithm based on public key cryptography
  25. Tools to Secure Your App • SSL/TLS • Password policy

    • Argon2 hashing algorithm with salted inputs • JWT – RS256 • Make sure security is enabled on your database • If using cookies, use http only cookies
  26. Reference Materials Official Angular Documentation https://angular.io ng-book – The Complete

    Book on Angular 4 – Nathan Murray and Ari Lerner Open Web Application Security Project https://www.owasp.org How to Secure an Angular Web Application https://github.com/dougcorbett/event-demo Angular 5 Security Masterclass https://www.udemy.com/angular-security The Complete Node.js Developer Course (2nd Edition) https://www.udemy.com/the-complete-nodejs-developer-course-2