Amazon MSK brokers have public access enabled

Review the need for public Amazon MSK broker connections, and use private connectivity for internal-only clients.

Description

On an existing MSK Provisioned cluster, PublicAccess.Type: SERVICE_PROVIDED_EIPS requests public broker endpoints. Connecting still requires a permitted network path, authentication and Kafka permissions.

Potential impact

Unnecessary access to broker ports invites unwanted connections. A client with excessive permissions can read or alter event data or interrupt processing.

Remediation

  • Before setting PublicAccess.Type: DISABLED, connect each client through the private network using its private bootstrap broker addresses.
  • If public access is required, use a supported cluster version and public subnets routed to an internet gateway. Restrict broker ports to approved sources. Keep authentication, client-to-broker TLS and inter-broker encryption enabled.
  • After the update completes, test authorized producers and consumers and confirm that unapproved sources cannot connect.

Examples

The public configuration can only be applied after cluster creation. For an existing stack, match the cluster name and properties. Supply a supported Kafka version and broker type, security groups and three subnets in different Availability Zones of one VPC in a supported Region.

Before

yaml
Parameters:
  KafkaVersion:
    Type: String
  BrokerInstanceType:
    Type: String
  ClientSubnetIds:
    Type: List<AWS::EC2::Subnet::Id>
  SecurityGroupIds:
    Type: List<AWS::EC2::SecurityGroup::Id>
Resources:
  TestCluster:
    Type: AWS::MSK::Cluster
    Properties:
      ClusterName: ClusterWithRequiredProperties
      KafkaVersion: !Ref KafkaVersion
      NumberOfBrokerNodes: 3
      ClientAuthentication:
        Sasl:
          Iam:
            Enabled: true
        Unauthenticated:
          Enabled: false
      EncryptionInfo:
        EncryptionInTransit:
          ClientBroker: TLS
          InCluster: true
      BrokerNodeGroupInfo:
        InstanceType: !Ref BrokerInstanceType
        ClientSubnets: !Ref ClientSubnetIds
        SecurityGroups: !Ref SecurityGroupIds
        ConnectivityInfo:
          PublicAccess:
            Type: SERVICE_PROVIDED_EIPS

SERVICE_PROVIDED_EIPS requests public access. The template requires IAM authentication and TLS. Grant clients the IAM permissions they need separately.

After

yaml
Parameters:
  KafkaVersion:
    Type: String
  BrokerInstanceType:
    Type: String
  ClientSubnetIds:
    Type: List<AWS::EC2::Subnet::Id>
  SecurityGroupIds:
    Type: List<AWS::EC2::SecurityGroup::Id>
Resources:
  TestCluster:
    Type: AWS::MSK::Cluster
    Properties:
      ClusterName: ClusterWithRequiredProperties
      KafkaVersion: !Ref KafkaVersion
      NumberOfBrokerNodes: 3
      ClientAuthentication:
        Sasl:
          Iam:
            Enabled: true
        Unauthenticated:
          Enabled: false
      EncryptionInfo:
        EncryptionInTransit:
          ClientBroker: TLS
          InCluster: true
      BrokerNodeGroupInfo:
        InstanceType: !Ref BrokerInstanceType
        ClientSubnets: !Ref ClientSubnetIds
        SecurityGroups: !Ref SecurityGroupIds
        ConnectivityInfo:
          PublicAccess:
            Type: DISABLED

DISABLED removes the public endpoints. Clients use the private IAM bootstrap addresses with the same authentication and encryption settings.

References