Docker Might not be your friend
Trojanizing Docker like a Sir
Roberto	Muñoz	(robsky)	-	@skyeinthewildDaniel	García	(cr0hn)	-	@ggdaniel
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
<spam>About	Us</spam>
• Creator/co-creator	many	security	tools	
• Security	researcher	/	ethical	hacking	
• Chapter	Leader	OWASP	Madrid	
• Python	developer
https://www.linkedin.com/in/garciagarciadaniel
https://www.linkedin.com/in/roberto-muñoz-fernández-8389a313/
• SecDevOPs	
• Security	researcher	
• Former	 BOFH	 (Because	 even	 developers	
need	heroes)
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
What’s	this	talk	about?
1. What’s	Docker	
2. The	Docker	environment	
3. What’s	a	C.I.	/	C.D.	cycle?	
4. Dissecting	Docker	images	
5. Abusing	Docker	registry?	
6. Conclusions
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
What’s	this	talk	about?
1. What’s	Docker	
2. The	Docker	environment	
3. What’s	a	C.I.	/	C.D.	cycle?	
4. Dissecting	Docker	images	
5. Abusing	Docker	registry?	
6. Conclusions
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
WHAT’S	DOCKER?
If	you	feel	like	the	monkeys	of	
2001	odyssey,	this	is	chapter	is	
important	to	you
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	A	brief	definition
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	A	brief	definition
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Docker	vs	VM
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Docker	vs	VM
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Docker	vs	VM
IS NOT
VIRTUALIZATION
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Docker	vs	VM
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Docker	vs	VM
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Docker	vs	VM
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Dockerfile Image Container
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Dockerfile Image Container
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Dockerfile Image Container
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Different
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Different
But similar
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	Docker	-	Parts
Different
But similar
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
THE	DOCKER	ENVIRONMENT
Neighbourhood	colleagues
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Docker	Registry
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Docker	Registry Docker	Orchestrators
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Docker	Host
Docker	Registry Docker	Orchestrators
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Docker	Host
Docker	Registry
Docker	Image	builder
Docker	Orchestrators
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	environment
Docker	Host
Docker	Registry
Docker	Image	builder
Docker	Orchestrators
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
WHAT’S	A	C.I.	/	C.D	CYCLE?
Ensure	that	your	boss	does	not	see	this,	
he	could	realise	that	you	are	not	really	
necessary….	fired!	fired!	fired!
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Summary	-	Definitions
1. Continuous Integration - C.I:
“Is the practice of merging all developer working
copies to a shared mainline several times a day.”
2.Continuous Deployment - C.D:
“Is a software engineering approach in which
teams produce software in short cycles,
ensuring that the software can be reliably
released at any time.”
Source Wikipedia
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I	-	Classic	cycle
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I	-	Classic	cycle
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I	-	Classic	cycle
Very manual process
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I	-	Classic	cycle
Very manual process
Restart the process
is hard
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I	-	Classic	cycle
Very manual process
Restart the process
is hard
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I	-	Classic	cycle
Very manual process
Restart the process
is hard
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I.	-	New	approach
https://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I.	-	New	approach
https://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I.	-	New	approach
https://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
C.I.	+	C.D.	-	New	approach	with	Docker
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Image	builder
C.I.	+	C.D.	-	New	approach	with	Docker
Docker	Host Docker	Registry
Orchestrator
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
DISSECTING	DOCKER	IMAGES
Shut	up	and	tell	me	how	I	can	break	it	
down
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
What’s	a	docker	image?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Global	Metadata
Global	metadata	JSON	file
• Global	info	about	image	
• Modification	history	
• A	SHA256	hash	of	each	layer.	
Stored	in	order.
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Manifest
Manifest	file
• A	reference	to	global	config	
file.	
• List	of	tags	for	the	image.	
• List	of	layers.	IN	ORDER
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Repositories
Repositories
• Repository	witch	belong	the	
image.	
• Repository	tags	available.	
• A	reference	to	the	last	layer.
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Layers
Image	layers
• A	docker	image	can	contains	
any	number	of	layers	
• Each	layer	has	their	own	
folder.	
• Each	layer	has	3	files:	
• json	
• layer.tar	
• VERSION
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Layer	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Layer	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Layer	content
• Layer	metadata	
• Reference	to	the	parent	layer
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Layer	content
• Layer	metadata	
• Reference	to	the	parent	layer
• Layer	version
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Layer	content
• Layer	metadata	
• Reference	to	the	parent	layer
• Layer	version
• Folders	/	files	
• Incremental	file	system
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	image	parts	-	Extracting	content
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Why?
• Change	environment	vars	
• Change	Entry	Point	
• Add	new/modify	files	
• Analyse	the	image	
• Extract	the	content
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Manifest	/	Metadata	only	meet	
the	layer	hash
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Manifest	/	Metadata	only	meet	
the	layer	hash
The	layer	hash	is	referenced	in	
many	places
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Manifest	/	Metadata	only	meet	
the	layer	hash
The	layer	hash	is	referenced	in	
many	places
A	tiny	change	in	a	layer	content	
implies	many	changes	in	many	
files.
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
SHA256:	
f94a86523746be32e7981681172198717edd94333d263b1f64228a41e14dc6b5
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
We	need	to	update	the	
references	and	metadata
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
We	need	to	update	the	
references	and	metadata
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
SHA256:	
f94a86523746be32e7981681172198717edd94333d263b1f64228a41e14dc6b5
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
We	need	to	update	the	
references	and	metadata
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
We	need	to	update	the	
references	and	metadata
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
We	need	to	update	the	
references	and	metadata
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Problems
We	need	to	update	the	
references	and	metadata
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
LD_PRELOAD
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
LD_PRELOAD
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
LD_PRELOAD
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Manipulating	Docker	images	-	Attacks
LD_PRELOAD
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker Scan
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
https://github.com/cr0hn/dockerscan	
Docker Scan
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
¡	Demo	time	!
Trojanizing	Docker	Images	with	
Docker	Scan
Manipulating	Docker	images	-	Attacks
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
ABUSING	DOCKER	REGISTRY?
Yes,	we	love	break	things…
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Docker	Registry	(D.R)	-	Brief	summary
• Storage	docker	images.	
• Index	the	images	hashes	
• Create	 a	 logical	 structure	 to	 locate	
docker	images:	repository/image:tag	
• Exposes	a	REST	API	to	interact.
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage
Storage	server Indexing	server
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	How	registry	storage	the	images?
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	How	registry	storage	the	images?
…
…
Images
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	How	registry	storage	the	images?
…
…
Images Tags
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
latest
D.R.	-	How	registry	storage	the	images?
1.1.10
1.11.10-alpine
1.10.3-alpine
…
…
…
Images Tags
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage	:	Upload	process
Client Docker	Registry
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage	:	Upload	process
Client Docker	Registry
I	want	upload	the	image:	minion
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage	:	Upload	process
Client Docker	Registry
I	want	upload	the	image:	minion
Oks.	Here	is	your	upload	Path
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage	:	Upload	process
Client Docker	Registry
I	want	upload	the	image:	minion
Oks.	Here	is	your	upload	Path
Uploading…
SHA256:	
f94a86523746be32e7981681172198717edd94333d263b1f64228a41e
14dc6b5
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	As	image	storage	:	Upload	process
Client Docker	Registry
I	want	upload	the	image:	minion
Oks.	Here	is	your	upload	Path
Uploading…
Add	the	tag:	Latest
minion :Latest
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Client Docker	Registry
I	want	upload	the	image:	minion
Oks.	Here	is	your	upload	Path
Uploading…
Add	the	tag:	Latest
minion :Latest
D.R.	-	Attacks	:	Upload	non	accessible	files
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Client Docker	Registry
I	want	upload	the	image:	minion
Oks.	Here	is	your	upload	Path
Uploading…
Add	the	tag:	Latest
minion :Latest
D.R.	-	Attacks	:	Upload	non	accessible	files
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
¡	Demo	time	!
Uploading	files	that	only	you	
can	download…
D.R.	-	Attacks	:	Upload	non	accesible	files
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	Attacks	:	Replace	remote	images
latest
1.1.10
1.11.10-alpine
1.10.3-alpine
…
…
…
Images Tags
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	Attacks	:	Replace	remote	images
latest
1.1.10
1.11.10-alpine
1.10.3-alpine
…
…
…
Images Tags
latest
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	A	short	search	in	Shodan
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	A	short	search	in	Shodan
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
D.R.	-	A	short	search	in	Shodan
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
CONCLUSIONS
The	conclusion	is	simple:	give	me	your	
money	and	avoid	intermediaries
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
WE	NEED	TO	INVOKE	
SECURITY!
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
BUILD	BEST	PRACTICES
• Do	not	trust	name	or	tags,	use	digests	instead	in	FROM	declarations.
• Always	check	the	integrity	of	anything	downloaded	in	build	time.
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
REGISTRY	SECURIZATION
• Implement	some	of	the	available	authN/authZ	
options.	
• Limit	the	exposure,	the	best	case	scenario	is	
where	only	the	build	servers	are	allowed	to	push	
images	to	registries	
• Implement	signing	(https://github.com/docker/
notary)	and	don't	execute	unsigned	images.
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
RUNTIME	PROTECTION
• Don't	execute	images	with	excessive	privileges	(--
privileged	flag,	added	capabilities,	disabled	
namespaces,	etc)	
• Use	native	docker	supported	custom	security	
profiles	for	your	containers	(Seccomp,Selinux/
Apparmor)	
• Use	dynamic	analysis	tools	to	create	behavioural	
profiles	of	the	containers	and	monitor	any	suspect	
change	in	the	container	activity.
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Be	careful….
…there	is	always	someone	watching
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Questions
?
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Docker	might	not	be	your	friend	-	Trojanizing	Docker	like	a	Sir
Daniel	García	(cr0hn)	-	@ggdaniel	|	Roberto	Muñoz	(robskye)	-	@skyeinthewild
Thank	you!

RootedCON 2017 - Docker might not be your friend. Trojanizing Docker images