Ensure 'Skip_show_database' Database Flag for Cloud SQL MySQL Instance Is Set to 'On'

'skip_show_database' database flag prevents people from using the SHOW DATABASES statement if they do not have the SHOW DATABASES privilege. This can improve security if you have concerns about users being able to see databases belonging to other users. Its effect depends on the SHOW DATABASES privilege: If the variable value is ON, the SHOW DATABASES statement is permitted only to users who have the SHOW DATABASES privilege, and the statement displays all database names. If the value is OFF, SHOW DATABASES is permitted to all users, but displays the names of only those databases for which the user has the SHOW DATABASES or other privilege.

Risk Level: Medium
Cloud Entity: GCP CloudSql
CloudGuard Rule ID: D9.GCP.VLN.05
Covered by Spectral: Yes
Category: Database

GSL LOGIC

CloudSql where databaseVersion like 'mysql%' should have settings.databaseFlags contain [ name like 'skip_show_database' and value like 'on' ]

REMEDIATION

Attention! Doing the steps below will restart your machine.

From Portal

  1. Navigate to the instance where the flag needs to be set: https://console.cloud.google.com/sql/instances
  2. Click Edit Configurations
  3. Under flags section, choose add flag, look for skip_show_database and choose value - on.
  4. Save and review your changes

From TF
Set the flag 'skip_show_database' to 'on':

resource 'google_sql_database_instance' 'default' {
	...
	settings {
		database_flags {
			name  = 'skip_show_database'
			value = 'on'
		}
	}
}

From Command Line

  1. First retrieve all existing flags values:
gcloud sql instances describe INSTANCE_NAME
  1. Add all existing flags and their value to the patch request - otherwise they will get set to their default value.
gcloud sql instances patch INSTANCE_NAME --database-flags (ExistingFlag1=Value1,ExistingFlag2=Value2,...),skip_show_database=on

References

  1. https://cloud.google.com/sql/docs/mysql/flags
  2. https://cloud.google.com/sdk/gcloud/reference/sql/instances/patch#--database-flags
  3. https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_skip_show_database

GCP CloudSql

Cloud SQL is a fully managed database service that makes it easy to set up, maintain, manage, and administer your relational PostgreSQL, MySQL, and SQL Server databases in the cloud.

Compliance Frameworks

  • CloudGuard GCP All Rules Ruleset
  • GCP CIS Controls V 8
  • GCP CIS Foundations v. 1.2.0
  • GCP CIS Foundations v. 1.3.0
  • GCP CIS Foundations v. 2.0
  • GCP CloudGuard Best Practices
  • GCP MITRE ATT&CK Framework v12.1
  • GCP NIST 800-53 Rev 5