RDS PubliclyAccessible: The Flag That Bypasses Your VPC
Overview
With PubliclyAccessible set to true, an RDS instance's endpoint resolves to a public address, but nothing reaches it until a security group allows it. The exposure stays dormant until an unrelated rule opens the database port to 0.0.0.0/0.
At a glance
- Symptom
- An unrelated security group edit adds an internet-wide ingress rule while the public endpoint already exists
- Likely cause
- PubliclyAccessible=true combined with a security group later allowing 0.0.0.0/0 on the database port
- Impact
- Internet-wide scanners can find the open port, enabling brute force, exploitation of unpatched engine flaws, and credential reuse across environments.
- Verification signal
- Re-run the detection test and a controlled negative-path test.
- Safe correction
- Disable PubliclyAccessible, detect with the AWS Config rule rds-instance-public-access-check (remediation on manual approval first), and block with an SCP only if a documented condition key exists, otherwise a…
- Rollback or recovery
- Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
The Trap
The PubliclyAccessible attribute on an Amazon RDS instance, left set to true and paired with a security group that later gains an inbound rule for 0.0.0.0/0 on the database port.
The Default State
The CreateDBInstance API defaults PubliclyAccessible to true for non-Aurora instances created without a DB subnet group or with the default one, and the console’s Public access choice is easily set to Yes. Terraform modules copied from public examples sometimes ship with publicly_accessible = true as the sample value, and templates written for a migration may set it explicitly during a cutover, then never revert it. Separately, engineers create a dedicated security group during a migration and add an ingress rule for 0.0.0.0/0 on port 5432 or 3306 so an external ETL box or a Lambda outside the VPC can reach the instance during the initial load. Neither setting alone is fatal. Together, they are dangerous. With PubliclyAccessible true, the instance’s DNS endpoint resolves to a public IP address from outside the VPC and to the private address from inside it. The flag does not bypass the VPC: security groups, network ACLs and a DB subnet route to an internet gateway still decide whether any traffic arrives. What it does is leave the security group as the only thing standing between the listener and the internet.
The Blast Radius
The endpoint resolves publicly from day one, sitting inert until someone modifies the security group for an unrelated reason: a new integration, a firewall exception ticket, a copy-pasted Terraform block. The instant a 0.0.0.0/0 rule lands on the database port, the previously dormant public endpoint becomes reachable from the entire internet, not just the intended new client. Internet-exposed database ports are routinely found by scanning services such as Shodan and by anyone running tools such as masscan. Once found, the listener is open to brute-force attempts against the master username, exploitation of any unpatched engine vulnerabilities, and credential stuffing against database user passwords. Where the same credentials are reused across environments, one exposed instance can also yield access to staging and production.
The Lead Mechanic Fix
Find which clients still reach the instance from outside the VPC and move them to private connectivity first, because they lose access once the change takes effect. In a scheduled change window, disable the flag: aws rds modify-db-instance --db-instance-identifier <id> --no-publicly-accessible --apply-immediately. Confirm with aws rds describe-db-instances --db-instance-identifier <id> --query 'DBInstances[0].PubliclyAccessible' that it now reports false, and check from outside the VPC that the endpoint no longer resolves to a public address. Enforce this at the control-plane level with an AWS Config managed rule, rds-instance-public-access-check, with remediation on manual approval at first, excluding instances that must stay public, and tested in a non-production account before any automatic remediation. Only build an SCP for this if the RDS page of the Service Authorization Reference documents a condition key for the setting, and test it in a sandbox OU; otherwise use a proactive control such as a CloudFormation Hook. Where possible, inbound rules should reference a dedicated application-tier security group ID rather than a CIDR block (not a shared group, whose every member would gain access); for traffic arriving over VPN, Direct Connect or peering, use the narrowest CIDR for that range. Any external-integration requirement should route through VPN, Direct Connect, VPC peering or a bastion with Session Manager port forwarding instead of a public listener.
Related reading
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
aws rds modify-db-instance --db-instance-identifier <id> --no-publicly-accessible --apply-immediatelyaws rds describe-db-instances --db-instance-identifier <id> --query 'DBInstances[0].PubliclyAccessible'rds-instance-public-access-checkVerify, roll back or escalate
Verify
Re-run the detection test and a controlled negative-path test. Confirm the unsafe behaviour is blocked while approved traffic still succeeds.
Rollback
Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Last updated
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

