Cloud SQL SQL Server instance has 'cross db ownership chaining' flag set to off
Cloud SQL SQL Server instances are evaluated for the cross db ownership chaining server flag. The finding identifies SQL Server instances where this flag isn't set to off, meaning cross-database ownership chaining is permitted.
Risk
Allowing cross-database ownership chaining erodes database boundaries, impacting confidentiality and integrity. Users with privileges in one database can traverse ownership chains to access or modify objects in others, enabling privilege escalation, lateral movement, and unauthorized data exposure.
Run this check with Prowler
Run in Prowler Cloudprowler gcp --checks cloudsql_instance_sqlserver_cross_db_ownership_chaining_flagRecommendation
Keep cross db ownership chaining set to off to maintain database isolation. Enforce least privilege with explicit per-database permissions and separation of duties. Prefer controlled execution patterns (e.g., signed modules) over implicit trusts, and periodically review flags and access. This flag is deprecated-do not enable it.
Remediation
CLI
gcloud sql instances patch <example_resource_name> --database-flags '"cross db ownership chaining"=off'Terraform
resource "google_sql_database_instance" "<example_resource_name>" {
name = "<example_resource_name>"
region = "<REGION>"
database_version = "SQLSERVER_2019_STANDARD"
settings {
tier = "<TIER>"
# Critical: ensures the flag is OFF to pass the check
database_flags {
name = "cross db ownership chaining" # disables cross-database ownership chaining
value = "off"
}
}
}Other
Check Code
from prowler.lib.check.models import Check, Check_Report_GCP
from prowler.providers.gcp.services.cloudsql.cloudsql_client import cloudsql_client
class cloudsql_instance_sqlserver_cross_db_ownership_chaining_flag(Check):
def execute(self) -> Check_Report_GCP:
findings = []
for instance in cloudsql_client.instances:
if "SQLSERVER" in instance.version:
report = Check_Report_GCP(metadata=self.metadata(), resource=instance)
report.status = "PASS"
report.status_extended = f"SQL Server Instance {instance.name} has 'cross db ownership chaining' flag set to 'off'."
for flag in instance.flags:
if (
flag.get("name", "") == "cross db ownership chaining"
and flag.get("value", "off") == "on"
):
report.status = "FAIL"
report.status_extended = f"SQL Server Instance {instance.name} does not have 'cross db ownership chaining' flag set to 'off'."
break
findings.append(report)
return findings