---
layout: docs
page_title: Secure Consul
description: >-
  This topic provides an overview of all the Consul functionalities that contribute to increase its security. You can control access to Consul with access control lists (ACLs), encrypt its network traffic with gossip encryption/TLS, configure SSO or automatic configuration with an identity provider, or learn more about its security model.
---

# Secure Consul

Consul is not secure by default, but can be configured to satisfy the security requirements for a wide-range of use cases from local developer environments without any configuration, to container orchestrators in-production with ACL authorization, and mTLS authentication.

Requirements and recommendations for configuring and operating a secure Consul deployment may vary drastically depending on your intended workloads, operating system, and environment. This document provides an high level description of the Consul security model and features intended to harden your environment.

If you are looking for documentation on how to secure service-to-service communication within a service mesh using Consul, refer to [Connect workloads to Consul service mesh](/consul/docs/connect) and [Secure service mesh overview](/consul/docs/secure-mesh).

## Consul security model

[Security models overview](/consul/docs/secure/security-model) is a good starting point to understand what are the recommended configurations that help you increase Consul's security. The requirements highlighted in [Threat model](/consul/docs/secure/security-model/core#threat-model) offer guidance on sensitive areas of your Consul installation that need to be addressed.

The table below provides a simplified overview of different Consul operations and the Consul feature responsible of their security. 

| Use Case               | [Gossip encryption][gossip] | [TLS encryption][tls] | [ACLs][acl] |
| ---------------------- | :-------------------------: | :-------------------: | :---------: |
| Gossip communication   |   ✅                        |   🚫                  |   🚫         |
| Raft communication     |   🚫                        |   ✅                  |   🚫         |
| RPC communication      |   🚫                        |   ✅                  |   🚫         |
| K/V Operations         |   🚫                        |   ✅                  |   ✅         |
| API/CLI/UI Operations  |   🚫                        |   ✅                  |   ✅         |
| Catalog Access         |   🚫                        |   🚫                  |   ✅         |
| DNS service discovery  |   🚫                        |   🚫                  |   ✅         |
| Add datacenter nodes   |   ✅                        |   ✅                  |   ✅         |


[gossip]:/consul/docs/secure#gossip-encryption
[tls]:/consul/docs/secure#mtls-encryption
[acl]:/consul/docs/secure#access-control


## Traffic encryption

Consul allows to use encryption in all the network communications between the different agents and also for the Consul API, CLI, and UI interfaces.

Two distinct encryption systems are available to secure Consul, depending on the traffic they are encrypting, Gossip encryption and Mutual TLS (mTLS) encryption.

### Gossip encryption

Consul uses a [gossip protocol](/consul/docs/concept/gossip) to perform the following cluster operations:

- Identify datacenter members.
- Quickly detect failed members and notify the rest of the cluster.
- Broadcast events and queries that can trigger custom workflows.

The gossip protocol, as well as its membership management and message broadcasting features, use the [Serf library](https://github.com/hashicorp/serf/).

Enabling gossip encryption for your Consul datacenter secures all the traffic broadcasted by the agents to maintain cluster health state.

To learn more about enabling gossip encryption on your Consul datacenter and rotating gossip keys, refer to [manage gossip encryption](/consul/docs/secure/encryption/gossip/enable).

### mTLS encryption

Consul uses several communication protocols over different ports that you can secure using mTLS:

- A [consensus protocol](/consul/docs/concept/consensus) to provide data consistency between Consul servers.
- Remote Procedure Calls (RPC) forward requests from client agents to server agents.
- An HTTP or HTTPS interface to permit client communication with the Consul API, CLI, and UI.
- A gRPC interface to receive incoming traffic from the gateways and Envoy proxies registered to the agent node.

Consul uses mTLS to verify the authenticity of server and client agents. It requires that all clients and servers have key pairs that are generated by a single Certification Authority (CA). We recommend using a private CA that is not shared with other applications.

To learn more about enabling mTLS on your Consul datacenter, refer to [Manage mTLS encryption](/consul/docs/secure/encryption/tls/mtls).

## Access control

Consul implements an Access Control List system (ACL) to authenticate requests and authorize access to resources. ACL also control access to the Consul UI, API, and CLI, as well as secure service-to-service and agent-to-agent communication.

To learn more about the ACL system refer to the [Access control list (ACL)](/consul/docs/secure/acl) documentation.

## Additional security best practices

Enabling script checks via the [`enable_script_checks`](/consul/docs/reference/agent/configuration-file/general#_enable_script_checks) configuration setting may introduce a remote execution vulnerability that is known to be targeted by malware. We strongly recommend using [`enable_local_script_checks`](/consul/docs/reference/agent/configuration-file/general#_enable_local_script_checks) instead. See [this blog post](https://www.hashicorp.com/blog/protecting-consul-from-rce-risk-in-specific-configurations) for more details.

Configure client agents to bind to `localhost` for the HTTP, HTTPS, DNS, and gRPC APIs. This ensures these APIs are not exposed outside the node where the client agent is running. Consul client agents bind to localhost by default if the [`addresses`](/consul/docs/reference/agent/configuration-file/general#addresses) and [`client_addr`](/consul/docs/reference/agent/configuration-file/general#client_addr) config options are not specified.

Verify that the version of Consul deployed within the environment does not have any active CVEs that are relevant by visiting the following page:
[Hashicorp Discuss: Consul Security](https://discuss.hashicorp.com/tag/security-consul)

Leverage Consul [intentions](/consul/docs/secure-mesh/intention)
within a service mesh for defining rules which allow service-to-service
communication.

## Other resources

### Automate security configuration with `auto_config`

Configuring traffic encryption, both for gossip and mTLS, and creating agent ACL tokens involves many operations that needs to be manually executed by an operator. You can automate those operation by using [`auto_config`](/consul/docs/reference/agent/configuration-file/auto-config). Read more on this at [Consul auto-config on Docker](/consul/docs/secure/auto-config/docker). 

### Implement Single Sign On (SSO)

Instead of creating user tokens, you can use an OIDC provider to implement Single Sign On (SSO) on Consul. This simplifies the integration of Consul in your network and avoids the creation of ad-hoc credentials for every new user. Read more on this at [Enable Auth0 single sign-on (SSO)](/consul/docs/secure/sso/auth0).

### Monitor API request with audit logging <EnterpriseAlert inline /> 

Consul Enterprise offers advanced monitoring for its HTTP API endpoints. Using audit logs it is possible to capture a clear and actionable log of authenticated requests performed against Consul API. Read more on this at [audit logging](/consul/docs/monitor/log/audit).

### Separate resources and delegate permissions with namespaces <EnterpriseAlert inline /> 

Namespaces provide separation for teams within a single organization enabling them to share access to one or more Consul datacenters without conflict. Additionally, namespaces with ACLs allows you to delegate access control to specific resources within the datacenter including services, Connect service mesh proxies, key/value pairs, and sessions.
Read more on this in the [namespaces](/consul/docs/multi-tenant/namespace) documentation.
