EC2 instances with security groups permitting any source to TCP 1433 or 1434 (SQL Server) are identified, considering the instance's public reachability based on IP and subnet exposure.
Risk
Internet-reachable SQL services enable:
- Brute-force and credential-stuffing of DB logins
- Exploitation of SQL Server flaws for remote code execution
- Unauthorized queries and data exfiltration This threatens confidentiality and integrity, and facilitates lateral movement from the database host.
Run this check with Prowler CLI
prowler aws --checks ec2_instance_port_sqlserver_exposed_to_internet
Fix finding with Prowler CLI
prowler aws --checks ec2_instance_port_sqlserver_exposed_to_internet --fixer
Recommendation
Enforce least privilege and defense in depth:
- Remove
0.0.0.0/0and::/0to1433-1434 - Allow only trusted IPs or app tiers via security group references
- Keep databases in private subnets without public IPs; access via VPN or bastion
- Require TLS and strong authentication; monitor access.
Remediation
CLI
aws ec2 revoke-security-group-ingress --group-id <SECURITY_GROUP_ID> --ip-permissions '[{"IpProtocol":"tcp","FromPort":1433,"ToPort":1434,"IpRanges":[{"CidrIp":"0.0.0.0/0"}],"Ipv6Ranges":[{"CidrIpv6":"::/0"}]}]'
Native IaC
Terraform
Other
- In the AWS Console, go to VPC > Security Groups
- Select the security group attached to the affected EC2 instance
- In the Inbound rules tab, click Edit inbound rules
- Delete any rule allowing TCP 1433 or 1434 from 0.0.0.0/0 or ::/0
- If access is required, add a rule for TCP 1433-1434 with a specific trusted source (e.g., your office IP or another security group)
- Click Save rules
Source Code
Resource Type
AwsEc2Instance
References
- https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html
- https://support.icompaas.com/support/solutions/articles/62000223371-ensure-no-security-groups-allow-ingress-from-0-0-0-0-0-or-0-to-windows-sql-server-ports-1433-or-14
- https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/aws/EC2/unrestricted-mssql-access.html