SKY-D405 · Deployment and infrastructure
Terraform makes an RDS database publicly accessible
publicly_accessible = true gives an Amazon RDS database a public DNS name and IP address. SKY-D405 reports a Terraform aws_db_instance that asks for this.
- Languages
- Terraform
- Quality gate
- counted toward the gate limits (full and diff scans). Reported under security (
danger). It counts towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Terraform AWS database public accessibility enabled
Why it matters
A database reachable from the internet is one security-group mistake away from password guessing and exploit attempts against the database server. Application databases rarely need it: the application talks to them inside the VPC.
What Skylos flags
resource "aws_db_instance" "orders" { identifier = "orders" engine = "postgres" engine_version = "16.4" instance_class = "db.t3.medium" allocated_storage = 50 username = "orders" manage_master_user_password = true storage_encrypted = true publicly_accessible = true}What Skylos leaves alone
resource "aws_db_instance" "orders" { identifier = "orders" engine = "postgres" engine_version = "16.4" instance_class = "db.t3.medium" allocated_storage = 50 username = "orders" manage_master_user_password = true storage_encrypted = true publicly_accessible = false}Why Skylos leaves it alone
The same database with public access explicitly off. It is reachable only from inside its VPC.
How Skylos decides
- Runs with
--danger(or-a). Reads.tfand.tf.jsonfiles, skipping.terraform,.git,node_modules,vendor,build,distand virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS. - Resolves only literal values and
localvalues of the same module. Input variables, data sources, attributes of other resources and module outputs stay unknown, and an unknown value never produces a finding. - Skips a resource with
count = 0or an emptyfor_each, and needs the official AWS provider (hashicorp/aws, which anaws_resource uses unless another provider is configured). - Checks
aws_db_instanceresources. - Reports when
publicly_accessibleis the literaltrue. Leaving it out (the AWS default isfalse) is not reported. - Reports HIGH on the
resourceline. Whether the database can really be reached also depends on subnets, routes and security groups, which the rule does not evaluate.
How to fix it
Set publicly_accessible = false and reach the database from inside the VPC, through a bastion, Session Manager port forwarding or a VPN.
resource "aws_db_instance" "orders" { identifier = "orders" engine = "postgres" engine_version = "16.4" instance_class = "db.t3.medium" allocated_storage = 50 username = "orders" manage_master_user_password = true storage_encrypted = trueRemoved: publicly_accessible = trueAdded: publicly_accessible = false}When it can be wrong
- Values that come from variables, modules or other resources are not checked, because Skylos does not run Terraform:
cidr_blocks = var.admin_cidrsis not reported even when its default is0.0.0.0/0. - It judges the declaration only. It does not know what is deployed, and other settings (account defaults, security groups, routing) can make the real exposure smaller or larger.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Terraform rules read no inline marker:
# skylos: ignore[SKY-D405]on the resource line does not hide the finding.[tool.skylos] ignore = ["SKY-D405"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the declarations that exist today and reports new ones.