Cross-database ownership chaining is enabled in Cloud SQL

Cross-database ownership chaining affects permission checks on objects in other databases. Review existing dependencies and remove unnecessary chains.

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

  1. Identify cross-database calls and object owners. Grant only the required access or use certificate-signed stored procedures.
  2. Remove the existing flag or set it to "off". The SQL instance module in google.cloud 1.14.0 cannot update existing instances. Use Cloud SQL administration tools or the API and preserve other required flags.
  3. 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

yaml
- 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

yaml
- 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