Description
When contained database authentication is enabled, SQL Server can authenticate a user inside a contained database without a server login.
Potential impact
Reviewing server logins alone can miss these database users. A user with ALTER ANY USER can grant access to another account.
Remediation
Identify contained users and the applications that use them. If the feature is unnecessary, migrate those connections before setting the flag to "off". If it must stay enabled, restrict who can manage users. Update existing instances with Cloud SQL administration tools or the API because the google.cloud 1.14.0 module cannot update them. Preserve other required flags and test that only approved clients can connect.
Examples
Use a supported Cloud SQL version in place of SQLSERVER_13_1 and provide your service account JSON file path. Quote YAML flag values as strings, such as "on" and "off".
First configuration
- name: sql_instance
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
database_version: SQLSERVER_13_1
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
database_flags:
- name: contained database authentication
value: on
tier: db-n1-standard-1
state: present
on permits database-level authentication. Review both server logins and contained users.
Comparison configuration
- name: sql_instance
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
database_version: SQLSERVER_13_1
name: '{{ resource_name }}-2'
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
database_flags:
- name: contained database authentication
value: off
tier: db-n1-standard-1
state: present
off disables this authentication method. Verify existing application connections after applying it.