This rule ensures that the Security Group attached to the ALB instance restricts TCP 27018 inbound traffic
Rule | Ensure Security Group attached to application load balancer instance does not allow inbound traffic from all to TCP 27018 (MongoDB) |
Framework | CloudDefense.AI Security |
Severity | ✔ High |
Rule Description:
The security group attached to the application load balancer instance should have restricted inbound traffic access to TCP port 27018, which is commonly used for MongoDB. This rule helps ensure the security of the CloudDefense application by preventing unauthorized access to the MongoDB server.
Troubleshooting Steps (if any):
Remediation:
To remediate the issue, follow these steps:
aws elbv2 describe-load-balancers --query 'LoadBalancers[?LoadBalancerName==`<load_balancer_name>`].LoadBalancerArn'
Replace
<load_balancer_name>
with the name of your load balancer.aws elbv2 describe-load-balancers --load-balancer-arns <load_balancer_arn> --query 'LoadBalancers[0].SecurityGroups'
Replace
<load_balancer_arn>
with the ARN obtained in the previous step.Take note of the security group ID for further use in the following steps.
Now, verify the inbound rules of the security group associated with the load balancer. Use the following command:
aws ec2 describe-security-groups --group-ids <security_group_id>
Replace
<security_group_id>
with the security group ID obtained earlier.Identify any inbound rules that allow traffic from all sources to TCP port 27018. Note down the rule description or ID for removal.
To remove the identified rule, use the following command:
aws ec2 revoke-security-group-ingress --group-id <security_group_id> --protocol tcp --port 27018 --source 0.0.0.0/0
Replace
<security_group_id>
with the security group ID and confirm that the source is set to 0.0.0.0/0
to revoke access from all sources.aws ec2 describe-security-groups --group-ids <security_group_id>
Ensure that there is no longer an inbound rule allowing traffic from all sources to TCP port 27018.
Note:
Make sure to review all the security group rules and consider adding more restrictive rules to enhance the security of your CloudDefense application.