Skip to main content

SKY-D405 · Deployment and infrastructure

Terraform makes an RDS database publicly accessible

High

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 toward max_high and max_security; the rule never reports CRITICAL.
Finding type
review
Catalog name
Terraform AWS database public accessibility enabled
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

main.tf · TerraformReported on line 1
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

main.tf · Terraform
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

  1. Runs with --danger (or -a). Reads .tf and .tf.json files, skipping .terraform, .git, node_modules, vendor, build, dist and virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS.
  2. Resolves only literal values and local values 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.
  3. Skips a resource with count = 0 or an empty for_each, and needs the official AWS provider (hashicorp/aws, which an aws_ resource uses unless another provider is configured).
  4. Checks aws_db_instance resources.
  5. Reports when publicly_accessible is the literal true. Leaving it out (the AWS default is false) is not reported.
  6. Reports HIGH on the resource line. 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.

main.tf · Terraform · the fix, against the flagged file
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_cidrs is not reported even when its default is 0.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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.