Insufficient restrictions on EKS node group remote access

Restrict EKS node management ports to the security groups used by approved management hosts.

Description

When you create an EKS managed node group with only RemoteAccess.Ec2SshKey, Linux SSH port 22 or Windows RDP port 3389 is open to all IPv4 addresses.

Potential impact

Any host with a network path to the node can attempt to connect to its management port. Retain operating system authentication and limit node privileges.

Remediation

For direct access, set SourceSecurityGroups to the groups used by approved management hosts. Omit RemoteAccess when it is unnecessary. For Session Manager, prepare its agent, IAM permissions and network path first. Changing remote access replaces an existing node group, so provide capacity and an access path during workload migration.

Examples

Supply the cluster, node role, subnets and VpcId. Replace ED25519 with the name of the existing EC2 key pair you intend to use.

Before

yaml
Resources:
  EKSNodegroup:
    Type: AWS::EKS::Nodegroup
    Properties:
      ClusterName: prod
      NodeRole: arn:aws:iam::012345678910:role/eksInstanceRole
      Subnets:
        - subnet-6782e71e
      RemoteAccess:
        Ec2SshKey: ED25519

After

yaml
Resources:
  SSHAccessToNodeSG:
    Type: AWS::EC2::SecurityGroup
    Properties:
      VpcId: !Ref VpcId
      GroupDescription: ssh access to eks workers

  EKSNodegroup:
    Type: AWS::EKS::Nodegroup
    Properties:
      ClusterName: prod
      NodeRole: arn:aws:iam::012345678910:role/eksInstanceRole
      Subnets:
        - subnet-6782e71e
      RemoteAccess:
        Ec2SshKey: ED25519
        SourceSecurityGroups:
          - !Ref SSHAccessToNodeSG

The second excerpt creates the source group. Attach the approved management hosts to it and verify that they can connect to the nodes.

References