web security and auth
play

Web Security and Auth Shan-Hung Wu CS, NTHU Outline Security - PowerPoint PPT Presentation

Web Security and Auth Shan-Hung Wu CS, NTHU Outline Security risks of web applications Injection, broken authentication , XSS, CSRF, etc. Checklist of 23 Node.js security best practices Auth: Authentication, authorization, and


  1. Web Security and Auth Shan-Hung Wu CS, NTHU

  2. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 2

  3. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 3

  4. Authentication vs. Authorization • Authentication : the process to verify you are who you said • Authorization : the process to decide if you have permission to access a resource 4

  5. Session Management • The process of securely handling multiple requests to a server from a single client (user) 5

  6. Were to Store Session States? • Server – Stateful sessions – Server processes requests based on the states • Client – Stateless sessions – Server processes requests based on their content 6

  7. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 7

  8. Which one should I choose? 8

  9. Evaluation Criteria • Complexity • Reliance on HTTPS • Reliance on CSRF protection • Replay and integrity protection • Session management • User cases & tips 9

  10. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 10

  11. How It Works • A client attaches clear text password to each request: // Request from client Authorization: Basic base64(username:password) • Seriously? 11

  12. Evaluation • Complexity: Dead simple; tons of libraries • Reliance on HTTPS: Yes • Reliance on CSRF protection: Yes • Replay and integrity protection: Relies on TLS • Session management: Poor – Logout is complicated • Tips: always use Basic Auth with HTTPS 12

  13. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 13

  14. HTTP Digest Auth • Goal: not to rely on HTTPS/TLS anymore • Idea: server challenges client – No password in every request • Not widely adopted due to complexity! 14

  15. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 15

  16. How It Works // Login response from server Set-Cookie: sessionId=...; Domain=.app.com; Secure; SameSite; HttpOnly // Subsequent requests from client Cookie: sessionId=... • Cookies are managed by browser – Sent to server in every subsequent request 16

  17. Stateful Sessions User ID 17

  18. Evaluation • Complexity: simple; tons of libraries • Reliance on HTTPS: Yes – Set the Secure flag • Reliance on CSRF protection: Yes – Set the SameSite flag • Replay and integrity protection: Relies on TLS • Session management: Good • Tips: Set the HttpOnly flag to prevent XSS attacks from stealing it 18

  19. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 19

  20. How It Works // Login response from server { token: e2ZahC5b // JWT token } // Subsequent request from client Authorization: Bearer e2ZahC5b // added by JS • A JWT token is self-descriping and immutable – Includes user ID, expiration date, etc. (uid, expdate, sha256(uid, expdate, secret)) 20

  21. Sateless Sessions User ID User ID 21

  22. Evaluation • Complexity: simple with aid from libraries • Reliance on HTTPS: Yes • Reliance on CSRF protection: No • Replay and integrity protection: Relies on TLS • Session management: Limited • Tips: – Use access and refresh tokens – Do not save tokens in local or session storage 22

  23. Tips SetCookie: access=...; Domain=.app.com; Secure; SameSite; HttpOnly SetCookie: refresh=...; Domain=auth.app.com; Secure; SameSite; HttpOnly app.com auth. app .com • Secure à No token stealing • HttpOnly à No XSS • SameSite à No CSRF 23

  24. Statefull or Sateless? • Stateless: more scalable, but simpler lifecycle – Good for single-page sites, APIs, or mobile apps 24

  25. More Authentication Schemes • For server-to-server communications – Based on symmetric/asymmetric key cryptography • Signature Schemes – Idea: to digitally sign every request to prevent request tempering – Used by AWS • TLS Client Certificates – Idea: to use TLS certificate to authenticate each other 25

  26. Outline • Security risks of web applications – Injection, broken authentication , XSS, CSRF, etc. – Checklist of 23 Node.js security best practices • Auth: Authentication, authorization, and session management – HTTP Basic auth – HTTP Digest auth – Cookies for stateful sessions – Bearer tokens for stateless sessions • Single Sign On (SSO) 26

  27. Signgle Sign-On (SSO) 27

  28. Open ID Connect (OIDC) vs. OAuth • Authentication • Authorization 28

  29. OIDC Flow Client app.com fb.com Login 302 Credentials (name, password) 302 w/ ID token Login w/ ID token Verification Session 29

  30. Client app.com fb.com auth.fb.com api.fb.com Login OAuth 2 Flow 302 Credentials (name, password) 302 w/ ID token, grant code Login w/ ID token Verification Session Grant code Access token Session w/ access token 30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend