For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform/gcp/sql_database_instance_does_not_have_skip_show_database.md.
A documentation index is available at /llms.txt.
The absence of the skip_show_database flag, or its incorrect setting within a google_sql_database_instance resource, can allow users to view a list of all databases on a MySQL server instance, potentially exposing sensitive schema information to unauthorized individuals. This misconfiguration increases the risk of information disclosure and can aid attackers in reconnaissance activities by providing insight into database names and structures. To mitigate this risk, ensure the configuration includes database_flags { name = "skip_show_database" value = "on" }, as shown below:
resource "google_sql_database_instance" "good_example" {
name = "good-instance"
database_version = "MYSQL_8"
region = "us-central1"
settings {
tier = "db-custom-2-13312"
database_flags {
name = "skip_show_database"
value = "on"
}
database_flags {
name = "cross db ownership chaining"
value = "on"
}
}
}
Compliant Code Examples
resource"google_sql_database_instance""good_example"{name="good-instance"database_version="MYSQL_8"region="us-central1"settings{tier="db-custom-2-13312"database_flags{name="skip_show_database"value="on" # This flag is present as required
}database_flags{name="cross db ownership chaining"value="on"}}}
Non-Compliant Code Examples
resource"google_sql_database_instance""bad_example"{name="bad-instance"database_version="MYSQL_8"region="us-central1"settings{tier="db-custom-2-13312"database_flags{name="cross db ownership chaining"value="on"}}}resource"google_sql_database_instance""bad_example_2"{name="bad-instance"database_version="MYSQL_8"region="us-central1"settings{tier="db-custom-2-13312"database_flags{name="skip_show_database"value="off"}}}resource"google_sql_database_instance""bad_example_3"{name="bad-instance"database_version="MYSQL_8"region="us-central1"settings{tier="db-custom-2-13312"}}
1
2
rulesets:- Terraform / GCP # Rules to enforce / GCP.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.