SlideShare a Scribd company logo
The	Hacker’s	Guide		
to	NoSQL	Injec9on
Patrycja	Wegrzynowicz	
CTO,	Yon	Labs/Yonita	
CodeOne	2018
About	Me
• 20+	professional	experience		
• SoRware	engineer,	architect,	head	of	
soRware	R&D		
• Author	and	speaker		
• JavaOne,	Devoxx,	JavaZone,	TheServerSide	
Java	Symposium,	Jazoon,	OOPSLA,	ASE,	
others		
• Top	10	Women	in	Tech	2016	in	Poland	
• Founder	and	CTO	of	Yon	Labs/Yonita	
• Consul9ng,	trainings	and	code	audits	
• Automated	detec9on	and	refactoring	of	
soRware	defects	
• Security,	performance,	concurrency,	
databases		
• Twi]er	@yonlabs
About	Me
• 20+	professional	experience		
• SoRware	engineer,	architect,	head	of	soRware	
R&D		
• Author	and	speaker		
• JavaOne,	Devoxx,	JavaZone,	TheServerSide	
Java	Symposium,	Jazoon,	OOPSLA,	ASE,	others		
• Top	10	Women	in	Tech	2016	in	Poland	
• Founder	and	CTO	of	Yon	Labs	and	Yonita	
• Bridge	the	gap	between	the	industry	and	the	
academia	
• Automated	detec9on	and	refactoring	of	
soRware	defects	
• Trainings	and	code	reviews	
• Security,	performance,	concurrency,	databases		
• Twi]er	@yonlabs
Agenda
• Security	horror	stories	
• Demos	of	NoSQL	injec9on	
• Protec9on	against	NoSQL	injec9on	
• Common	NoSQL	misconfigura9ons
Security	Horror Stories
#!/bin/bash
SQL	Injection
6
xkdc
Simple	SQL/ORM	Injection
7
String custId = request.getParameter(”cust_id”)
String sqlQuery = ”SELECT * FROM ACCOUNT WHERE CUST_ID=“ + custId;
String jpqlQuery = ”from Account where custId=“ + custId
http://www.example.com/app/accountView?cust_id=0 or 1=1
http://www.example.com/app/accountView?cust_id%3D0%20or%201%3D1%0A
SELECT * FROM ACCOUNT WHERE CUST_ID=0 or 1=1
from Account where custId=0 or 1=1
Interesting	Injections
8
Interesting	Injections
9
SQL	Injection	Damage
• Loss	of	confidentiality		
• SELECT	...	WHERE	...	OR	1=1	
• Loss	of	integrity	
• 5;	DROP	TABLE	ACCOUNTS;		
• Loss	of	availability	
• 5;	BENCHMARK(99999999,MD5(NOW()))	
10
Db	Engines	Ranking
11
h&ps://db-engines.com/en/ranking
NoSQL	Injection?
NoSQL	Injection?
13
h&ps://intellipaat.com/blog/what-is-mongodb/
NoSQL	Horror	Stories
14
OWASP	Top	10	Risks	2017
Demo	#1
• Bypass	Authen9ca9on:	Known	Account	Name		
• h]p://demo.yonita.com:3000
Demo	#1	Attack	Vector
17
Problem?
• Take	a	look	at	source	code
Demo	#2
• Bypass	Authen9ca9on:	Unknown	Account	Name		
• h]p://demo.yonita.com:3000	
• Please	register	:-)
Demo	#2	A]ack	Vector
Hashed	Passwords
• Login	
• Hash	provided	password	
• Search	for	User	in	mongodb	with	a	given	username	and	hashed	
password
Hashed	Passwords
• Login	
• Hash	provided	password	
• Search	for	User	in	mongodb	with	a	given	username	and	hashed	
password	
• Dic9onary	search	
• Many	users	=>	some	have	simple	passwords	
• Use	salted	passwords		
• e.g.	bcrypt
Demo	#3	
Expose	Data
• h]p://demo.yonita.com:3000	
• Private	notes	about	CodeOne	
• Please	register	
• Leave	your	note	about	CodeOne	=>	I’ll	will	read	all	of	
them	:-)
NoSQL	Injec9on	
Tautologies
• A]ack	Intent		
• Bypassing	authen9ca9on	
• Iden9fying	injectable	parameters	
• Extrac9ng	data	
• Descrip9on	
• Injec9ng	code	that	the	condi9on	always	evaluates	to	true	
• Example	
• Demo	#1
NoSQL	Injec9on	
Union	Queries
• A]ack	Intent	
• Bypassing	authen9ca9on,	extrac9ng	data	
• Descrip9on	
• Changes	the	data	set	returned	for	a	given	query	
• Example	
• Demo	#2
NoSQL	Injec9on	
Piggy-Backed	Queries
• A]ack	Intent		
• Extrac9ng	data,	adding	or	modifying	data,	performing	
denial	of	service,	execu9ng	remote	commands	
• Descrip9on	
• Injec9ng	addi9onal	JS	into	the	original	query	
• Example	
Robb',	$where:	‘func9on(){		
sleep(5000);	return	this.name	==	“Robb"}'	
})
Blind	NoSQL	Injec9on
http://www.example.com/app/viewArticle?articleId=5
The article displayed No article error
or
1=1
and
1=2
Blind	NoSQL	Injec9on	
Real	World	Example
Blind	NoSQL	Injec9on	
Real	World	Example
Blind	NoSQL	Injec9on	
Real	World	Example
Blind	NoSQL	Injec9on	
Real	World	Example	-	Exploit
Blind	NoSQL	Injec9on	
Real	World	Example	-	Patch
Protec9on	against	NoSQL	Injec9on	
Primary	Defences
• User	input	
• Strong	type	checking	
• Input	valida9on	
• White-list	valida9on	
• Input	sani9za9on	
• Escaping	all	user	supplied	input	
• Use	proper	API	
• No	string	concatena9on	
• Beware	of	template	engines	
• Bind	parameters
Protec9on	against	NoSQL	Injec9on	
Addi9onal	Defences
• Applica9on	tes9ng	
• Black-box	tes9ng	
• Sta9c	code	checkers	
• Dynamic	analysis	
• Tools	in	the	middle	
• Intrusion	detec9on	systems	
• Proxy	filtering	
• Web	applica9on	firewalls
MongoDb	Default	Configura9on
MongoDb	Security	Check	List
• Enable	Access	Control	and	Enforce	Authen9ca9on	
• Configure	Role-Based	Access	Control	
• Encrypt	Communica9on	
• Limit	Network	Exposure	
• >	3.6	bind	only	to	localhost	
• Run	MongoDB	with	Secure	Configura9on	Op9ons	
• mapReduce,	group,	$where	
• —noscrip9ng	op9on
Remember!		
It’s	not	all	about		injec9ons!
And	it’s	not	all	about	MongoDb!
A	fool	with	a	tool	is	only	a	fool!
Con9nuous	Learning
Q&A
• patrycja@yonita.com	
• @yonlabs

More Related Content

What's hot

OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
Software Guru
 

What's hot (20)

Practical Application of the API Security Top Ten: A Tester's Perspective
Practical Application of the API Security Top Ten: A Tester's PerspectivePractical Application of the API Security Top Ten: A Tester's Perspective
Practical Application of the API Security Top Ten: A Tester's Perspective
 
Application Security
Application SecurityApplication Security
Application Security
 
Web application security
Web application securityWeb application security
Web application security
 
OWASP Top 10 2021 What's New
OWASP Top 10 2021 What's NewOWASP Top 10 2021 What's New
OWASP Top 10 2021 What's New
 
I hunt sys admins 2.0
I hunt sys admins 2.0I hunt sys admins 2.0
I hunt sys admins 2.0
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
 
IBM AppScan - the total software security solution
IBM AppScan - the total software security solutionIBM AppScan - the total software security solution
IBM AppScan - the total software security solution
 
Practical White Hat Hacker Training - Passive Information Gathering(OSINT)
Practical White Hat Hacker Training -  Passive Information Gathering(OSINT)Practical White Hat Hacker Training -  Passive Information Gathering(OSINT)
Practical White Hat Hacker Training - Passive Information Gathering(OSINT)
 
Pentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A PrimerPentesting Modern Web Apps: A Primer
Pentesting Modern Web Apps: A Primer
 
PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)
 
Secure Coding principles by example: Build Security In from the start - Carlo...
Secure Coding principles by example: Build Security In from the start - Carlo...Secure Coding principles by example: Build Security In from the start - Carlo...
Secure Coding principles by example: Build Security In from the start - Carlo...
 
Android Application Penetration Testing - Mohammed Adam
Android Application Penetration Testing - Mohammed AdamAndroid Application Penetration Testing - Mohammed Adam
Android Application Penetration Testing - Mohammed Adam
 
Security testing
Security testingSecurity testing
Security testing
 
Hacking and Defending APIs - Red and Blue make Purple.pdf
Hacking and Defending APIs - Red and Blue make Purple.pdfHacking and Defending APIs - Red and Blue make Purple.pdf
Hacking and Defending APIs - Red and Blue make Purple.pdf
 
OWASP Top 10 2021 Presentation (Jul 2022)
OWASP Top 10 2021 Presentation (Jul 2022)OWASP Top 10 2021 Presentation (Jul 2022)
OWASP Top 10 2021 Presentation (Jul 2022)
 
Waf bypassing Techniques
Waf bypassing TechniquesWaf bypassing Techniques
Waf bypassing Techniques
 
Sigma and YARA Rules
Sigma and YARA RulesSigma and YARA Rules
Sigma and YARA Rules
 
Detection Rules Coverage
Detection Rules CoverageDetection Rules Coverage
Detection Rules Coverage
 
DevSecOps and the CI/CD Pipeline
 DevSecOps and the CI/CD Pipeline DevSecOps and the CI/CD Pipeline
DevSecOps and the CI/CD Pipeline
 
Threat hunting - Every day is hunting season
Threat hunting - Every day is hunting seasonThreat hunting - Every day is hunting season
Threat hunting - Every day is hunting season
 

Similar to The Hacker's Guide to NoSQL Injection

DaZhangJM0203JM0203
DaZhangJM0203JM0203DaZhangJM0203JM0203
DaZhangJM0203JM0203
Da Zhang
 

Similar to The Hacker's Guide to NoSQL Injection (20)

The Hacker's Guide to Session Hijacking
The Hacker's Guide to Session Hijacking The Hacker's Guide to Session Hijacking
The Hacker's Guide to Session Hijacking
 
The Hacker's Guide to XSS
The Hacker's Guide to XSSThe Hacker's Guide to XSS
The Hacker's Guide to XSS
 
Secure Authentication and Session Management in Java EE
Secure Authentication and Session Management in Java EESecure Authentication and Session Management in Java EE
Secure Authentication and Session Management in Java EE
 
DaZhangJM0203JM0203
DaZhangJM0203JM0203DaZhangJM0203JM0203
DaZhangJM0203JM0203
 
AppSec EU 2011 - An Introduction to ZAP by Simon Bennetts
AppSec EU 2011 - An Introduction to ZAP by Simon BennettsAppSec EU 2011 - An Introduction to ZAP by Simon Bennetts
AppSec EU 2011 - An Introduction to ZAP by Simon Bennetts
 
Javantura v2 - The Road to Java - HUJAK & Oracle Croatia - Branko Mihaljević,...
Javantura v2 - The Road to Java - HUJAK & Oracle Croatia - Branko Mihaljević,...Javantura v2 - The Road to Java - HUJAK & Oracle Croatia - Branko Mihaljević,...
Javantura v2 - The Road to Java - HUJAK & Oracle Croatia - Branko Mihaljević,...
 
DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...
DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...
DevSecCon Asia 2017 - Abhay Bhargav: Building an Application Vulnerability To...
 
8th TUC Meeting - David Meibusch, Nathan Hawes (Oracle Labs Australia). Frapp...
8th TUC Meeting - David Meibusch, Nathan Hawes (Oracle Labs Australia). Frapp...8th TUC Meeting - David Meibusch, Nathan Hawes (Oracle Labs Australia). Frapp...
8th TUC Meeting - David Meibusch, Nathan Hawes (Oracle Labs Australia). Frapp...
 
Practical Security Testing for Developers using OWASP ZAP at Dot Net Bangalor...
Practical Security Testing for Developers using OWASP ZAP at Dot Net Bangalor...Practical Security Testing for Developers using OWASP ZAP at Dot Net Bangalor...
Practical Security Testing for Developers using OWASP ZAP at Dot Net Bangalor...
 
Carrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java ProgrammerCarrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java Programmer
 
Как стать синьором
Как стать синьоромКак стать синьором
Как стать синьором
 
How to assess & hire Java developers accurately?
How to assess & hire Java developers accurately?How to assess & hire Java developers accurately?
How to assess & hire Java developers accurately?
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Mark Tortoricci - Talent42 2015
Mark Tortoricci - Talent42 2015Mark Tortoricci - Talent42 2015
Mark Tortoricci - Talent42 2015
 
10 Useful Testing Tools for Open Source Projects @ TuxCon 2015
10 Useful Testing Tools for Open Source Projects @ TuxCon 201510 Useful Testing Tools for Open Source Projects @ TuxCon 2015
10 Useful Testing Tools for Open Source Projects @ TuxCon 2015
 
OpenStack Networking: Developing and Delivering a Commercial Solution for Lo...
OpenStack Networking:  Developing and Delivering a Commercial Solution for Lo...OpenStack Networking:  Developing and Delivering a Commercial Solution for Lo...
OpenStack Networking: Developing and Delivering a Commercial Solution for Lo...
 
Testing your Single Page Application
Testing your Single Page ApplicationTesting your Single Page Application
Testing your Single Page Application
 
Java Certification by HUJAK - 2015-05-12 - at JavaCro'15 conference
Java Certification by HUJAK - 2015-05-12 - at JavaCro'15 conferenceJava Certification by HUJAK - 2015-05-12 - at JavaCro'15 conference
Java Certification by HUJAK - 2015-05-12 - at JavaCro'15 conference
 
Java application security the hard way - a workshop for the serious developer
Java application security the hard way - a workshop for the serious developerJava application security the hard way - a workshop for the serious developer
Java application security the hard way - a workshop for the serious developer
 
Java Community News - September 2015
Java Community News - September 2015Java Community News - September 2015
Java Community News - September 2015
 

More from Patrycja Wegrzynowicz

More from Patrycja Wegrzynowicz (9)

The Hacker's Guide to Kubernetes: Reloaded
The Hacker's Guide to Kubernetes: ReloadedThe Hacker's Guide to Kubernetes: Reloaded
The Hacker's Guide to Kubernetes: Reloaded
 
The Hacker's Guide to Kubernetes
The Hacker's Guide to KubernetesThe Hacker's Guide to Kubernetes
The Hacker's Guide to Kubernetes
 
The Hacker's Guide to JWT Security
The Hacker's Guide to JWT SecurityThe Hacker's Guide to JWT Security
The Hacker's Guide to JWT Security
 
The Hacker's Guide to JWT Security
The Hacker's Guide to JWT SecurityThe Hacker's Guide to JWT Security
The Hacker's Guide to JWT Security
 
Second Level Cache in JPA Explained
Second Level Cache in JPA ExplainedSecond Level Cache in JPA Explained
Second Level Cache in JPA Explained
 
Thinking Beyond ORM in JPA
Thinking Beyond ORM in JPAThinking Beyond ORM in JPA
Thinking Beyond ORM in JPA
 
The Hacker's Guide To Session Hijacking
The Hacker's Guide To Session HijackingThe Hacker's Guide To Session Hijacking
The Hacker's Guide To Session Hijacking
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1
 
Thinking Beyond ORM in JPA
Thinking Beyond ORM in JPAThinking Beyond ORM in JPA
Thinking Beyond ORM in JPA
 

Recently uploaded

Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 

Recently uploaded (20)

De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 

The Hacker's Guide to NoSQL Injection