Ensure that the 'contained database authentication' database flag for Cloud SQL on the SQL Server instance is set to 'off'

Setting contained database authentication to 'on' will enable the use of Contained databases, which is not recommend for most cases due to potential security threats. Most of the threats are related to the USER WITH PASSWORD authentication process, which moves the authentication process from the Database Engine level to the database level.

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


CloudSql where databaseVersion like 'SQLSERVER%' should have settings.databaseFlags contain [ name like 'contained database authentication' and value like 'off' ]


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 'contained database authentication' and choose value - off.
  4. Save and review your changes

From TF
Set the flag 'contained database authentication' to 'off':

resource 'google_sql_database_instance' 'default' {
	settings {
		database_flags {
			name  = 'contained database authentication'
			value = 'off'

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,...),'contained database authentication'=off


  1. https://cloud.google.com/sdk/gcloud/reference/sql/instances/describe
  2. https://cloud.google.com/sdk/gcloud/reference/sql/instances/patch#--database-flags
  3. https://cloud.google.com/sql/docs/mysql/flags
  4. https://docs.microsoft.com/en-us/sql/relational-databases/databases/security-best-practices-with-contained-databases
  5. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/contained-database-authentication-server-configuration-option

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.1.0
  • 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