Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Manual JavaScript Analysis Is A Bug

When performing security assessments or participating in bug bounties, there is generally a methodology you follow when assessing source-code or performing dynamic analysis. This involves using tools, reviewing results and understanding what you should be testing for. Reviewing modern web applications can be quite challenging, and this talk will go into details on how we can automate the boring (but necessary parts) and how to set a roadmap of what should be focused on when dealing with modern JavaScript applications.

  • Login to see the comments

Manual JavaScript Analysis Is A Bug

  1. 1. Manual JavaScript Analysis is a Bug AllStars 26th September 2019 @LewisArdern
  2. 2. About Me • Sr. Security Consultant @ Synopsys • Formerly Cigital • AngularSF Organizer • • B.Sc. in Computer Security and Ethical Hacking • Founder of • JavaScript Enthusiast!
  4. 4. Manual Work Is a Bug • Automation can be used to help improve productivity and reduce repetitive work • Four Phases 1. Document the steps 2. Create automation equivalents 3. Create automation 4. Self-service and autonomous systems A.B.A: always be automating – Thomas A. Limoncelli
  5. 5. “Automate everything you can, even if it's just a series of manual steps in your documentation with a bunch of code snippets. Let your mind be the CPU. Follow these directions and improve them when you can.” – Parsia Hackerman
  6. 6. Automation Process: 1. Target something boring and repetitive 2. Automate it. It does not have to be code. Steps are fine 3. Follow your steps when doing that task and improve your steps in real-time (do not delay this) 4. Use your newly acquired spare time to target a new task 5. Share the documentation (wiki, git repo, confluence, etc.) and collaborate with others A. Good Example
  7. 7. Automation will allow you to spend your time focusing on things which require your energy such as business logic flaws, or identifying more complex attack chains
  8. 8. What can/should we automate?
  9. 9. We should not have to manually identify what URLs, and assets exist in an application!
  10. 10. Endpoint Discovery
  11. 11. Endpoint Discovery: js-link-finder • Useful for finding additional domains and paths through JavaScript • Example AOL:
  12. 12. Source Maps (* • Production minified JavaScript is intimidating to review: • Computer Transpiled: TypeScript, Coffee Script • Minified: Webpack, rollup, Pracel
  13. 13. Source Maps (* • Tools to reverse source maps • Directly in the browser • • • * Opportunity to build a Burp extension to reverse source maps
  14. 14. Understanding Technologies (Fingerprinting) • Burp Extensions • Asset Discover • • Software Version • • Browser Plugins • • Source Code •
  15. 15. We should not have to manually detect ‘basic’ sources and sinks
  16. 16. Detecting Issues ESLint Burp Suite
  17. 17. Detecting Issues: Burp Suite • Burp 2.0 JavaScript analysis is insanely good
  18. 18. When To Perform Manual Analysis • Understanding dataflow is important to confirm issues • Learning JavaScript inbuilt-functions • Get comfortable with: • Developer console • Debugging
  19. 19. When To Perform Manual Analysis • Browsers interpret window.location.hash differently<img src=x onerror=prompt(1)>
  20. 20. Detecting Issues: ESLint • Linting can identify issues in source-code
  21. 21. Detecting Out-Of-Bound Responses • Burp Collaborator is king for Out-Of-Bound Detection • XXE • SSRF • bXSS • SQLi • Setting up your own server is a good exercise
  22. 22. Detecting Out-Of-Bound Responses: bXSS • Burp Collaborator does detect bXSS, but.. • Sleepy puppy was the initial ‘bXSS’ tool (now deprecated) • Current contenders: • XSS Hunter (Top Dog) • bXSS (Hot Dog)
  23. 23. Detecting Out-Of-Bound Responses: bXSS • Modifying SP Burp Extension to detect bXSS
  24. 24. We should not have to manually find ‘hungry’ regular expressions
  25. 25. Detecting ReDoS • Certain vulnerable regular expressions loop exponentially when validating specific strings • The expression ^(a+)+$ takes 65536 steps to check the string aaaaaaaaaaaaaaaaX • The number of steps doubles for each additional “a” • An attacker can exploit vulnerable expressions to consume server resources and create a DoS condition
  26. 26. Detecting ReDoS • Useful reading: • • Useful tools for detecting ReDoS • • •
  27. 27. Detecting ReDoS With vuln-regex-detector
  28. 28. We should not have to manually find API keys or secrets in source code
  29. 29. Detecting Secrets • TruffleHog • Ripgrep • git-secrets
  30. 30. We should not have to manually identify known security issues in third-party components
  31. 31. Detecting Vulnerable Third-Party Components Example Command npm npm audit yarn yarn audit bower auditjs --bower bower.json Client-Side JavaScript retire --js /path/ Node.js Open-Source snyk test
  32. 32. NPM Audit && RetireJS
  33. 33. Let’s Talk About Dependencies:
  34. 34. What if we had a tool such as npm audit that could help drive secure-development and issue discovery?
  35. 35. What would this look like? Expertise: 1. Review popular dependencies for: a) Possible misconfigurations b) Possible security issues 2. Add them to a repository to retrieve later Tool Creation: 1. Review a package.json file for its dependencies a) Retrieve the name, and version 2. Look-up repository and match version and name 3. Return list of recommendations to investigate in a readable format
  36. 36. Tool Output
  37. 37. Example: express-session
  38. 38. Never Store The Secret In Source Control
  39. 39. Enforce The Browser To Only Transmit Over HTTPs
  40. 40. Prevent Inclusion In Cross-Origin Requests
  41. 41. Prevent Memory Exhaustion With A Store
  42. 42. Triaged Tool Output
  43. 43. What if we had a tool which combines all the open source projects which help identify security issues and drive secure development?
  44. 44. Metasec.js • Metasec.js is a meta analysis tool to review JavaScript Applications using open-source tools: • Current Functionality: • Help drive secure development based on package.json dependencies • Identifies issues with third-party dependencies • Looks for secrets • Looks for ReDoS • Performs security linting against an application • Audits the application for electron issues with doyensec/electronegativity if electron is in the package.json file
  45. 45. Demo
  46. 46. Future Work • Currently a PoC, and needs a lot of work… • Future plans: • Extend the ‘repository’ with more libraries • Smarter automation • E.g. detect when a framework/library is used and run appropriate linting/tools rather than hailmary • Extend or improve current capabilities • Link finder, and other asset finding capabilities in source-code • Request for help!
  47. 47. Conclusion • Automation helps streamline work processes • To get the best results you should automate from both a static and dynamic perspective • Automation can be used to help identify security issues and drive secure development in modern JavaScript applications • Automate and be AWESOME!
  48. 48. Thank you! Email: Website: Twitter: GitHub: LinkedIn: