2020-11-04 22:05:44 +00:00
---
layout: docs
2022-09-16 15:28:32 +00:00
page_title: Security Models - Consul
2020-11-04 22:05:44 +00:00
description: >-
2022-09-16 15:28:32 +00:00
The security model for Consul Core details requirements and recommendations for securing your deployment of Consul. Learn about potential threats and how to protect Consul from malicious actors.
2020-11-04 22:05:44 +00:00
---
2024-05-28 16:54:38 +00:00
# Consul security model overview
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
Consul enables automation of network configurations, service discovery, and secure network connectivity across any
2020-11-04 22:05:44 +00:00
cloud or runtime.
2020-12-08 23:24:36 +00:00
Consul uses a lightweight gossip and RPC system which provides various essential features. Both of these systems
2020-11-05 20:59:53 +00:00
provide security mechanisms which should be used to enable confidentiality, integrity and authentication.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
Using defense in depth is crucial for Consul security, and deployment requirements may differ drastically depending on
your use case. Some security features for multi-tenant deployments are offered exclusively in the
2023-01-25 16:52:43 +00:00
[Enterprise](/consul/docs/enterprise) version. This documentation may need to be adapted to your
2020-11-05 21:03:14 +00:00
environment, but the general mechanisms for a secure Consul deployment revolve around:
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **mTLS** - Mutual authentication of both the TLS server and client x509 certificates prevents internal abuse from
2020-11-04 22:05:44 +00:00
unauthorized access to network components within the cluster.
2020-12-08 23:24:36 +00:00
- **ACLs** - Enable role-based access controls for authenticated connections by granting capabilities for an individual
human, or machine operator identity via an ACL token to authorize actions within a cluster. Optionally, custom
2023-01-25 16:52:43 +00:00
[authentication methods](/consul/docs/security/acl/auth-methods) can be used to enable trusted external parties to authorize
2020-11-04 22:05:44 +00:00
ACL token creation.
2024-10-16 16:23:33 +00:00
- **Intentions** - If in use, configure service intentions to use a default-deny policy. If L7 intentions are
in use, enable [Mesh request normalization](/consul/docs/connect/config-entries/mesh#request-normalization)
and review your [header match rules](/consul/docs/connect/config-entries/service-intentions#spec-sources-permissions-http-header) to prevent malformed requests from bypassing intentions.
2020-11-06 15:47:22 +00:00
- **Namespaces** <EnterpriseAlert inline /> - Read and write operations can be scoped to a logical namespace to restrict
access to Consul components within a multi-tenant environment.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Sentinel Policies** <EnterpriseAlert inline /> - Sentinel policies enable policy-as-code for granular control over
2020-11-06 15:47:22 +00:00
the built-in key-value store.
2020-11-04 22:05:44 +00:00
2024-05-28 16:54:38 +00:00
## Personas
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
It helps to consider the following types of personas when managing the security requirements of a Consul deployment.
2020-11-04 22:05:44 +00:00
The granularity may change depending on your team's requirements.
2020-12-08 23:24:36 +00:00
- **System Administrator** - This is someone who has access to the underlying infrastructure to the Consul cluster.
2020-11-04 22:05:44 +00:00
Often they have access to SSH or RDP directly into a server within a cluster through a bastion host. Ultimately they
2020-12-08 23:24:36 +00:00
have read, write and execute permissions for the actual Consul binary. This binary is the same for server and client
agents using different configuration files. These users potentially have sudo, administrative, or some other
super-user access to the underlying compute resource. They have access to all persisted data on disk, or in memory.
This would include ACL tokens, certificates, and other secrets stored on the system. Users like these are essentially
totally trusted, as they have administrative rights to the underlying operating-system with the ability to configure,
2020-11-04 22:05:44 +00:00
start, and stop the agent.
2020-12-08 23:24:36 +00:00
- **Consul Administrator** - This is someone (probably the same System Administrator) who has access to define the
Consul agent configurations for servers and clients, and/or have a Consul management ACL token. They also have total
2020-11-04 22:05:44 +00:00
rights to all of the parts in the Consul system including the ability to manage all services within a cluster.
- **Consul Operator** - This is someone who likely has restricted capabilities to use their namespace within a cluster.
2020-12-08 23:24:36 +00:00
- **Developer** - This is someone who is responsible for creating, and possibly deploying applications connected, or
configured with Consul. In some cases they may have no access, or limited capabilities to view Consul information,
2020-11-04 22:05:44 +00:00
such as through metrics, or logs.
2020-12-08 23:24:36 +00:00
- **User** - This is the end user, using applications backed by services managed by Consul. In some cases services may
be public facing on the internet such as a web server, typically through a load-balancer, or ingress gateway. This is
2020-11-04 22:05:44 +00:00
someone who should not have any network access to the Consul agent APIs.
2024-05-28 16:54:38 +00:00
## Secure Configuration
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
Consul's security model is applicable only if all parts of the system are running with a secure configuration; **Consul
is not secure-by-default.** Without the following mechanisms enabled in Consul's configuration, it may be possible to
2020-11-04 22:05:44 +00:00
abuse access to a cluster. Like all security considerations, administrators must determine what is appropriate for their
environment and adapt these configurations accordingly.
2024-05-28 16:54:38 +00:00
## Requirements
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **mTLS** - Mutual authentication of both the TLS server and client x509 certificates prevents internal abuse through
2020-11-04 22:05:44 +00:00
unauthorized access to Consul agents within the cluster.
2023-01-25 16:52:43 +00:00
- [`tls.defaults.verify_incoming`](/consul/docs/agent/config/config-files#tls_defaults_verify_incoming) - By default this is false, and
2022-03-18 10:46:58 +00:00
should almost always be set to true to require TLS verification for incoming client connections. This applies to the
internal RPC, HTTPS and gRPC APIs.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`tls.https.verify_incoming`](/consul/docs/agent/config/config-files#tls_https_verify_incoming) - By default this is false, and should
2022-03-18 10:46:58 +00:00
be set to true to require clients to provide a valid TLS certificate when the Consul HTTPS API is enabled. TLS for
the API may be not be necessary if it is exclusively served over a loopback interface such as `localhost`.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`tls.internal_rpc.verify_incoming`](/consul/docs/agent/config/config-files#tls_internal_rpc_verify_incoming) - By default this is false,
2022-03-18 10:46:58 +00:00
and should almost always be set to true to require clients to provide a valid TLS certificate for Consul agent RPCs.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`tls.grpc.verify_incoming`](/consul/docs/agent/config/config-files#tls_grpc_verify_incoming) - By default this is false, and should
2022-03-18 10:46:58 +00:00
be set to true to require clients to provide a valid TLS certificate when the Consul gRPC API is enabled. TLS for
the API may be not be necessary if it is exclusively served over a loopback interface such as `localhost`.
2023-01-25 16:52:43 +00:00
- [`tls.internal_rpc.verify_outgoing`](/consul/docs/agent/config/config-files#tls_internal_rpc_verify_outgoing) - By default this is false,
2022-03-18 10:46:58 +00:00
and should be set to true to require TLS for outgoing connections from server or client agents. Servers that specify
`verify_outgoing = true` will always talk to other servers over TLS, but they still accept non-TLS connections to allow
for a transition of all clients to TLS. Currently the only way to enforce that no client can communicate with a server
unencrypted is to also enable `verify_incoming` which requires client certificates too.
2020-11-05 21:09:07 +00:00
2023-01-25 16:52:43 +00:00
- [`enable_agent_tls_for_checks`](/consul/docs/agent/config/config-files#enable_agent_tls_for_checks) - By default this is false, and
2020-12-08 23:24:36 +00:00
should almost always be set to true to require mTLS to set up the client for HTTP or gRPC health checks. This was
2020-11-05 21:09:07 +00:00
added in Consul 1.0.1.
2023-01-25 16:52:43 +00:00
- [`tls.internal_rpc.verify_server_hostname`](/consul/docs/agent/config/config-files#tls_internal_rpc_verify_server_hostname) - By default
2022-03-18 10:46:58 +00:00
this is false, and should be set to true to require that the TLS certificate presented by the servers matches
2020-12-08 23:24:36 +00:00
`server.<datacenter>.<domain>` hostname for outgoing TLS connections. The default configuration does not verify the
hostname of the certificate, only that it is signed by a trusted CA. This setting is critical to prevent a
compromised client agent from being restarted as a server and having all cluster state including all ACL tokens and
2023-05-05 17:41:40 +00:00
service mesh CA root keys replicated to it. This setting was introduced in 0.5.1. From version 0.5.1 to 1.4.0 we
2020-12-08 23:24:36 +00:00
documented that `verify_server_hostname` being true implied verify_outgoing however due to a bug this was not the
case so setting only `verify_server_hostname` results in plaintext communication between client and server. See
[CVE-2018-19653](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-19653) for more details. This is fixed
2020-11-05 21:09:07 +00:00
in 1.4.1.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`auto_encrypt`](/consul/docs/agent/config/config-files#auto_encrypt) - Enables automated TLS certificate distribution for client
2023-05-05 17:41:40 +00:00
agent RPC communication using the service mesh CA. Using this configuration a [`ca_file`](/consul/docs/agent/config/config-files#tls_defaults_ca_file)
2020-11-06 15:15:26 +00:00
and ACL token would still need to be distributed to client agents.
2020-12-08 23:24:36 +00:00
2023-01-25 16:52:43 +00:00
- [`allow_tls`](/consul/docs/agent/config/config-files#allow_tls) - By default this is false, and should be set to true on server
2023-05-05 17:41:40 +00:00
agents to allow certificates to be automatically generated and distributed from the service mesh CA to client agents.
2020-12-08 23:24:36 +00:00
2023-01-25 16:52:43 +00:00
- [`tls`](/consul/docs/agent/config/config-files#tls) - By default this is false, and should be set to true on client agents to
2023-05-05 17:41:40 +00:00
automatically request a client TLS certificate from the server's service mesh CA.
2020-11-06 15:15:26 +00:00
2020-11-04 22:05:44 +00:00
**Example Server Agent TLS Configuration**
```hcl
2022-03-18 10:46:58 +00:00
tls {
defaults {
verify_incoming = true
verify_outgoing = true
ca_file = "consul-agent-ca.pem"
cert_file = "dc1-server-consul-0.pem"
key_file = "dc1-server-consul-0-key.pem"
verify_server_hostname = true
}
}
2020-12-08 23:24:36 +00:00
2020-11-04 22:05:44 +00:00
auto_encrypt {
2022-03-18 10:46:58 +00:00
allow_tls = true
2020-11-04 22:05:44 +00:00
}
```
**Example Client Agent TLS Configuration**
```hcl
2022-04-27 21:15:39 +00:00
tls {
defaults {
verify_incoming = false
verify_outgoing = true
ca_file = "consul-agent-ca.pem"
verify_server_hostname = true
}
2022-03-18 10:46:58 +00:00
}
2022-04-27 21:15:39 +00:00
auto_encrypt {
tls = true
2022-03-18 10:46:58 +00:00
}
2020-11-04 22:05:44 +00:00
```
2023-01-25 16:52:43 +00:00
-> **Note**: The client agent TLS configuration from above sets [`verify_incoming`](/consul/docs/agent/config/config-files#tls_defaults_verify_incoming)
2022-03-18 10:46:58 +00:00
to false which assumes all incoming traffic is restricted to `localhost`. The primary benefit for this configuration
2020-12-08 23:24:36 +00:00
would be to avoid provisioning client TLS certificates (in addition to ACL tokens) for all tools or applications
2020-11-04 22:05:44 +00:00
using the local Consul agent. In this case ACLs should be enabled to provide authorization and only ACL tokens would
need to be distributed.
2020-12-08 23:24:36 +00:00
- **ACLs** - The access control list (ACL) system provides a security mechanism for Consul administrators to grant
capabilities tied to an individual human, or machine operator identity. To ultimately secure the ACL system,
2023-01-25 16:52:43 +00:00
administrators should configure the [`default_policy`](/consul/docs/agent/config/config-files#acl_default_policy) to "deny".
2020-11-05 21:30:00 +00:00
2023-01-25 16:52:43 +00:00
The [system](/consul/docs/security/acl) is comprised of five major components:
2020-11-04 22:05:44 +00:00
- **🗝 Token** - API key associated with policies, roles, or service identities.
- **📜 Policy** - Set of rules to grant or deny access to various Consul resources.
2020-12-08 23:24:36 +00:00
2020-11-04 22:05:44 +00:00
- **🎭 Role** - Grouping of policies, and service identities.
2020-12-08 23:24:36 +00:00
- **👤 Service or Node Identity** - Synthetic policy granting a predefined set of permissions typical for services
2020-11-04 22:05:44 +00:00
deployed within Consul.
2020-12-08 23:24:36 +00:00
- **🏷 Namespace** <EnterpriseAlert inline /> - a named, logical scoping of Consul Enterprise resources, typically to
2023-09-27 16:31:28 +00:00
enable multi-tenant environments. Consul CE clusters always operate within the "default" namespace.
2020-11-04 22:05:44 +00:00
2024-10-16 16:23:33 +00:00
- **Intentions** - Service intentions control traffic communication between services at the network layer (L4) and
application layer (L7). If in use, we strongly recommend configuring intentions to use a default-deny policy.
When L7 intentions are in use, review your configuration for [Mesh request normalization](/consul/docs/connect/config-entries/mesh#request-normalization)
and use the strictest set of options suitable to your environment. At minimum, we
recommend keeping path normalization enabled, because this default setting prevents requests that do not conform to [RFC 3986](
https://tools.ietf.org/html/rfc3986#section-6) from bypassing path match rules.
2020-12-08 23:24:36 +00:00
- **Gossip Encryption** - A shared, base64-encoded 32-byte symmetric key is required to [encrypt Serf gossip
2023-01-25 16:52:43 +00:00
communication](/consul/tutorials/security/gossip-encryption-secure?utm_source=consul.io&utm_medium=docs) within a cluster using
2020-12-08 23:24:36 +00:00
AES GCM. The key size determines which AES encryption types to use; 16, 24, or 32 bytes to select AES-128, AES-192,
or AES-256 respectively. 32-byte keys are ultimately preferable and is the default size generated by the
2023-01-25 16:52:43 +00:00
[`keygen`](/consul/commands/keygen) command. This key should be
2020-12-08 23:24:36 +00:00
[regularly rotated](https://support.hashicorp.com/hc/en-us/articles/360044051754-Consul-Gossip-Key-Rotation) using
2023-01-25 16:52:43 +00:00
the builtin [keyring management](/consul/commands/keyring) features of Consul.
2020-12-08 23:24:36 +00:00
Two optional gossip encryption options enable Consul servers without gossip encryption to safely upgrade. After
2020-11-04 22:05:44 +00:00
upgrading, the verification options should be enabled, or removed to set them to their default state:
2023-01-25 16:52:43 +00:00
- [`encrypt_verify_incoming`](/consul/docs/agent/config/config-files#encrypt_verify_incoming) - By default this is true to enforce
2020-12-08 23:24:36 +00:00
encryption on _incoming_ gossip communications.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`encrypt_verify_outgoing`](/consul/docs/agent/config/config-files#encrypt_verify_outgoing) - By default this is true to enforce
2020-12-08 23:24:36 +00:00
encryption on _outgoing_ gossip communications.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Namespaces** <EnterpriseAlert inline /> - Read and write operations should be scoped to logical namespaces to
restrict access to Consul components within a multi-tenant environment. Furthermore, this feature can be used to
2020-11-06 15:47:22 +00:00
enable a self-service approach to Consul ACL administration for teams within a scoped namespace.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Sentinel Policies** <EnterpriseAlert inline /> - Sentinel policies allow for granular control over the builtin
2020-11-04 22:05:44 +00:00
key-value store.
2022-08-26 05:49:29 +00:00
- **Ensure Script Checks are Disabled** - Consul's agent optionally has an HTTP API, which can be exposed beyond
2020-12-08 23:24:36 +00:00
`localhost`. If this is the case, `enable_script_checks` must be false otherwise, even with ACLs configured, script
checks present a remote code execution threat. `enable_local_script_checks` provides a secure alternative if the
HTTP API must be exposed and is available from 1.3.0 on. This feature was also back-ported to patch releases 0.9.4,
2020-11-04 22:05:44 +00:00
1.1.1, and 1.2.4 as described here. This is not enabled by default.
2020-12-08 23:24:36 +00:00
- **Ensure Remote Execution is Disabled** - Consul includes a consul exec feature allowing execution of arbitrary
commands across the cluster. This is disabled by default since 0.8.0. We recommend leaving it disabled. If enabled,
2020-11-04 22:05:44 +00:00
extreme care must be taken to ensure correct ACLs restrict access to execute arbitrary code on the cluster.
2024-05-28 16:54:38 +00:00
## Recommendations
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Rotate Credentials** - Using short-lived credentials and rotating them frequently is highly recommended for
2020-11-04 22:05:44 +00:00
production environments to limit the blast radius from potentially compromised secrets, and enabling basic auditing.
2022-01-20 16:54:23 +00:00
- **ACL Tokens** - Consul APIs require an ACL token to authorize actions within a cluster.
2020-11-04 22:05:44 +00:00
- **X.509 Certificates** - Rotate certificates used by the Consul agent; e.g. integrate with Vault's PKI secret engine
2020-12-08 23:24:36 +00:00
to automatically generate and renew dynamic, unique X.509 certificates for each Consul node with a short TTL. Client
certificates can be automatically rotated by Consul when using `auto_encrypt` such that only server certificates
2020-11-04 22:05:44 +00:00
would be managed by Vault.
2020-12-08 23:24:36 +00:00
- **Gossip Keys** - Rotating the encryption keys used by the internal gossip protocol for Consul agents can be
2020-11-04 22:05:44 +00:00
regularly rotated using the builtin keyring management features.
2020-12-08 23:24:36 +00:00
- **Running without Root** - Consul agents can be run as unprivileged users that only require access to the
2020-11-04 22:05:44 +00:00
data directory.
2020-12-08 23:24:36 +00:00
- **Linux Security Modules** - Use of security modules that can be directly integrated into operating systems such as
2020-11-04 22:05:44 +00:00
AppArmor, SElinux, and Seccomp on Consul agent hosts.
2023-01-25 16:52:43 +00:00
- **Customize TLS Settings** - TLS settings such as the [available cipher suites](/consul/docs/agent/config/config-files#tls_defaults_tls_cipher_suites),
2020-11-04 22:05:44 +00:00
should be tuned to fit the needs of your environment.
2023-01-25 16:52:43 +00:00
- [`tls_min_version`](/consul/docs/agent/config/config-files#tls_defaults_tls_min_version) - Used to specify the minimum TLS version to use.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`tls_cipher_suites`](/consul/docs/agent/config/config-files#tls_defaults_tls_cipher_suites) - Used to specify which TLS cipher suites are allowed.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Customize HTTP Response Headers** - Additional security headers, such as
[`X-XSS-Protection`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection), can be
2023-01-25 16:52:43 +00:00
[configured](/consul/docs/agent/config/config-files#response_headers) for HTTP API responses.
2020-11-04 22:05:44 +00:00
```hcl
http_config {
2021-06-16 20:13:32 +00:00
response_headers {
2020-11-04 22:05:44 +00:00
"X-Frame-Options" = "DENY"
}
}
```
2024-10-16 16:23:33 +00:00
- **Customize Mesh HTTP Request Normalization** - If L7 intentions are in use, we recommend configuring request normalization to
avoid match rule circumvention. Other normalization options, such as dropping or rejecting headers with underscores,
may also be appropriate depending on your requirements. Review the options in the [Mesh configuration entry](/consul/docs/connect/config-entries/mesh#request-normalization) to determine the appropriate settings for your use case.
2020-11-04 22:05:44 +00:00
- **Customize Default Limits** - Consul has a number of builtin features with default connection limits that should be
tuned to fit your environment.
2023-01-25 16:52:43 +00:00
- [`http_max_conns_per_client`](/consul/docs/agent/config/config-files#http_max_conns_per_client) - Used to limit concurrent access from
2020-11-04 22:05:44 +00:00
a single client to the HTTP(S) endpoint on Consul agents.
2023-01-25 16:52:43 +00:00
- [`https_handshake_timeout`](/consul/docs/agent/config/config-files#https_handshake_timeout) - Used to timeout TLS connection for the
2020-11-04 22:05:44 +00:00
HTTP(S) endpoint for Consul agents.
2023-01-25 16:52:43 +00:00
- [`rpc_handshake_timeout`](/consul/docs/agent/config/config-files#rpc_handshake_timeout) - Used to timeout TLS connections for the RPC
2020-12-08 23:24:36 +00:00
endpoint for Consul agents.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`rpc_max_conns_per_client`](/consul/docs/agent/config/config-files#rpc_max_conns_per_client) - Used to limit concurrent access from a
2020-11-04 22:05:44 +00:00
single client to the RPC endpoint on Consul agents.
2023-01-25 16:52:43 +00:00
- [`rpc_rate`](/consul/docs/agent/config/config-files#rpc_rate) - Disabled by default, this is used to limit (requests/second) for client
2020-11-04 22:05:44 +00:00
agents making RPC calls to server agents.
2023-01-25 16:52:43 +00:00
- [`rpc_max_burst`](/consul/docs/agent/config/config-files#rpc_max_burst) - Used as the token bucket size for client agents making RPC
2020-12-08 23:24:36 +00:00
calls to server agents.
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- [`kv_max_value_size`](/consul/docs/agent/config/config-files#kv_max_value_size) - Used to configure the max number of bytes in a
2020-11-04 22:05:44 +00:00
key-value API request.
2023-01-25 16:52:43 +00:00
- [`txn_max_req_len`](/consul/docs/agent/config/config-files#txn_max_req_len) - Used to configure the max number of bytes in a
2020-11-04 22:05:44 +00:00
transaction API request.
2022-08-26 05:49:29 +00:00
- **Secure UI Access** - Access to Consul's builtin UI can be secured in various ways:
2020-11-04 22:05:44 +00:00
- **mTLS** - Enabling the HTTPS with mutual TLS authentication is recommended, but requires extra tooling to terminate
2021-08-11 21:51:43 +00:00
the mTLS connection, preferably on an operator's local machine using a proxy script. To do this, follow the tutorial on
2023-01-25 16:52:43 +00:00
[Configuring the Consul UI for HTTPS](/consul/tutorials/security-operations/tls-encryption-openssl-secure#configure-the-consul-ui-for-https)
2021-08-11 21:51:43 +00:00
and in Step 2 use "Option 1: add a client certificate to your browser".
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **TLS** - Enabling the HTTPS is recommended where mTLS may not be required for UI access, such as when ACLs are
2021-08-11 21:51:43 +00:00
configured with a default deny. To do this, follow the tutorial on
2023-01-25 16:52:43 +00:00
[Configuring the Consul UI for HTTPS](/consul/tutorials/security-operations/tls-encryption-openssl-secure#configure-the-consul-ui-for-https)
2021-08-11 21:51:43 +00:00
and in Step 2 use "Option 2: verify_incoming_rpc".
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **ACL** - ACLs with a default deny policy enables safer UI access by preventing unauthorized access to sensitive
2021-08-11 21:51:43 +00:00
components within the cluster. To do this, follow the tutorial on
2023-01-25 16:52:43 +00:00
[Securing Consul with Access Control Lists (ACLs)](/consul/tutorials/security/access-control-setup-production),
which includes a section on [creating ACL tokens that provide a desired level UI access](/consul/tutorials/security/access-control-setup-production#consul-ui-token).
2020-11-04 22:05:44 +00:00
2023-01-25 16:52:43 +00:00
- **Restrict HTTP Writes** - Using the [`allow_write_http_from`](/consul/docs/agent/config/config-files#allow_write_http_from)
2021-08-11 21:51:43 +00:00
configuration option to restrict write access for agent endpoints to hosts on the specified list of CIDRs.
2020-11-04 22:05:44 +00:00
**Example Agent Configuration**
2020-12-08 23:24:36 +00:00
```hcl
http_config {
allow_write_http_from = ["127.0.0.0/8"]
}
```
2020-11-04 22:05:44 +00:00
2024-05-28 16:54:38 +00:00
## Threat Model
2020-11-04 22:05:44 +00:00
The following are parts of the core Consul threat model:
2020-12-08 23:24:36 +00:00
- **Consul agent-to-agent communication** - Communication between Consul agents should be secure from eavesdropping.
2020-11-04 22:05:44 +00:00
This requires transport encryption to be enabled on the cluster and covers both TCP and UDP traffic.
2020-12-08 23:24:36 +00:00
- **Consul agent-to-CA communication** - Communication between the Consul server and the configured certificate
2023-05-05 17:41:40 +00:00
authority provider for service mesh is always encrypted.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Tampering of data in transit** - Any tampering should be detectable and cause Consul to avoid processing
2020-11-04 22:05:44 +00:00
the request.
2020-12-08 23:24:36 +00:00
- **Access to data without authentication or authorization** - All requests must be authenticated and authorized. This
requires that ACLs are enabled on the cluster with a default deny mode.
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **State modification or corruption due to malicious messages** - Ill-formatted messages are discarded and
2020-11-04 22:05:44 +00:00
well-formatted messages require authentication and authorization.
2020-12-08 23:24:36 +00:00
- **Non-server members accessing raw data** - All servers must join the cluster (with proper authentication and
2020-11-04 22:05:44 +00:00
authorization) to begin participating in Raft. Raft data is transmitted over TLS.
2020-12-08 23:24:36 +00:00
- **Denial of Service against a node** - DoS attacks against a node should not compromise the security stance of
the software.
2020-11-04 22:05:44 +00:00
2023-05-05 17:41:40 +00:00
- **Communication between mesh services** - Communications between two mesh-enabled services (natively or
by sidecar proxy) should be secure from eavesdropping and provide authentication. This is achieved via mutual TLS.
2020-11-04 22:05:44 +00:00
The following are not part of the threat model for server agents:
- **Access (read or write) to the Consul data directory** - All Consul servers, including non-leaders, persist the full
2023-05-05 17:41:40 +00:00
set of Consul state to this directory. The data includes all KV, service registrations, ACL tokens, service mesh CA
2020-11-04 22:05:44 +00:00
configuration, and more. Any read or write to this directory allows an attacker to access and tamper with that data.
- **Access (read or write) to the Consul configuration directory** - Consul configuration can enable or disable the ACL
2020-12-08 23:24:36 +00:00
system, modify data directory paths, and more. Any read or write of this directory allows an attacker to reconfigure
2020-11-04 22:05:44 +00:00
many aspects of Consul. By disabling the ACL system, this may give an attacker access to all Consul data.
2020-12-08 23:24:36 +00:00
- **Memory access to a running Consul server agent** - If an attacker is able to inspect the memory state of a running
Consul server agent the confidentiality of almost all Consul data may be compromised. If you're using an external
2023-05-05 17:41:40 +00:00
service mesh CA, the root private key material is never available to the Consul process and can be considered safe. Service
service mesh TLS certificates should be considered compromised; they are never persisted by server agents but do exist
2020-11-04 22:05:44 +00:00
in-memory during at least the duration of a Sign request.
2020-12-08 23:24:36 +00:00
2020-11-05 21:41:15 +00:00
The following are not part of the threat model for client agents:
2020-12-08 23:24:36 +00:00
- **Access (read or write) to the Consul data directory** - Consul clients will use the data directory to cache local
2023-05-05 17:41:40 +00:00
state. This includes local services, associated ACL tokens, service mesh TLS certificates, and more. Read or write access
2020-11-05 21:41:15 +00:00
to this directory will allow an attacker to access this data. This data is typically a smaller subset of the full data
of the cluster.
2020-12-08 23:24:36 +00:00
- **Access (read or write) to the Consul configuration directory** - Consul client configuration files contain the
address and port information of services, default ACL tokens for the agent, and more. Access to Consul configuration
could enable an attacker to change the port of a service to a malicious port, register new services, and more.
Further, some service definitions have ACL tokens attached that could be used cluster-wide to impersonate that
2020-11-05 21:41:15 +00:00
service. An attacker cannot change cluster-wide configurations such as disabling the ACL system.
2020-12-08 23:24:36 +00:00
- **Memory access to a running Consul client agent** - The blast radius of this is much smaller than a server agent but
2020-11-05 21:41:15 +00:00
the confidentiality of a subset of data can still be compromised. Particularly, any data requested against the agent's
2023-05-05 17:41:40 +00:00
API including services, KV, and service mesh information may be compromised. If a particular set of data on the server was
2020-12-08 23:24:36 +00:00
never requested by the agent, it never enters the agent's memory since replication only exists between servers. An
attacker could also potentially extract ACL tokens used for service registration on this agent, since the tokens must
2020-11-05 21:41:15 +00:00
be stored in-memory alongside the registered service.
2023-05-05 17:41:40 +00:00
- **Network access to a local service mesh proxy or service** - Communications between a service and a mesh-aware proxy
2020-12-08 23:24:36 +00:00
are generally unencrypted and must happen over a trusted network. This is typically a loopback device. This requires
that other processes on the same machine are trusted, or more complex isolation mechanisms are used such as network
2023-05-05 17:41:40 +00:00
namespaces. This also requires that external processes cannot communicate to the mesh service or sidecar proxy (except on
the inbound port). Therefore, non-native service mesh applications should only bind to non-public addresses.
2020-11-05 21:41:15 +00:00
2023-05-05 17:41:40 +00:00
- **Improperly Implemented service mesh proxy or service** - A service mesh proxy or natively integrated service must correctly
2020-12-08 23:24:36 +00:00
serve a valid leaf certificate, verify the inbound TLS client certificate, and call the Consul agent-local authorized
endpoint. If any of this isn't performed correctly, the proxy or service may allow unauthenticated or unauthorized
2020-11-05 21:41:15 +00:00
connections.
2020-11-04 22:05:44 +00:00
2024-05-28 16:54:38 +00:00
## Internal Threats
2020-11-04 22:05:44 +00:00
2020-12-08 23:24:36 +00:00
- **Operator** - A malicious internal Consul operator with a valid mTLS certificate and ACL token may still be a threat
to your cluster in certain situations, especially in multi-team deployments. They may accidentally or intentionally
2020-11-04 22:05:44 +00:00
abuse access to Consul components which can help be protected against using Namespace, and Sentinel policies.
2021-06-16 20:13:32 +00:00
- **Application** - A malicious internal application, such as a compromised third-party dependency with access to a
2020-12-08 23:24:36 +00:00
Consul agent, along with the TLS certificate or ACL token used by the local agent, could effectively do anything the
token permits. Consider enabling HTTPS for the local Consul agent API, enforcing full mutual TLS verification,
2020-11-04 22:05:44 +00:00
segmenting services using namespaces, as well as configuring OS users, groups, and file permissions to build a defense-in-depth approach.
2020-12-08 23:24:36 +00:00
- **RPC** - Malicious actors with access to a Consul agent RPC endpoint may be able to impersonate Consul server agents
2020-11-04 22:05:44 +00:00
if mTLS is not properly configured to verify the client TLS certificate identity. Consul should also have ACLs enabled
with a default policy explicitly set to deny to require authorization.
2022-08-26 05:49:29 +00:00
- **HTTP** - Malicious actors with access to a Consul agent HTTP(S) endpoint may be able to impersonate the agent's
2020-11-04 22:05:44 +00:00
configured identity, and extract information from Consul when ACLs are disabled.
2020-12-08 23:24:36 +00:00
- **DNS** - Malicious actors with access to a Consul agent DNS endpoint may be able to extract service catalog
2022-03-23 15:46:56 +00:00
information.
- **Gossip** - Malicious actors with access to a Consul agent Serf gossip endpoint may be able to impersonate
2020-11-04 22:05:44 +00:00
agents within a datacenter. Gossip encryption should be enabled, with a regularly rotated gossip key.
2020-12-08 23:24:36 +00:00
- **Proxy (xDS)** - Malicious actors with access to a Consul agent xDS endpoint may be able to extract Envoy service
information. When ACLs and HTTPS are enabled, the gRPC endpoint serving up the xDS service requires (m)TLS and a
2020-11-04 22:05:44 +00:00
valid ACL token.
2024-05-28 16:54:38 +00:00
## External Threats
2020-11-04 22:05:44 +00:00
2022-08-26 05:49:29 +00:00
- **Agents** - External access to the Consul agent's various network endpoints should be considered including the
2020-12-08 23:24:36 +00:00
gossip, HTTP, RPC, and gRPC ports. Furthermore, access through other services like SSH or `exec` functionality in
orchestration systems such as Nomad and Kubernetes may expose unencrypted information persisted to disk including
2022-08-26 05:49:29 +00:00
TLS certificates or ACL tokens. Access to the Consul agent directory is explicitly outside the scope of Consul's
2020-11-04 22:05:44 +00:00
threat model and should only be exposed to authenticated and authorized users.
2023-01-25 16:52:43 +00:00
- **Gateways** - Consul supports a variety of [gateways](/consul/docs/connect/gateways) to allow traffic in-and-out of the
2020-12-08 23:24:36 +00:00
service mesh to support a variety of workloads. When using an internet-exposed gateway, you should be sure to harden
your Consul agent and host configurations. In most configurations, ACLS, gossip encryption, and mTLS should be
2023-01-25 16:52:43 +00:00
enforced. If an [escape hatch override](/consul/docs/connect/proxies/envoy#escape-hatch-overrides) is
2020-12-08 23:24:36 +00:00
required, the proxy configuration should be audited to ensure security configurations remain intact, and do not
2022-08-26 05:49:29 +00:00
violate Consul's security model.