Description
SQL Server can skip a permission check on a referenced object when the objects share an owner and an ownership chain applies. Cloud SQL no longer permits enabling cross db ownership chaining on any SQL Server version.
Potential impact
A grant in one database can allow access to objects in another. Turning off an existing chain can also break operations that depend on it.
Remediation
- Identify cross-database calls and object owners. Grant only the required access or use certificate-signed stored procedures.
- Remove the existing flag or set it to
"off". The SQL instance module ingoogle.cloud1.14.0 cannot update existing instances. Use Cloud SQL administration tools or the API and preserve other required flags. - Test that required operations succeed and unauthorized access is denied.
Examples
SQLSERVER_13_1 is not a supported Cloud SQL version identifier. Use a supported version and a service account JSON file path in your configuration, and quote YAML flag values as strings.
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: cross db ownership chaining
value: on
tier: db-n1-standard-1
state: present
on represents a value that may remain on an older instance.
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: cross db ownership chaining
value: off
tier: db-n1-standard-1
state: present
off disables instance-wide chaining. Grant the permissions required for legitimate cross-database work separately.
References
- CWE-284
- Ansible gcp_sql_instance database_flags documentation
- google.cloud 1.14.0 SQL instance module implementation
- Cloud SQL for SQL Server flags and deprecation notice
- SQL Server cross-database ownership chaining
- Signing stored procedures with a certificate
- Cloud SQL for SQL Server instance settings
- SQL Server ownership chaining and permission checks