hacking nodejs applications for fun and profit
play

Hacking NodeJS applications for fun and profit Testing NodeJS - PowerPoint PPT Presentation

Hacking NodeJS applications for fun and profit Testing NodeJS Security by @jmortegac Agenda Introduction nodejS security Npm security packages Node Goat project Tools Node JS JavaScript in the backend Built on


  1. Hacking NodeJS applications for fun and profit Testing NodeJS Security by @jmortegac

  2. Agenda ▪ Introduction nodejS security ▪ Npm security packages ▪ Node Goat project ▪ Tools

  3. Node JS ▪ JavaScript in the backend ▪ Built on Chrome´s Javascript runtime(V8) ▪ NodeJs is based on event loop ▪ Designed to be asynchronous ▪ Single Thread ▪ Node.js is resilient to flooding attacks since there’s no limit on the number of concurrent requests.

  4. Security https://expressjs.com/en/advance d/security-updates.html updates

  5. Package https://www.npmjs.com/advisories vulnerabilities

  6. ▪ Helmet Npm ▪ express-session security ▪ cookie-session packages ▪ csurf ▪ express-validator ▪ bcrypt-node ▪ express-enforces-ssl

  7. Security HTTP Headers ▪ Strict-Transport-Security ▪ X-Frame-Options ▪ X-XSS-Protection ▪ X-Content-Type-Options ▪ Content-Security-Policy

  8. ▪ https://www.npmjs.com/package Helmet module /helmet

  9. ▪ https://github.com/helmetjs/helmet Helmet module

  10. ▪ hidePoweredBy Helmet module ▪ Hpkp → protection MITM ▪ Hsts → forces https connections ▪ noCache → desactive client cache ▪ Frameguard → protection clickjacking ▪ xssFilter → protection XSS

  11. Helmet CSP

  12. ▪ http://cyh.herokuapp.com/cyh Check headers ▪ https://securityheaders.io/ security

  13. Express ▪ https://www.shodan.io/ search?query=express versions

  14. Disable x-powered-by

  15. Disable ▪ Avoid framework x-powered-by fingerprinting

  16. Disable ▪ Use Helmet and use “hide-powered-by” plugin x-powered-by

  17. ▪ https://www.npmjs.com/pack Sessions age/cookie-session management ▪ secure ▪ httpOnly ▪ domain ▪ path ▪ expires

  18. httpOnly & secure:true

  19. XSS attacks ▪ An attacker can exploit XSS vulnerability to: ▪ Steal session cookies/Sesion hijacking ▪ Redirect user to malicious sites ▪ Defacing and content manipulation ▪ Cross Site Request forgery

  20. CSRF attacks

  21. https://www.npmjs.com/package/csurf

  22. app.use(function (request, response, next) { CSRF response.locals.csrftoken = request.csrfToken(); next(); }); <form action="/process" method=" POST "> <input type="hidden" name="_csrf" value="{{csrfToken}}"> <button type="submit">Submit</button> </form>

  23. CSRF

  24. Filter/sanitize user input ▪ Fixing XSS attacks ▪ https://www.npmjs.com/package/sanitizer ▪ Module express-validator ▪ https://www.npmjs.com/package/express-validator

  25. Express Validator

  26. ▪ https://github.com/kelektiv/node.bcrypt.js Bcrypt-node

  27. ▪ http://nodegoat.herokuapp.com Node Goat /tutorial

  28. ▪ https://github.com/OWASP/Node Node Goat Goat

  29. res.end(require('fs').read EVAL() dirSync('.').toString()) ATTACKS

  30. Insecure Direct ▪ Use session instead of Object request param References ▪ var userId = req.session.userId;

  31. Tools ▪ KrakenJS ▪ Lusca middleware ▪ NodeJsScan

  32. http://krakenjs.com/

  33. https://github.com/krakenjs/lusca

  34. ▪ https://github.com/ajinabra NodeJsScan ham/NodeJsScan

  35. https://github.com/jmorteg NodeJsScan a/NodeJsScan/blob/maste r/rules.xml

  36. NodeJsScan

  37. GitHub repositories ▪ https://github.com/jmortega/testing_nodejs_security ▪ https://github.com/cr0hn/vulnerable-node ▪ https://github.com/rdegges/svcc-auth ▪ https://github.com/strongloop/loopback-getting-start ed-intermediate ▪ https://github.com/Feeld/strong-node

  38. Node security ▪ https://www.udemy.com/nodejs-security- pentesting-and-exploitation/ learning

  39. Books

  40. References ▪ https://blog.risingstack.com/node-js-security-checklist/ ▪ https://blog.risingstack.com/node-js-security-tips/ ▪ https://www.npmjs.com/package/helmet ▪ https://expressjs.com/en/advanced/best-practice-security.html https://expressjs.com/en/advanced/security-updates.html ▪ http://nodegoat.herokuapp.com/tutorial ▪ https://www.owasp.org/index.php/Projects/OWASP_Node_js_Goa ▪ t_Project

Recommend


More recommend