SlideShare a Scribd company logo
Securing web applications with
Spring Security 3
Fernando Redondo Ramírez
@pronoide_fer
Roadmap
• Who am I?
• A brief introduction to
Spring Security
• Hands on
• Furthermore
Roadmap
• Who am I?
• A brief introduction to
Spring Security
• Hands on
• Furthermore
Brief Introduction to Spring Security
• Isn’t Security within JEE a standard feature?
Yes indeed, but:
• JEE Security ⇒ It’s constraint based
• JEE Security ⇒ It only defines a secured perimeter
• JEE Security ⇒ its features are depending on each
App Server (Realms, SSO, Cipher, etc)
• JEE Security ⇒ Secured JEE Applications can’t
easily move across different platforms or between
server versions
• JEE Security ⇒ Complex to adapt to Web 2.0 or
changing requirements
Brief Introduction to Spring Security
• Why use Spring Security then?
because:
• Spring Security ⇒ It’s granted based
• Spring Security ⇒ Both perimeter and
hierarchical
• Spring Security ⇒ Features independent of the
App Server
• Spring Security ⇒ Transportable Secured JEE
Applications
• Spring Security ⇒ Adaptable and versatile
Brief Introduction to Spring Security
• Architecture and we are done!
Spring Security 3
internals
SecurityContextHolder
SecurityContext
Authentication
GrantedAuthority
Web Requests
Web/HTTP Security
Security filter chain
Authentication
AuthenticationManager
AuthenticationProviders
UserDetailsService
Authorization
AccessDecisionManager
Voters
AfterInvocationManager
Business Methods
Business Object (Method) Security
Proxies/Security Interceptors
Your next mission
I need to put security
within our FBI X-Files
application!
Hands on! (Later at home)
Before start, you have to…
1. Install git in your computer
http://git-scm.com/book/en/Getting-Started-Installing-Git
2. Download Spring Tool Suite 3.5
https://spring.io/tools/sts/all
3. Start Spring Tool Suite 3.5 (STS) and choose or
create a workspace (remember run it with a JDK)
4. Download http://pronoide.com/downloads/javacro2014-
spring-security-xfiles.zip and unzip it into workspace
folder.
5. Pace yourself! It’s all quite straightforward…
FBI X Files webapp
Import webapp (File/Import/Git/Proyect from Git)
FBI X Files webapp
Run webapp!
Stage: Setup Spring Security in webapp
i. Setup a interceptor filter for all web requests
Stage: Setup Spring Security in webapp
ii. Create a new spring bean configuration file with the least
config and load through web.xml context parameter
Stage: Setup Spring Security in webapp
iii. Explicitly config login / logout procedures
iv. Fix issues with resources, images and CSS files
FBI X Files webapp
Stage: Setup Spring Security in webapp
v. Encrypt user’s paswords via Spring Security Crypto Module
• Encode passwords
• Configure algorithm and salt field. Then use passwords
within security config file
Stage: Setup Spring Security in webapp
vi. Add Remember Me feature to users login process
Stage: Setup Spring Security in webapp
vii. Secure transport channel (HTTPS)
• Setup constrains and ports
• Configure tomcat server (create SSL connector)
Stage: Setup Spring Security in webapp
viii. Session expiration control
ix. Session concurrency control
Stage: Setup Spring Security in webapp
x. JSP tag library usage (Spring Security Taglibs)
Stage: Setup Spring Security in webapp
xi. SpEL usage to protect URLs (Spring Expression Language)
xii. SpEL usage with Spring security taglib
what have you done!
Is there only security in
the web resources
access? Is that the very
best you can make it?
Try this URL and watch what is gonna happen:
https://localhost:8443/fbi/xfiles/declassify?id=0
Stage: Setup Spring Security in business methods
xii. Secure business method invocations thru Spring Security
Annotations
Stage: Setup Spring Security in business methods
xiii. Secure business method invocations thru AspectJ pointcuts
Stage: Setup Spring Security in business methods
xiv. Secure business method invocations thru SpEL (Pre Invocation)
Much better! But…
What are you doing viewing files
that aren’t yours?
How come you are able to access to
your sister’s files?
And why are you accessing at this
time of the day?
Stage: Setup Spring Security in an hierarchical way
xv. Secure business method invocations thru SpEL (Post Invocation)
xvi. Secure business method invocations thru SpEL (Result Filtering)
Stage: Setup Spring Security in an hierarchical way
xvii. Customization of access voters
• Code a new voter
Stage: Setup Spring Security in an hierarchical way
xviii.Customization of access voters (continuation)
• Dismiss Spring Security auto-config and reveal actual config
• Customize Access decision manager behavior
Stage: Spring Security Extras
xix. Customization of security filter chain (Example A)
• Create custom filter
• Place it within the filter chain
Stage: Spring Security Extras
xx. Customization of security filter chain (Example B)
• Create custom filter
• Place it within the filter chain
The smoking man
All of these features about Spring
Security are pretty fine, but I can
always leverage a Java2 attack:
<%System.exit(0);%>
Beyond this talk
• Not implicit but explicit configs
• ACL’s management
• Autentification with DataSources,
LDAP, X509, OPENID, JEE, etc
• Captcha
• Single Sign On
• Java Config
“… in most of my work, the laws of physics rarely seems to apply.”
Fox Mulder 1x01 "Pilot"
Whoami
• Entrepreneur and Business Manager at Pronoide
since 2003
• Java & Friends Trainer (JEE, Spring, Groovy, Maven, Jenkins, Sonar,
Weblogic, Jboss, Websphere, Disco Dancing and so )
• Doing things with Java from 1999 on
• Computer Engineer
• Happily married and proud father of two children
• I used to wanna be a physics scientist and I really do love
X-files series
Apendix: Hands on (Later at home)!
Navigate along the project code with git presenter
1. Install jruby or ruby
http://jruby.org/getting-started
https://www.ruby-lang.org/en/installation/
2. Install git presenter (gem install git_presenter)
3. When the code is ready use the "git-presenter init" command
to initialize
4. Once it is initialized you can start the presentation with "git-
presenter start"
5. Then use the following commands to navigate the presentation
• next/n: move to the next slide (commit)
• back/b: move to the back slide (commit)
• end/e: move to the end of presentation
• start/s: move to the start of presentation
• list/l : list slides in presentation
• help/h: display this message

More Related Content

PDF
Fun With Spring Security
PPTX
Spring Security 3
PPTX
Building Layers of Defense with Spring Security
PPTX
Spring Security
PDF
Spring Security
PPT
Spring Security Introduction
PPTX
Spring security
PDF
Codemotion 2015 spock_workshop
Fun With Spring Security
Spring Security 3
Building Layers of Defense with Spring Security
Spring Security
Spring Security
Spring Security Introduction
Spring security
Codemotion 2015 spock_workshop

What's hot (20)

PDF
Pentesting Rest API's by :- Gaurang Bhatnagar
PPTX
Cyber ppt
PPTX
Spring security
PDF
Injecting Security into vulnerable web apps at Runtime
PPT
香港六合彩
PPTX
Web Hacking Intro
PPT
Top 10 Web Security Vulnerabilities (OWASP Top 10)
PDF
Shellcoding in linux
PPTX
Security asp.net application
PDF
[Wroclaw #7] Why So Serial?
PPTX
Web & Cloud Security in the real world
PPTX
Rapid Android Application Security Testing
PDF
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
PPTX
[Wroclaw #7] AWS (in)security - the devil is in the detail
PPTX
Abusing Exploiting and Pwning with Firefox Addons
PPTX
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
PPTX
Hacking WebApps for fun and profit : how to approach a target?
PDF
Web application security & Testing
PPTX
[Wroclaw #7] Security test automation
PDF
OWASP Portland - OWASP Top 10 For JavaScript Developers
Pentesting Rest API's by :- Gaurang Bhatnagar
Cyber ppt
Spring security
Injecting Security into vulnerable web apps at Runtime
香港六合彩
Web Hacking Intro
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Shellcoding in linux
Security asp.net application
[Wroclaw #7] Why So Serial?
Web & Cloud Security in the real world
Rapid Android Application Security Testing
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
[Wroclaw #7] AWS (in)security - the devil is in the detail
Abusing Exploiting and Pwning with Firefox Addons
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
Hacking WebApps for fun and profit : how to approach a target?
Web application security & Testing
[Wroclaw #7] Security test automation
OWASP Portland - OWASP Top 10 For JavaScript Developers
Ad

Similar to Javacro 2014 Spring Security 3 Speech (20)

PDF
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
PDF
Spring security4.x
PPTX
Spring Security services for web applications
PPTX
Spring Security 5
PDF
Building layers of defense for your application
PDF
Spring security jwt tutorial toptal
PDF
spring-security-reference.pdf
PDF
Java Web Application Security - Denver JUG 2013
PDF
Anil saldhana securityassurancewithj_bosseap
PDF
Spring Security in Action 1st Edition Laurentiu Spilca Spilcă Laurenţiu
PPTX
Spring Security Framework
PDF
Spring4 security
PDF
ADDRESSING TOMORROW'S SECURITY REQUIREMENTS IN ENTERPRISE APPLICATIONS
PDF
Spring Security in Action 1st Edition Laurentiu Spilca
PDF
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
PPTX
SCWCD : Secure web : CHAP : 7
PPTX
SCWCD : Secure web
PPTX
Spring 1 day program
PDF
Java EE Services
PPTX
Java Secure Coding Practices
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
Spring security4.x
Spring Security services for web applications
Spring Security 5
Building layers of defense for your application
Spring security jwt tutorial toptal
spring-security-reference.pdf
Java Web Application Security - Denver JUG 2013
Anil saldhana securityassurancewithj_bosseap
Spring Security in Action 1st Edition Laurentiu Spilca Spilcă Laurenţiu
Spring Security Framework
Spring4 security
ADDRESSING TOMORROW'S SECURITY REQUIREMENTS IN ENTERPRISE APPLICATIONS
Spring Security in Action 1st Edition Laurentiu Spilca
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
SCWCD : Secure web : CHAP : 7
SCWCD : Secure web
Spring 1 day program
Java EE Services
Java Secure Coding Practices
Ad

More from Fernando Redondo Ramírez (7)

PDF
Spring IO 2015 Spock Workshop
PDF
Greach 2015 Spock workshop
PDF
Seguridad de las aplicaciones web con Spring Security 3.x
PDF
Javacro 2014 SemameStreet Grails 2 Speech
PDF
Greach 2014 Sesamestreet Grails2 Workshop
PDF
Greach2013 taller-grails2
PDF
Springio2012 taller-seguridad-web-springsecurity-3
Spring IO 2015 Spock Workshop
Greach 2015 Spock workshop
Seguridad de las aplicaciones web con Spring Security 3.x
Javacro 2014 SemameStreet Grails 2 Speech
Greach 2014 Sesamestreet Grails2 Workshop
Greach2013 taller-grails2
Springio2012 taller-seguridad-web-springsecurity-3

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPT
Teaching material agriculture food technology
PDF
Encapsulation theory and applications.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
Per capita expenditure prediction using model stacking based on satellite ima...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Building Integrated photovoltaic BIPV_UPV.pdf
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Teaching material agriculture food technology
Encapsulation theory and applications.pdf
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation
Programs and apps: productivity, graphics, security and other tools

Javacro 2014 Spring Security 3 Speech

  • 1. Securing web applications with Spring Security 3 Fernando Redondo Ramírez @pronoide_fer
  • 2. Roadmap • Who am I? • A brief introduction to Spring Security • Hands on • Furthermore
  • 3. Roadmap • Who am I? • A brief introduction to Spring Security • Hands on • Furthermore
  • 4. Brief Introduction to Spring Security • Isn’t Security within JEE a standard feature? Yes indeed, but: • JEE Security ⇒ It’s constraint based • JEE Security ⇒ It only defines a secured perimeter • JEE Security ⇒ its features are depending on each App Server (Realms, SSO, Cipher, etc) • JEE Security ⇒ Secured JEE Applications can’t easily move across different platforms or between server versions • JEE Security ⇒ Complex to adapt to Web 2.0 or changing requirements
  • 5. Brief Introduction to Spring Security • Why use Spring Security then? because: • Spring Security ⇒ It’s granted based • Spring Security ⇒ Both perimeter and hierarchical • Spring Security ⇒ Features independent of the App Server • Spring Security ⇒ Transportable Secured JEE Applications • Spring Security ⇒ Adaptable and versatile
  • 6. Brief Introduction to Spring Security • Architecture and we are done! Spring Security 3 internals SecurityContextHolder SecurityContext Authentication GrantedAuthority Web Requests Web/HTTP Security Security filter chain Authentication AuthenticationManager AuthenticationProviders UserDetailsService Authorization AccessDecisionManager Voters AfterInvocationManager Business Methods Business Object (Method) Security Proxies/Security Interceptors
  • 7. Your next mission I need to put security within our FBI X-Files application!
  • 8. Hands on! (Later at home) Before start, you have to… 1. Install git in your computer http://git-scm.com/book/en/Getting-Started-Installing-Git 2. Download Spring Tool Suite 3.5 https://spring.io/tools/sts/all 3. Start Spring Tool Suite 3.5 (STS) and choose or create a workspace (remember run it with a JDK) 4. Download http://pronoide.com/downloads/javacro2014- spring-security-xfiles.zip and unzip it into workspace folder. 5. Pace yourself! It’s all quite straightforward…
  • 9. FBI X Files webapp Import webapp (File/Import/Git/Proyect from Git)
  • 10. FBI X Files webapp Run webapp!
  • 11. Stage: Setup Spring Security in webapp i. Setup a interceptor filter for all web requests
  • 12. Stage: Setup Spring Security in webapp ii. Create a new spring bean configuration file with the least config and load through web.xml context parameter
  • 13. Stage: Setup Spring Security in webapp iii. Explicitly config login / logout procedures iv. Fix issues with resources, images and CSS files
  • 14. FBI X Files webapp
  • 15. Stage: Setup Spring Security in webapp v. Encrypt user’s paswords via Spring Security Crypto Module • Encode passwords • Configure algorithm and salt field. Then use passwords within security config file
  • 16. Stage: Setup Spring Security in webapp vi. Add Remember Me feature to users login process
  • 17. Stage: Setup Spring Security in webapp vii. Secure transport channel (HTTPS) • Setup constrains and ports • Configure tomcat server (create SSL connector)
  • 18. Stage: Setup Spring Security in webapp viii. Session expiration control ix. Session concurrency control
  • 19. Stage: Setup Spring Security in webapp x. JSP tag library usage (Spring Security Taglibs)
  • 20. Stage: Setup Spring Security in webapp xi. SpEL usage to protect URLs (Spring Expression Language) xii. SpEL usage with Spring security taglib
  • 21. what have you done! Is there only security in the web resources access? Is that the very best you can make it? Try this URL and watch what is gonna happen: https://localhost:8443/fbi/xfiles/declassify?id=0
  • 22. Stage: Setup Spring Security in business methods xii. Secure business method invocations thru Spring Security Annotations
  • 23. Stage: Setup Spring Security in business methods xiii. Secure business method invocations thru AspectJ pointcuts
  • 24. Stage: Setup Spring Security in business methods xiv. Secure business method invocations thru SpEL (Pre Invocation)
  • 25. Much better! But… What are you doing viewing files that aren’t yours? How come you are able to access to your sister’s files? And why are you accessing at this time of the day?
  • 26. Stage: Setup Spring Security in an hierarchical way xv. Secure business method invocations thru SpEL (Post Invocation) xvi. Secure business method invocations thru SpEL (Result Filtering)
  • 27. Stage: Setup Spring Security in an hierarchical way xvii. Customization of access voters • Code a new voter
  • 28. Stage: Setup Spring Security in an hierarchical way xviii.Customization of access voters (continuation) • Dismiss Spring Security auto-config and reveal actual config • Customize Access decision manager behavior
  • 29. Stage: Spring Security Extras xix. Customization of security filter chain (Example A) • Create custom filter • Place it within the filter chain
  • 30. Stage: Spring Security Extras xx. Customization of security filter chain (Example B) • Create custom filter • Place it within the filter chain
  • 31. The smoking man All of these features about Spring Security are pretty fine, but I can always leverage a Java2 attack: <%System.exit(0);%>
  • 32. Beyond this talk • Not implicit but explicit configs • ACL’s management • Autentification with DataSources, LDAP, X509, OPENID, JEE, etc • Captcha • Single Sign On • Java Config “… in most of my work, the laws of physics rarely seems to apply.” Fox Mulder 1x01 "Pilot"
  • 33. Whoami • Entrepreneur and Business Manager at Pronoide since 2003 • Java & Friends Trainer (JEE, Spring, Groovy, Maven, Jenkins, Sonar, Weblogic, Jboss, Websphere, Disco Dancing and so ) • Doing things with Java from 1999 on • Computer Engineer • Happily married and proud father of two children • I used to wanna be a physics scientist and I really do love X-files series
  • 34. Apendix: Hands on (Later at home)! Navigate along the project code with git presenter 1. Install jruby or ruby http://jruby.org/getting-started https://www.ruby-lang.org/en/installation/ 2. Install git presenter (gem install git_presenter) 3. When the code is ready use the "git-presenter init" command to initialize 4. Once it is initialized you can start the presentation with "git- presenter start" 5. Then use the following commands to navigate the presentation • next/n: move to the next slide (commit) • back/b: move to the back slide (commit) • end/e: move to the end of presentation • start/s: move to the start of presentation • list/l : list slides in presentation • help/h: display this message