Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ec2): add checks for EC2 instances with exposed ports to the internet #4029

Merged
merged 28 commits into from
May 28, 2024

Conversation

sergargar
Copy link
Member

@sergargar sergargar commented May 20, 2024

Description

Add checks ec2_instance_port_X_exposed_to_internet to check if there are EC2 Instances exposed to the internet through the specific port.

EC2 Instances with exposed port open to the Internet will be flagged as FAIL with a severity of medium if the instance has no public IP, high if the instance has a public IP but is in a private subnet, and critical if the instance has a public IP and is in a public subnet.

  • ec2_instance_port_mongodb_exposed_to_internet
  • ec2_instance_port_ftp_exposed_to_internet
  • ec2_instance_port_ssh_exposed_to_internet
  • ec2_instance_port_rdp_exposed_to_internet
  • ec2_instance_port_cassandra_exposed_to_internet
  • ec2_instance_port_elasticsearch_kibana_exposed_to_internet
  • ec2_instance_port_kafka_exposed_to_internet
  • ec2_instance_port_memcached_exposed_to_internet
  • ec2_instance_port_mysql_exposed_to_internet
  • ec2_instance_port_oracle_exposed_to_internet
  • ec2_instance_port_postgres_exposed_to_internet
  • ec2_instance_port_redis_exposed_to_internet
  • ec2_instance_port_sql_server_exposed_to_internet
  • ec2_instance_port_telnet_exposed_to_internet
  • ec2_instance_port_kerberos_exposed_to_internet
  • ec2_instance_port_ldap_exposed_to_internet
  • ec2_instance_port_cifs_exposed_to_internet

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label May 20, 2024
Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.62%. Comparing base (374567a) to head (131b44c).
Report is 33 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4029      +/-   ##
==========================================
+ Coverage   86.37%   86.62%   +0.25%     
==========================================
  Files         789      812      +23     
  Lines       24706    25396     +690     
==========================================
+ Hits        21340    22000     +660     
- Misses       3366     3396      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sergargar sergargar marked this pull request as ready for review May 21, 2024 18:01
@sergargar sergargar requested review from a team as code owners May 21, 2024 18:01
@sergargar sergargar changed the title feat(ec2): add ec2_instance_ssh_port_exposed_to_internet check feat(ec2): add ec2_instance_port_ssh_exposed_to_internet check May 21, 2024
@sergargar sergargar changed the title feat(ec2): add ec2_instance_port_ssh_exposed_to_internet check feat(ec2): add checks for EC2 instances with exposed ports to the internet May 21, 2024
Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

@sergargar sergargar requested a review from jfagoagas May 24, 2024 11:37
) = get_instance_public_status(
vpc_client.vpc_subnets, instance, "Cassandra"
)
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This break only aborts the for ingress_rule in sg.ingress_rules: loop, is that on purpose or do we need to add more checks to exit the outer loops?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment applies to all the checks within this PR.

prowler/providers/aws/services/ec2/ec2_service.py Outdated Show resolved Hide resolved
prowler/providers/aws/services/ec2/ec2_service.py Outdated Show resolved Hide resolved
prowler/providers/aws/services/ec2/lib/instance.py Outdated Show resolved Hide resolved
prowler/providers/aws/services/ec2/lib/instance.py Outdated Show resolved Hide resolved
prowler/providers/aws/services/ec2/lib/instance.py Outdated Show resolved Hide resolved
prowler/providers/aws/services/ec2/lib/instance.py Outdated Show resolved Hide resolved
Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

@sergargar sergargar requested a review from jfagoagas May 28, 2024 13:56
) = get_instance_public_status(
vpc_client.vpc_subnets, instance, "Cassandra"
)
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the comment about the loop break.

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

@sergargar sergargar requested a review from jfagoagas May 28, 2024 15:11
Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Member

@jfagoagas jfagoagas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergargar sergargar merged commit f4a1130 into master May 28, 2024
12 checks passed
@sergargar sergargar deleted the new-ec2-instance-checks branch May 28, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants