Consul RCE
Consul without ACLs (or with a permissive anonymous policy) allows registering services with health checks that execute arbitrary commands. The exec API (if enabled) provides direct command execution across cluster nodes. Confirm unauthenticated access through Consul enumeration first.
RCE via Service Registration
Register a service with a health check script. Consul executes the script at the defined interval to check service health. This is the most reliable RCE method.
The health check script executes every 10 seconds. Start nc -lvnp on your listener first. The shell runs as the consul user. Deregister the service after to stop repeated connections.
Warning
Health check scripts require enable_script_checks = true in the Consul agent configuration. This is disabled by default since Consul 1.0 but still common in older deployments and development environments.
RCE via Exec API
The /v1/agent/exec API (deprecated but still available when disable_remote_exec = false) executes a command on all cluster nodes simultaneously.
consul-server-01: uid=100(consul) gid=1000(consul) groups=1000(consul) consul-client-01: uid=100(consul) gid=1000(consul) groups=1000(consul)
Runs on every node in the cluster. Requires the consul CLI or equivalent API calls. Disabled by default since Consul 0.8.
KV Store Manipulation
With write access to the KV store, modify application configuration to inject backdoors or redirect traffic.
true
Applications using Consul for config may pick up the change dynamically. Redirecting a database host to your machine captures credentials from connection attempts.
ACL Token Extraction
If the current access level allows reading ACL tokens, extract them for elevated access.
The token list shows token IDs and policies but not the secret values. Use /v1/acl/token/<AccessorID> to read individual tokens. The master/bootstrap token has global-management policy.
Snapshot for Offline Analysis
A Consul snapshot contains the entire cluster state: KV data, ACL tokens, service registrations, and configuration.
The snapshot is a gzip-compressed file containing Raft state. Extract and parse for ACL tokens, KV secrets, and service configs.
References
-
Consul: Service Registration APILINK: Consul: Service Registration API, developer.hashicorp.com/consul/api-docs/agent/service (opens in new tab)
Official docs on service registration with health checks.
-
Consul: Security ModelDOCS: Consul: Security Model, www.consul.io/docs/security (opens in new tab)
ACL system, encryption, and access control documentation.
-
HackTricks: 8500 Pentesting ConsulTOOL: HackTricks: 8500 Pentesting Consul, hacktricks.wiki/en/network-services-pentesting/8500-pentesting-consul.html (opens in new tab)
Consul RCE via health checks and exec API.