Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Oct 22, 2025

Reason for Proposed Changes

  • Currently there is no query to ensure that a "google_sql_database_instance" resource with a "SQLSERVER" based "database_version" has the 'cross db ownership chaining' flag disabled.

  • Quoting CIS_Google_Cloud_Platform_Foundation_Benchmark_v4.0.0 page 247: "This flag is deprecated for all SQL Server versions in CGP. Going forward, you can't set its value to on. However, if you have this flag enabled, we strongly recommend that you either remove the flag from your database or set it to off." and "Enabling cross db ownership is not recommended unless all of the databases hosted by the instance of SQL Server must participate in cross-database ownership chaining and you are aware of the security implications of this setting.

Proposed Changes

  • Implemented the missing query.
  • The query will flag for a specific instance : (after ensuring "database_version" is SQLSERVER based (possible values list))
    • Setting the "cross db ownership chaining" flag to a value that is not "off" (default value is off)

Tenable reference

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions bot added feature New feature query New query feature terraform Terraform query labels Oct 22, 2025
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.13

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review October 22, 2025 15:02
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner October 22, 2025 15:02
Copy link
Contributor

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think of my suggestion @cx-andre-pereira .

"resourceName": tf_lib.get_resource_name(resource, name),
"searchKey": results.searchKey,
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("'google_sql_database_instance[%s].settings.database_flags' should be defined and set 'cross db ownership chaining' to 'off'", [name]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this expectedValue misleading?
Following the documentation description: "This flag is deprecated for all SQL Server versions in CGP. Going forward, you can't set its value to on. However, if you have this flag enabled, we strongly recommend that you either remove the flag from your database or set it to off", the default value is off, I believe we should say that the expected value "should be defined and set"...

Maybe change the message to something similar to other related case queries:

Suggested change
"keyExpectedValue": sprintf("'google_sql_database_instance[%s].settings.database_flags' should be defined and set 'cross db ownership chaining' to 'off'", [name]),
"keyExpectedValue": sprintf("'google_sql_database_instance[%s].settings.database_flags' should set 'cross db ownership chaining' to 'off'", [name]),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants