Publicly accessible AWS MSK broker

Verify the need for public Kafka connectivity and restrict client access.

Description

public_access.type = "SERVICE_PROVIDED_EIPS" requests public broker endpoints on an existing MSK cluster. Network access, authentication and Kafka permissions determine who can use them.

Potential impact

Public broker ports accept connection attempts from permitted sources. Compromised or overprivileged clients may read or alter stream data or disrupt processing.

Remediation

  • For private clients, prepare the network path and private bootstrap broker addresses before switching to DISABLED. The setting creates no private client routes.
  • If public access is needed, confirm that inter-broker encryption was enabled when the cluster was created. Restrict broker ports to approved sources and configure supported authentication, Kafka permissions and client-to-broker TLS.
  • After applying the change, test authorized producers and consumers and confirm that other sources are blocked.

Examples

MSK accepts the public option only after cluster creation. The excerpts omit the broker type, subnets and security settings. Supply those and a supported var.kafka_version. Public subnets need a route to an internet gateway.

Before

hcl
resource "aws_msk_cluster" "msk_cluster" {
  cluster_name           = "example"
  kafka_version          = var.kafka_version
  number_of_broker_nodes = 3

  broker_node_group_info {
    connectivity_info {
      public_access {
        type = "SERVICE_PROVIDED_EIPS"
      }
    }
  }
}

SERVICE_PROVIDED_EIPS requests public connectivity for the three brokers.

After

hcl
resource "aws_msk_cluster" "msk_cluster" {
  cluster_name           = "example"
  kafka_version          = var.kafka_version
  number_of_broker_nodes = 3

  broker_node_group_info {
    connectivity_info {
      public_access {
        type = "DISABLED"
      }
    }
  }
}

DISABLED removes public access. Clients use their private bootstrap addresses.

References