Back to Checks
iac

A security group rule allows ingress traffic from multiple public addresses

OPNSTK-0003
Service: networkingSeverity: medium
OfficialBuilt-inVerified

Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler iac --checks OPNSTK-0003

Recommendation

Employ more restrictive security group rules

Check Code

# METADATA
# title: A security group rule allows ingress traffic from multiple public addresses
# description: |
#   Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.
# scope: package
# schemas:
#   - input: schema["cloud"]
# custom:
#   id: OPNSTK-0003
#   long_id: openstack-networking-no-public-ingress
#   aliases:
#     - AVD-OPNSTK-0003
#     - no-public-ingress
#     - openstack-networking-no-public-ingress
#   provider: openstack
#   service: networking
#   severity: MEDIUM
#   recommended_action: Employ more restrictive security group rules
#   input:
#     selector:
#       - type: cloud
#         subtypes:
#           - service: networking
#             provider: openstack
#   examples: checks/cloud/openstack/networking/no_public_ingress.yaml
package builtin.openstack.networking.openstack0003

import rego.v1

deny contains res if {
	some sg in input.openstack.networking.securitygroups
	some rule in sg.rules
	rule.isingress.value == true
	cidr.is_public(rule.cidr.value)
	cidr.count_addresses(rule.cidr.value) > 1
	res := result.new("Security group rule allows ingress to multiple public addresses.", rule.cidr)
}