Back to Checks
EC2 instance does not allow ingress from the Internet to TCP ports 1521, 2483, or 2484 (Oracle)
ec2_instance_port_oracle_exposed_to_internet
Service: ec2Severity: critical
OfficialBuilt-inVerified
Categories:internet-exposed
Resource Type:AwsEc2Instance
EC2 instances with security groups allowing inbound TCP from any address to Oracle listener ports 1521, 2483, or 2484
Risk
Exposed Oracle listener ports enable SID enumeration, credential brute force, and TNS abuse. A successful intrusion can grant database access, causing data exfiltration (C), unauthorized changes (I), and outages via exploits or DoS (A). Internet scanning quickly finds these endpoints, enlarging the attack surface.
Run this check with Prowler
Run in Prowler CloudRun
prowler aws --checks ec2_instance_port_oracle_exposed_to_internetRecommendation
Restrict Oracle ports to trusted sources; remove 0.0.0.0/0 and ::/0. Place databases in private subnets without public IPs. Use VPN/Direct Connect or bastions for access. Enable TLS on 2484, strong auth, and apply least privilege rules with defense in depth using NACLs and monitoring.
Remediation
CLI
aws ec2 revoke-security-group-ingress --group-id <SECURITY_GROUP_ID> --protocol tcp --port 1521 --cidr 0.0.0.0/0Terraform
# Security group with Oracle port restricted from Internet
resource "aws_security_group" "<example_resource_name>" {
vpc_id = "<example_resource_id>"
ingress {
from_port = 1521
to_port = 1521
protocol = "tcp"
cidr_blocks = ["10.0.0.0/16"] # FIX: restrict source; do not use 0.0.0.0/0 or ::/0
}
}NativeIaC
# CloudFormation: Restrict Oracle port from Internet
Resources:
<example_resource_name>:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Restrict Oracle port access
VpcId: <example_resource_id>
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 1521
ToPort: 1521
CidrIp: 10.0.0.0/16 # FIX: do not use 0.0.0.0/0 or ::/0; limits access to a trusted CIDR to block InternetOther
1In the AWS Console, go to EC2 > Security Groups
2Select the security group attached to the instance
3Open the Inbound rules tab and click Edit inbound rules
4For TCP ports 1521, 2483, and 2484, delete any rule with Source 0.0.0.0/0 or ::/0
5If access is required, change the Source to a specific trusted CIDR only
6Click Save rules
Check Code
from prowler.lib.check.models import Check, Check_Report_AWS
from prowler.providers.aws.services.ec2.ec2_client import ec2_client
from prowler.providers.aws.services.ec2.lib.instance import get_instance_public_status
from prowler.providers.aws.services.ec2.lib.security_groups import check_security_group
from prowler.providers.aws.services.vpc.vpc_client import vpc_client
class ec2_instance_port_oracle_exposed_to_internet(Check):
# EC2 Instances with Oracle ports 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.
def execute(self):
findings = []
check_ports = [1521, 2483, 2484]
for instance in ec2_client.instances:
report = Check_Report_AWS(metadata=self.metadata(), resource=instance)
report.status = "PASS"
report.status_extended = f"Instance {instance.id} does not have Oracle ports open to the Internet."
is_open_port = False
if instance.security_groups:
for sg in ec2_client.security_groups.values():
if sg.id in instance.security_groups:
for ingress_rule in sg.ingress_rules:
if check_security_group(
ingress_rule, "tcp", check_ports, any_address=True
):
# The port is open, now check if the instance is in a public subnet with a public IP
report.status = "FAIL"
(
report.status_extended,
report.check_metadata.Severity,
) = get_instance_public_status(
vpc_client.vpc_subnets, instance, "Oracle"
)
is_open_port = True
break
if is_open_port:
break
findings.append(report)
return findings