The from_port_is_ssh and to_port_is_ssh rules incorrectly fail if a security group uses a reference to a template parameter for the port numbers, even when the parameter has a default value that's not 22.
Minimum example template:
AWSTemplateFormatVersion: "2010-09-09"
Transform:
- AWS::Serverless-2016-10-31
Parameters:
ContainerPort:
Description: The port on which the container is running
Type: Number
Default: 6001
SourceSecurityGroupId:
Type: String
Default: abc123
Resources:
ContainerServiceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: !Sub "Security Group to access the Container Service"
GroupName: !Join
- "-"
- - !Ref AWS::StackName
- ContainerService
SecurityGroupIngress:
- Description: !Sub "Allow traffic from the load balancer on port ${ContainerPort}"
SourceSecurityGroupId: !Ref SourceSecurityGroupId
IpProtocol: tcp
FromPort: !Ref ContainerPort
ToPort: !Ref ContainerPort
Sustainability scanner output:
{
"title": "Sustainability Scanner Report",
"file": "test-template.yaml",
"version": "1.2.4",
"sustainability_score": 4,
"failed_rules": [
{
"rule_name": "from_port_is_ssh",
"severity": "MEDIUM",
"message": "Consider using AWS Systems Manager to access your Amazon EC2 instances instead of direct access or bastion host.",
"links": [
"https://docs.aws.amazon.com/wellarchitected/latest/sustainability-pillar/sus_sus_dev_a4.html"
],
"resources": [
{
"name": "/Resources/ContainerServiceSecurityGroup/Properties/SecurityGroupIngress/0/FromPort",
"line": "27"
}
]
},
{
"rule_name": "to_port_is_ssh",
"severity": "MEDIUM",
"message": "Consider using AWS Systems Manager to access your Amazon EC2 instances instead of direct access or bastion host.",
"links": [
"https://docs.aws.amazon.com/wellarchitected/latest/sustainability-pillar/sus_sus_dev_a4.html"
],
"resources": [
{
"name": "/Resources/ContainerServiceSecurityGroup/Properties/SecurityGroupIngress/0/ToPort",
"line": "28"
}
]
}
]
}
I'm on version 1.2.4 of susscanner and 3.0.3 of cfn-guard.
The
from_port_is_ssh
andto_port_is_ssh
rules incorrectly fail if a security group uses a reference to a template parameter for the port numbers, even when the parameter has a default value that's not 22.Minimum example template:
Sustainability scanner output:
I'm on version 1.2.4 of susscanner and 3.0.3 of cfn-guard.