SlideShare a Scribd company logo
1 of 26
Download to read offline
OUR DOCKER APP GOT HACKED…

NOW WHAT?
Joel Lathrop
JOEL@DIDACTIC-SECURITY.COM
BSidesRDU | October 2018
Copyright © 2018 Didactic Security
GOALS
‣ from a live system
‣ from a cold disk image
‣ … that used the overlay2 storage backend
‣ … that used the devicemapper storage backend
Know how to forensically capture a Docker container ...
Copyright © 2018 Didactic Security
ANATOMY
/usr/bin/foo
/etc/foo.conf
/usr/lib/libbar.so
<< Debian 9 image >>
ephemeral
Foo
Copyright © 2018 Didactic Security
LIVE CAPTURE
Container metadata
Log of all terminal I/O
Container filesystem snapshot
Container process memory
$ docker inspect foo
$ docker commit foo image-of-foo
$ docker save image-of-foo | gzip > image-of-foo.tar.gz
$ docker top foo
UID PID PPID C STIME TTY TIME CMD
root 4802 4784 0 17:53 pts/0 00:00:00 /usr/bin/my-app
$ gcore 4802
$ docker logs foo
Copyright © 2018 Didactic Security
COLD CAPTURE
Where are the goodies at?
/var/lib/docker
Copyright © 2018 Didactic Security
IMAGE LISTING
{
“Repositories”: {
“alpine”: {
“alpine:latest”: “sha256:196d12…”,
“alpine@sha256:621c2f…”: “sha256:196d12…”
},
“testing”: {
“testing:latest”: “sha256:2ba43e…”
}
}
}
image/<backend>/repositories.json
Copyright © 2018 Didactic Security
IMAGE METADATA
‣ A JSON file containing…
‣ Image name
‣ Container entrypoint script
‣ Build history
‣ Creation timestamp
‣ … and more
image/<backend>/imagedb/content/sha256/<ID>
Copyright © 2018 Didactic Security
CONTAINER METADATA
‣ Name
‣ Image ID
‣ Driver
‣ State.StartedAt &
State.FinishedAt
‣ Path & Args
containers/<ID>/config.v2.json
‣ Config.Env
‣ MountPoints
‣ LogPath
‣ For JSON logger will be

<ID>-json.log in same directory.
‣ … and more
Copyright © 2018 Didactic Security
WHAT ABOUT DISK CONTENT?
Source: https://docs.docker.com/storage/storagedriver
Copyright © 2018 Didactic Security
EXAMPLE CONTAINER
FROM alpine
ADD lemons pears /fruit/
ADD entrypoint.sh /
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
echo 'Empires are the best!' > /fruit/apples
echo 'Makes a good sugary drink.' > /fruit/lemons
echo 'This looks interesting...' > /fruit/durian
sync # force modifications to disk
rm /fruit/durian # can't stand the smell
rm /fruit/pears # over-ripen as soon as you turn your back
Dockerfile
entrypoint.sh
Copyright © 2018 Didactic Security
ANTICIPATED LAYERS
< alpine linux >
apples lemons
pearslemons
Copyright © 2018 Didactic Security
STORAGE BACKEND: OVERLAY2
‣ Linux kernel module: OverlayFS
‣ Stacked directory tree differences
‣ Uses host filesystem
‣ Docker’s preferred storage backend
Source: https://docs.docker.com/storage/storagedriver/overlayfs-driver
Copyright © 2018 Didactic Security
FINDING CONTAINER STORAGE
/var/lib/docker
├────────────────────────────────────────── overlay2
└── image │
└── overlay2 │
└── layerdb │
├── mounts │
│ └── <container ID> │
│ ├── mount-id ├── a23520
│ └── parent │ └── diff
│ │
└── sha256 │
├── 2ff448 │
│ ├── cache-id ├── b58759
│ └── parent │ └── diff
│ │
└── df64d3 │
└── cache-id └── dfbfbb
└── diff
Copyright © 2018 Didactic Security
CONTAINER R/W LAYER
$ mkdir /tmp/view
$ mount -t overlay overlay
-o ro,lowerdir="./overlay2/a23520/diff:
./overlay2/b58759/diff:
./overlay2/dfbfbb/diff"
/tmp/view
$ ls -l /tmp/view/fruit
total 20
-rw-r--r-- 1 root root 22 Oct 12 13:45 apples
-rw-r----- 1 root root 27 Oct 12 13:45 lemons
Copyright © 2018 Didactic Security
TOP IMAGE LAYER
$ mkdir /tmp/view
$ mount -t overlay overlay
-o ro,lowerdir="./overlay2/b58759/diff:
./overlay2/dfbfbb/diff"
/tmp/view
$ ls -l /tmp/view/fruit
total 20
-rw-r----- 1 root root 17 Oct 11 20:54 lemons
-rw-r----- 1 root root 33 Oct 11 20:54 pears
Copyright © 2018 Didactic Security
RAW OVERLAYFS
$ ls -l overlay2/a23520/diff/fruit/
total 20
-rw-r--r-- 1 root root 22 Oct 12 13:45 apples
-rw-r----- 1 root root 27 Oct 12 13:45 lemons
c--------- 1 root root 0, 0 Oct 12 13:45 pears
Represents a deleted file
Copyright © 2018 Didactic Security
WHAT ABOUT THE DURIAN?
$ ifind -f ext4 -n /var/lib/docker/overlay2/a23520/diff/fruit

/dev/sda1
259987
$ fls /dev/sda1 259987
r/r 259988: apples
r/r 259989: lemons
r/l * 259990: durian
c/c 259974: pears
Copyright © 2018 Didactic Security
EASY BUTTON!
Romain Gayon automated mounting overlay2 container storage
https://github.com/google/docker-explorer
(Only works for overlay, overlay2, and aufs Docker storage backends.)
Copyright © 2018 Didactic Security
STORAGE BACKEND: DEVICEMAPPER
‣ Uses an LVM storage pool for
production deployments
‣ Leverages "thin" device
mapper snapshots
‣ Unlike OverlayFS, the base
units are block devices, not
files
‣ You'll likely encounter this if
the host is RedHat or CentOSSource: https://docs.docker.com/storage/storagedriver/device-mapper-driver
Copyright © 2018 Didactic Security
FINDING CONTAINER STORAGE
/var/lib/docker
├───────────────────────────────────── devicemapper
└── image └── metadata
└── devicemapper │
└── layerdb │
├── mounts │
│ └── <container ID> │
│ ├── mount-id ├── a23520
│ └── parent │
│ │
└── sha256 │
├── 2ff448 │
│ ├── cache-id ├── b58759
│ └── parent │
│ │
└── df64d3 │
└── cache-id └── dfbfbb
Copyright © 2018 Didactic Security
THIN POOL DEVICES
dmsetup create my-new-device —table
"0 10240 thin /dev/mapper/pool-device 3"
new device name
starting sector
size in sectors
pool device volume ID
Copyright © 2018 Didactic Security
ACCESSING A LAYER
*
$ jq . devicemapper/metadata/a23520
{
"device_id": 13,
"size": 10737418240,
"transaction_id": 16,
"initialized": false,
"deleted": false
}
$ dmsetup create dk-my-container --table 
"0 $((10737418240 / 512)) thin /dev/docker/thinpool 13"
$ file -s -L /dev/mapper/dk-my-container
/dev/mapper/dk-base: SGI XFS filesystem data

(blksz 4096, inosz 256, v2 dirs)
*You will need to load the LVM volumes first.
Copyright © 2018 Didactic Security
MOUNTING THE LAYER
$ mkdir /mnt/my-container
$ mount -o ro,nouuid /dev/mapper/dk-my-container /mnt/my-container
$ ls -l /mnt/my-container/rootfs/fruit/
total 8
-rw-r--r--. 1 root root 22 Oct 13 16:40 apples
-rw-r-----. 1 root root 27 Oct 13 16:40 lemons
Copyright © 2018 Didactic Security
FURTHER ANALYSIS
‣ Thin pool devices ⇒ Virtual disks
‣ Use your regular imaging & analysis tools!
‣ Can compare with lower layers
‣ thin_dump reveals block-level differences
Copyright © 2018 Didactic Security
SUMMARY
‣ Metadata in JSON files
‣ Follow the layerdb chain of parent pointers
‣ overlay2: Layers are directory differences
‣ devicemapper: Layers are virtual disk snapshots
Questions?
JOEL@DIDACTIC-SECURITY.COM
Copyright © 2018 Didactic Security
https://www.didactic-security.com/resources/
docker-forensics-cheatsheet.pdf
Bonus!

More Related Content

What's hot

Threat Hunting Workshop
Threat Hunting WorkshopThreat Hunting Workshop
Threat Hunting WorkshopSplunk
 
PurpleSharp BlackHat Arsenal Asia
PurpleSharp BlackHat Arsenal AsiaPurpleSharp BlackHat Arsenal Asia
PurpleSharp BlackHat Arsenal AsiaMauricio Velazco
 
MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...
MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...
MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...MITRE - ATT&CKcon
 
You can detect PowerShell attacks
You can detect PowerShell attacksYou can detect PowerShell attacks
You can detect PowerShell attacksMichael Gough
 
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison DowdneySetting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison DowdneyWeaveworks
 
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with TeleportRole Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with TeleportDevOps.com
 
No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016Matthew Dunwoody
 
OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?Beau Bullock
 
MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...
MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...
MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...MITRE - ATT&CKcon
 
Ransomware Resistance
Ransomware ResistanceRansomware Resistance
Ransomware ResistanceFlorian Roth
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows EnvironmentHunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows EnvironmentTeymur Kheirkhabarov
 
Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container SecuritySuraj Khetani
 
Windows Threat Hunting
Windows Threat HuntingWindows Threat Hunting
Windows Threat HuntingGIBIN JOHN
 
Building an IP Reputation Engine: Tracking the Miscreants
Building an IP Reputation Engine: Tracking the MiscreantsBuilding an IP Reputation Engine: Tracking the Miscreants
Building an IP Reputation Engine: Tracking the MiscreantsAlienVault
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to dockerWei-Ting Kuo
 

What's hot (20)

Threat Hunting Workshop
Threat Hunting WorkshopThreat Hunting Workshop
Threat Hunting Workshop
 
PurpleSharp BlackHat Arsenal Asia
PurpleSharp BlackHat Arsenal AsiaPurpleSharp BlackHat Arsenal Asia
PurpleSharp BlackHat Arsenal Asia
 
MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...
MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...
MITRE ATT&CKcon 2.0: Prioritizing Data Sources for Minimum Viable Detection; ...
 
You can detect PowerShell attacks
You can detect PowerShell attacksYou can detect PowerShell attacks
You can detect PowerShell attacks
 
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison DowdneySetting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
 
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with TeleportRole Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
 
No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016
 
Introducing Vault
Introducing VaultIntroducing Vault
Introducing Vault
 
OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?
 
Kheirkhabarov24052017_phdays7
Kheirkhabarov24052017_phdays7Kheirkhabarov24052017_phdays7
Kheirkhabarov24052017_phdays7
 
Hashicorp Vault ppt
Hashicorp Vault pptHashicorp Vault ppt
Hashicorp Vault ppt
 
Block Storage For VMs With Ceph
Block Storage For VMs With CephBlock Storage For VMs With Ceph
Block Storage For VMs With Ceph
 
Docker on Docker
Docker on DockerDocker on Docker
Docker on Docker
 
MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...
MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...
MITRE ATT&CKcon 2.0: Flashback with ATT&CK: Exploring Malware History with AT...
 
Ransomware Resistance
Ransomware ResistanceRansomware Resistance
Ransomware Resistance
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows EnvironmentHunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows Environment
 
Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
 
Windows Threat Hunting
Windows Threat HuntingWindows Threat Hunting
Windows Threat Hunting
 
Building an IP Reputation Engine: Tracking the Miscreants
Building an IP Reputation Engine: Tracking the MiscreantsBuilding an IP Reputation Engine: Tracking the Miscreants
Building an IP Reputation Engine: Tracking the Miscreants
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 

Similar to Docker Forensics

Lessons Learned in Automating Compliance for Containers
Lessons Learned in Automating Compliance for ContainersLessons Learned in Automating Compliance for Containers
Lessons Learned in Automating Compliance for ContainersAll Things Open
 
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
Kubernetes Summit 2019 - Harden Your Kubernetes ClusterKubernetes Summit 2019 - Harden Your Kubernetes Cluster
Kubernetes Summit 2019 - Harden Your Kubernetes Clustersmalltown
 
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchaginstackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
stackconf 2020 | Speeding up Linux disk encryption by Ignat KorchaginNETWAYS
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For DevelopmentLaura Frank Tacho
 
Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Ricardo Amaro
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant Ricardo Amaro
 
ITB2019 Try This At Home: Building a Personal Docker Swarm - Matt Clemente
ITB2019 Try This At Home: Building a Personal Docker Swarm - Matt ClementeITB2019 Try This At Home: Building a Personal Docker Swarm - Matt Clemente
ITB2019 Try This At Home: Building a Personal Docker Swarm - Matt ClementeOrtus Solutions, Corp
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Securing Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - AdobeSecuring Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - AdobeCodeOps Technologies LLP
 
Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Nicola Paolucci
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on DockerRightScale
 
LinuxLabs 2017 talk: Container monitoring challenges
LinuxLabs 2017 talk: Container monitoring challengesLinuxLabs 2017 talk: Container monitoring challenges
LinuxLabs 2017 talk: Container monitoring challengesXavier Vello
 
Docker Basics & Alfresco Content Services
Docker Basics & Alfresco Content ServicesDocker Basics & Alfresco Content Services
Docker Basics & Alfresco Content ServicesSujay Pillai
 
Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Michael Boelen
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production OverviewDelve Labs
 
Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?Giri Kuncoro
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker皓鈞 張
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned RightScale
 

Similar to Docker Forensics (20)

Lessons Learned in Automating Compliance for Containers
Lessons Learned in Automating Compliance for ContainersLessons Learned in Automating Compliance for Containers
Lessons Learned in Automating Compliance for Containers
 
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
Kubernetes Summit 2019 - Harden Your Kubernetes ClusterKubernetes Summit 2019 - Harden Your Kubernetes Cluster
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
 
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchaginstackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For Development
 
Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant
 
Securing containers
Securing containersSecuring containers
Securing containers
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
 
Container BoM Inspection with TERN
Container BoM Inspection with TERNContainer BoM Inspection with TERN
Container BoM Inspection with TERN
 
ITB2019 Try This At Home: Building a Personal Docker Swarm - Matt Clemente
ITB2019 Try This At Home: Building a Personal Docker Swarm - Matt ClementeITB2019 Try This At Home: Building a Personal Docker Swarm - Matt Clemente
ITB2019 Try This At Home: Building a Personal Docker Swarm - Matt Clemente
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Securing Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - AdobeSecuring Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - Adobe
 
Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)Be a better developer with Docker (revision 3)
Be a better developer with Docker (revision 3)
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
 
LinuxLabs 2017 talk: Container monitoring challenges
LinuxLabs 2017 talk: Container monitoring challengesLinuxLabs 2017 talk: Container monitoring challenges
LinuxLabs 2017 talk: Container monitoring challenges
 
Docker Basics & Alfresco Content Services
Docker Basics & Alfresco Content ServicesDocker Basics & Alfresco Content Services
Docker Basics & Alfresco Content Services
 
Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production Overview
 
Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
 

Recently uploaded

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

Docker Forensics

  • 1. OUR DOCKER APP GOT HACKED…
 NOW WHAT? Joel Lathrop JOEL@DIDACTIC-SECURITY.COM BSidesRDU | October 2018
  • 2. Copyright © 2018 Didactic Security GOALS ‣ from a live system ‣ from a cold disk image ‣ … that used the overlay2 storage backend ‣ … that used the devicemapper storage backend Know how to forensically capture a Docker container ...
  • 3. Copyright © 2018 Didactic Security ANATOMY /usr/bin/foo /etc/foo.conf /usr/lib/libbar.so << Debian 9 image >> ephemeral Foo
  • 4. Copyright © 2018 Didactic Security LIVE CAPTURE Container metadata Log of all terminal I/O Container filesystem snapshot Container process memory $ docker inspect foo $ docker commit foo image-of-foo $ docker save image-of-foo | gzip > image-of-foo.tar.gz $ docker top foo UID PID PPID C STIME TTY TIME CMD root 4802 4784 0 17:53 pts/0 00:00:00 /usr/bin/my-app $ gcore 4802 $ docker logs foo
  • 5. Copyright © 2018 Didactic Security COLD CAPTURE Where are the goodies at? /var/lib/docker
  • 6. Copyright © 2018 Didactic Security IMAGE LISTING { “Repositories”: { “alpine”: { “alpine:latest”: “sha256:196d12…”, “alpine@sha256:621c2f…”: “sha256:196d12…” }, “testing”: { “testing:latest”: “sha256:2ba43e…” } } } image/<backend>/repositories.json
  • 7. Copyright © 2018 Didactic Security IMAGE METADATA ‣ A JSON file containing… ‣ Image name ‣ Container entrypoint script ‣ Build history ‣ Creation timestamp ‣ … and more image/<backend>/imagedb/content/sha256/<ID>
  • 8. Copyright © 2018 Didactic Security CONTAINER METADATA ‣ Name ‣ Image ID ‣ Driver ‣ State.StartedAt & State.FinishedAt ‣ Path & Args containers/<ID>/config.v2.json ‣ Config.Env ‣ MountPoints ‣ LogPath ‣ For JSON logger will be
 <ID>-json.log in same directory. ‣ … and more
  • 9. Copyright © 2018 Didactic Security WHAT ABOUT DISK CONTENT? Source: https://docs.docker.com/storage/storagedriver
  • 10. Copyright © 2018 Didactic Security EXAMPLE CONTAINER FROM alpine ADD lemons pears /fruit/ ADD entrypoint.sh / ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] echo 'Empires are the best!' > /fruit/apples echo 'Makes a good sugary drink.' > /fruit/lemons echo 'This looks interesting...' > /fruit/durian sync # force modifications to disk rm /fruit/durian # can't stand the smell rm /fruit/pears # over-ripen as soon as you turn your back Dockerfile entrypoint.sh
  • 11. Copyright © 2018 Didactic Security ANTICIPATED LAYERS < alpine linux > apples lemons pearslemons
  • 12. Copyright © 2018 Didactic Security STORAGE BACKEND: OVERLAY2 ‣ Linux kernel module: OverlayFS ‣ Stacked directory tree differences ‣ Uses host filesystem ‣ Docker’s preferred storage backend Source: https://docs.docker.com/storage/storagedriver/overlayfs-driver
  • 13. Copyright © 2018 Didactic Security FINDING CONTAINER STORAGE /var/lib/docker ├────────────────────────────────────────── overlay2 └── image │ └── overlay2 │ └── layerdb │ ├── mounts │ │ └── <container ID> │ │ ├── mount-id ├── a23520 │ └── parent │ └── diff │ │ └── sha256 │ ├── 2ff448 │ │ ├── cache-id ├── b58759 │ └── parent │ └── diff │ │ └── df64d3 │ └── cache-id └── dfbfbb └── diff
  • 14. Copyright © 2018 Didactic Security CONTAINER R/W LAYER $ mkdir /tmp/view $ mount -t overlay overlay -o ro,lowerdir="./overlay2/a23520/diff: ./overlay2/b58759/diff: ./overlay2/dfbfbb/diff" /tmp/view $ ls -l /tmp/view/fruit total 20 -rw-r--r-- 1 root root 22 Oct 12 13:45 apples -rw-r----- 1 root root 27 Oct 12 13:45 lemons
  • 15. Copyright © 2018 Didactic Security TOP IMAGE LAYER $ mkdir /tmp/view $ mount -t overlay overlay -o ro,lowerdir="./overlay2/b58759/diff: ./overlay2/dfbfbb/diff" /tmp/view $ ls -l /tmp/view/fruit total 20 -rw-r----- 1 root root 17 Oct 11 20:54 lemons -rw-r----- 1 root root 33 Oct 11 20:54 pears
  • 16. Copyright © 2018 Didactic Security RAW OVERLAYFS $ ls -l overlay2/a23520/diff/fruit/ total 20 -rw-r--r-- 1 root root 22 Oct 12 13:45 apples -rw-r----- 1 root root 27 Oct 12 13:45 lemons c--------- 1 root root 0, 0 Oct 12 13:45 pears Represents a deleted file
  • 17. Copyright © 2018 Didactic Security WHAT ABOUT THE DURIAN? $ ifind -f ext4 -n /var/lib/docker/overlay2/a23520/diff/fruit
 /dev/sda1 259987 $ fls /dev/sda1 259987 r/r 259988: apples r/r 259989: lemons r/l * 259990: durian c/c 259974: pears
  • 18. Copyright © 2018 Didactic Security EASY BUTTON! Romain Gayon automated mounting overlay2 container storage https://github.com/google/docker-explorer (Only works for overlay, overlay2, and aufs Docker storage backends.)
  • 19. Copyright © 2018 Didactic Security STORAGE BACKEND: DEVICEMAPPER ‣ Uses an LVM storage pool for production deployments ‣ Leverages "thin" device mapper snapshots ‣ Unlike OverlayFS, the base units are block devices, not files ‣ You'll likely encounter this if the host is RedHat or CentOSSource: https://docs.docker.com/storage/storagedriver/device-mapper-driver
  • 20. Copyright © 2018 Didactic Security FINDING CONTAINER STORAGE /var/lib/docker ├───────────────────────────────────── devicemapper └── image └── metadata └── devicemapper │ └── layerdb │ ├── mounts │ │ └── <container ID> │ │ ├── mount-id ├── a23520 │ └── parent │ │ │ └── sha256 │ ├── 2ff448 │ │ ├── cache-id ├── b58759 │ └── parent │ │ │ └── df64d3 │ └── cache-id └── dfbfbb
  • 21. Copyright © 2018 Didactic Security THIN POOL DEVICES dmsetup create my-new-device —table "0 10240 thin /dev/mapper/pool-device 3" new device name starting sector size in sectors pool device volume ID
  • 22. Copyright © 2018 Didactic Security ACCESSING A LAYER * $ jq . devicemapper/metadata/a23520 { "device_id": 13, "size": 10737418240, "transaction_id": 16, "initialized": false, "deleted": false } $ dmsetup create dk-my-container --table "0 $((10737418240 / 512)) thin /dev/docker/thinpool 13" $ file -s -L /dev/mapper/dk-my-container /dev/mapper/dk-base: SGI XFS filesystem data
 (blksz 4096, inosz 256, v2 dirs) *You will need to load the LVM volumes first.
  • 23. Copyright © 2018 Didactic Security MOUNTING THE LAYER $ mkdir /mnt/my-container $ mount -o ro,nouuid /dev/mapper/dk-my-container /mnt/my-container $ ls -l /mnt/my-container/rootfs/fruit/ total 8 -rw-r--r--. 1 root root 22 Oct 13 16:40 apples -rw-r-----. 1 root root 27 Oct 13 16:40 lemons
  • 24. Copyright © 2018 Didactic Security FURTHER ANALYSIS ‣ Thin pool devices ⇒ Virtual disks ‣ Use your regular imaging & analysis tools! ‣ Can compare with lower layers ‣ thin_dump reveals block-level differences
  • 25. Copyright © 2018 Didactic Security SUMMARY ‣ Metadata in JSON files ‣ Follow the layerdb chain of parent pointers ‣ overlay2: Layers are directory differences ‣ devicemapper: Layers are virtual disk snapshots
  • 26. Questions? JOEL@DIDACTIC-SECURITY.COM Copyright © 2018 Didactic Security https://www.didactic-security.com/resources/ docker-forensics-cheatsheet.pdf Bonus!