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.

Java Web Application Security - Utah JUG 2011


Published on

During this presentation, I demonstrate how to implement authentication in your Java web applications using Spring Security, Apache Shiro and good ol' Java EE Container Managed Authentication. You'll also learn how to secure your REST API with OAuth and lock it down with SSL.

After learning how to develop authentication, I'll introduce you to OWASP, the OWASP Top 10, its Testing Guide and its Code Review Guide.

Much of this talk is contained in demos and I plan on uploading those as screencasts throughout May and June. I'll also be delivering this talk at ÜberConf in July 2011.

Published in: Technology, Education

Java Web Application Security - Utah JUG 2011

  1. 1. Java Web Application SecurityDevelop. Penetrate. Protect. Relax.Matt Raible Images by Stuck in Customs - © 2011 Raible Designs
  2. 2. Introductions Your experience with web development? Your experience with implementing security? Have you used Java EE 6, Spring Security or Apache Shiro? What do you want to get from this talk? © 2011 Raible Designs
  3. 3. Blogger on Father, Skier, Cyclist Founder of AppFuse Web Framework Connoisseur Who is Matt Raible? © 2011 Raible Designs
  4. 4. Session AgendaSecurity Development Java EE 6, Spring Security, Apache Shiro SSL and TestingVerifying Security OWASP Top 10Commercial Tools and ServicesQ and A Develop Penetrate Protect Relax © 2011 Raible Designs
  5. 5. Why am I here?Purpose To learn more about Java webapp security and transform myself into a security expert.Goals Show how to implement Java webapp security. Show how to penetrate a Java webapp. Show how to fix vulnerabilities. © 2011 Raible Designs
  6. 6. Develop © 2011 Raible Designs
  7. 7. Dynamic Language Support?If it deploys on Tomcat, it has a web.xml. Grails JRuby on Rails Lift Play! Framework © 2011 Raible Designs
  8. 8. Java EE 6Security constraints defined in web.xml web resource collection - URLs and methods authorization constraints - role names user data constraint - HTTP or HTTPSUser Realm defined by App ServerDeclarative or Programmatic AuthenticationAnnotations Support © 2011 Raible Designs
  9. 9. Java EE 6 Demo © 2011 Raible Designs
  10. 10. Servlet 3.0 HttpServletRequest authenticate(response) login(user, pass) logout() getRemoteUser() isUserInRole(name) © 2011 Raible Designs
  11. 11. Servlet 3.0 and JSR 250Annotations @ServletSecurity @HttpMethodConstraint @HttpConstraint @RolesAllowed @PermitAll @DenyAll © 2011 Raible Designs
  12. 12. Java EE Security Limitations No error messages for failed logins No Remember Me Container has to be configured Doesn’t support regular expressions for URLs © 2011 Raible Designs
  13. 13. Spring Security Filter defined in web.xml Separate security context file loaded by Spring Defines URLs, Roles and Authentication Providers Defines UserService (provided or custom) Password Encoding Remember Me © 2011 Raible Designs
  14. 14. Spring Security Demo © 2011 Raible Designs
  15. 15. Securing Methods<global-method-security secured-annotations="enabled"/> @Secured("IS_AUTHENTICATED_ANONYMOUSLY") public Account readAccount(Long id); @Secured("IS_AUTHENTICATED_ANONYMOUSLY") public Account[] findAccounts(); @Secured("ROLE_TELLER") public Account post(Account account, double amount);<global-method-security jsr250-annotations="enabled"/> © 2011 Raible Designs
  16. 16. Securing Methods 3.0<global-method-security pre-post-annotations="enabled"/> @PreAuthorize("isAnonymous()") public Account readAccount(Long id); @PreAuthorize("isAnonymous()") public Account[] findAccounts(); @PreAuthorize("hasAuthority(ROLE_TELLER)") public Account post(Account account, double amount); © 2011 Raible Designs
  17. 17. Spring Security Limitations Authentication mechanism in WAR Securing methods only works on Spring beans My remember me example doesn’t work © 2011 Raible Designs
  18. 18. Apache ShiroFilter defined in web.xmlshiro.ini loaded from classpath [main], [urls], [roles]CryptographySession Management © 2011 Raible Designs
  19. 19. Apache Shiro Demo © 2011 Raible Designs
  20. 20. Testing with SSLCargo doesn’t support http andhttps at same timeJetty and Tomcat plugins workfor bothPass & maven-failsafe-plugin as<systemPropertyVariables> © 2011 Raible Designs
  21. 21. Ajax Login © 2011 Raible Designs
  22. 22. Securing a REST APIUse Basic or FormAuthenticationUse Developer KeysUse OAuth © 2011 Raible Designs
  23. 23. OAuth © 2011 Raible Designs
  24. 24. REST Security and OAuth Demo © 2011 Raible Designs
  25. 25. PenetrateOWASP Testing Guide and Code Review GuideOWASP Top 10OWASP Zed Attack ProxyBurp SuiteOWASP WebGoat © 2011 Raible Designs
  26. 26. OWASPThe Open Web Application Security Project (OWASP) isan open community dedicated to enablingorganizations to develop, purchase, and maintainapplications that can be trusted. At OWASP you’ll findfree and open ... Application security tools, complete books, standard security controls and libraries, cutting edge research © 2011 Raible Designs
  27. 27. OWASP Top 10 for 20101. Injection2. Cross-Site Scripting (XSS)3. Broken Authentication and Session Management4. Insecure Direct Object References5. Cross-Site Request Forgery (CSRF) © 2011 Raible Designs
  28. 28. OWASP Top 10 for 20106. Security Misconfiguration7. Insecure Cryptographic Storage8. Failure to Restrict URL Access9. Insufficient Transport Layer Protection10.Unvalidated Redirects and Forwards © 2011 Raible Designs
  29. 29. ProtectFirewallsIDS and IDPsAuditsPenetration TestsCode Reviews with StaticAnalysis Tools © 2011 Raible Designs
  30. 30. Firewalls Stateless Firewalls Stateful Firewalls Invented by Nir Zuk at Check Point in the mid-90s Web App Firewalls Inspired by the 1996 PHF CGI exploit WAF Market $234m in 2010 © 2011 Raible Designs
  31. 31. Gartner on Firewalls © 2011 Raible Designs
  32. 32. RelaxWeb App Firewalls: Imperva, F5, Trustwave Open Source: WebNight and ModSecurityStateful Firewalls: Palo Alto, JuniperIDP/IDS: Sourcefire, TippingPointAudits: ENY, PWC, Grant ThorntonPen Testing: Electric Alchemy, FishNet Security,ImmunityStatic Analysis: Fortify, Veracode © 2011 Raible Designs
  33. 33. Questions?Contact Information @mraibleMy Presentations © 2011 Raible Designs