RDS PubliclyAccessible Changes Are Asynchronous: Verify Before Closing the Ticket
Overview
Setting -no-publicly-accessible on an RDS instance applies immediately whether or not -apply-immediately is passed, but the change is asynchronous and leaves the security group untouched. Verify the endpoint is no longer reachable before closing the ticket.
At a glance
- Symptom
- An audit remediation ticket is closed based on a successful API call while the instance remains publicly reachable until the next maintenance window.
- Likely cause
- modify-db-instance --no-publicly-accessible is run without --apply-immediately, so the change sits in PendingModifiedValues instead of taking effect.
- Impact
- The database stays reachable on 0.0.0.0/0 over 3306/5432 for days while dashboards and tickets report the exposure as resolved.
- Verification signal
- Re-run the detection test and a controlled negative-path test.
- Safe correction
- Pair PubliclyAccessible changes with --apply-immediately, verify PendingModifiedValues is empty, and enforce closure via AWS Config auto-remediation.
- Rollback or recovery
- Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
The Trap
Deferred PubliclyAccessible remediation. A database is exposed with PubliclyAccessible: true and a security group ingress rule of 0.0.0.0/0 on port 3306 (MySQL/Aurora) or 5432 (PostgreSQL). An engineer spots this in an audit and runs aws rds modify-db-instance --no-publicly-accessible, closes the ticket, and moves on without checking what actually changed or touching the security group.
The Default State
The AWS CLI’s modify-db-instance command defaults --apply-immediately to false unless explicitly overridden, and the console pre-selects “Apply during the next scheduled maintenance window”, so engineers expect the fix to be deferred. It is not: the RDS API reference states that changes to PubliclyAccessible are applied immediately regardless of ApplyImmediately. What does wait is anything else submitted in the same call, such as an instance class change, which sits in PendingModifiedValues until the window. The public-access change is still asynchronous: the instance moves to modifying, and the endpoint resolves to its private address once it completes.
The Blast Radius
describe-db-instances can keep returning PubliclyAccessible: true while the modification is in progress, and the ticket is often closed before it completes. The security group’s 0.0.0.0/0 rule on 3306/5432 is untouched by this modify call entirely, since it’s a separate EC2 resource, so the endpoint becomes internet-reachable again the moment PubliclyAccessible is re-enabled, for example by a template or script that still sets it. Mass scanners on Shodan and routine masscan sweeps enumerate the open port and attempt master-user credential brute force whenever such a gap opens, with no alerting difference between “fix requested” and “fix applied”.
The Lead Mechanic Fix
Pass --apply-immediately anyway, so nothing bundled into the same call is deferred, and verify state explicitly: aws rds modify-db-instance --db-instance-identifier prod-db --no-publicly-accessible --apply-immediately, then confirm with aws rds describe-db-instances --db-instance-identifier prod-db --query 'DBInstances[0].[PubliclyAccessible,PendingModifiedValues]' until PubliclyAccessible returns false and PendingModifiedValues is empty. Separately revoke the security group rule: aws ec2 revoke-security-group-ingress --group-id sg-xxxxxxxx --protocol tcp --port 3306 --cidr 0.0.0.0/0. For standing enforcement, deploy the AWS Config managed rule rds-instance-public-access-check with automatic remediation via the SSM document AWSConfigRemediation-DisablePublicAccessForRDSInstance, so instances that are created or reverted as public are corrected without waiting for an audit; the security group still needs its own control.
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
--apply-immediatelyaws rds modify-db-instance --db-instance-identifier prod-db --no-publicly-accessible --apply-immediatelyaws rds describe-db-instances --db-instance-identifier prod-db --query 'DBInstances[0].[PubliclyAccessible,PendingModifiedValues]'Verify, 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
Corrections
- : Corrected during a review of published articles. Details
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.