A security group allows `0.0.0.0/0` on port 22. How do you fix it properly?
BeginnerScenarioContainer and IaC Security
Answer
Situation read → Internet-exposed SSH is scanned and brute-forced constantly.
What I'd do →
- Remove the rule:
aws ec2 revoke-security-group-ingress --group-id sg-... --protocol tcp --port 22 --cidr 0.0.0.0/0. - Replace admin access with AWS Systems Manager Session Manager (no inbound port, IAM-authenticated, logged).
- If SSH is unavoidable, restrict to a bastion or VPN CIDR.
- Add a Config rule
restricted-sshand a Checkov check to prevent regressions.
Why → No open port means nothing to scan.
Interview tip → Session Manager is the answer most interviewers want.
More on Container and IaC Security
A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?Beginner`trivy image` shows 300 vulnerabilities in your app image. How do you bring this down?BeginnerA Dockerfile runs the app as root. How do you fix it and prove the fix?IntermediateCheckov fails a Terraform PR because an S3 bucket allows public access. What do you change?BeginnerHow do you set up image scanning so nothing vulnerable reaches production?IntermediateAn image passed scanning three weeks ago and runs in production. A new critical CVE is published today. What happens next?Intermediate