Skip to content

Commit 8c1da07

Browse files
puchy22HugoPBrito
andauthored
chore(gcp): enhance metadata for cloudsql service (#9639)
Co-authored-by: HugoPBrito <hugopbrit@gmail.com>
1 parent 02b58d8 commit 8c1da07

File tree

23 files changed

+359
-251
lines changed

23 files changed

+359
-251
lines changed

prowler/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All notable changes to the **Prowler SDK** are documented in this file.
2525
- Update GCP API Keys service metadata to new format [(#9637)](https://github.com/prowler-cloud/prowler/pull/9637)
2626
- Update GCP BigQuery service metadata to new format [(#9638)](https://github.com/prowler-cloud/prowler/pull/9638)
2727
- Update GCP Cloud Storage service metadata to new format [(#9640)](https://github.com/prowler-cloud/prowler/pull/9640)
28+
- Update GCP Cloud SQL service metadata to new format [(#9639)](https://github.com/prowler-cloud/prowler/pull/9639)
2829

2930
### 🔐 Security
3031

prowler/providers/gcp/services/cloudsql/cloudsql_instance_automated_backups/cloudsql_instance_automated_backups.metadata.json

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
{
22
"Provider": "gcp",
33
"CheckID": "cloudsql_instance_automated_backups",
4-
"CheckTitle": "Ensure That Cloud SQL Database Instances Are Configured With Automated Backups",
4+
"CheckTitle": "Cloud SQL database instance has automated backups configured",
55
"CheckType": [],
66
"ServiceName": "cloudsql",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
9-
"Severity": "medium",
10-
"ResourceType": "DatabaseInstance",
11-
"ResourceGroup": "database",
12-
"Description": "Ensure That Cloud SQL Database Instances Are Configured With Automated Backups",
13-
"Risk": "Backups provide a way to restore a Cloud SQL instance to recover lost data or recover from a problem with that instance. Automated backups need to be set for any instance that contains data that should be protected from loss or damage. This recommendation is applicable for SQL Server, PostgreSql, MySql generation 1 and MySql generation 2 instances.",
9+
"Severity": "high",
10+
"ResourceType": "sqladmin.googleapis.com/Instance",
11+
"Description": "**Cloud SQL instances** are checked for **automated backups** being configured to run on a schedule and support point-in-time recovery.",
12+
"Risk": "Absent **automated backups**, unintended deletes, corruption, or ransomware can become irreversible. This degrades data **integrity** and **availability**, removes point-in-time recovery options, and widens `RPO`/`RTO`, causing prolonged outages and incomplete restoration after incidents or schema changes.",
1413
"RelatedUrl": "",
14+
"AdditionalURLs": [
15+
"https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/gcp/CloudSQL/enable-automated-backups.html",
16+
"https://cloud.google.com/sql/docs/mysql/backup-recovery/backups",
17+
"https://cloud.google.com/sql/docs/postgres/configure-ssl-instance/"
18+
],
1519
"Remediation": {
1620
"Code": {
17-
"CLI": "gcloud sql instances patch <INSTANCE_NAME> --backup-start-time <[HH:MM]>",
21+
"CLI": "gcloud sql instances patch <INSTANCE_NAME> --backup-start-time <HH:MM>",
1822
"NativeIaC": "",
19-
"Other": "https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/CloudSQL/enable-automated-backups.html",
20-
"Terraform": ""
23+
"Other": "1. In Google Cloud Console, go to Cloud SQL > Instances\n2. Click your instance name, then click Edit\n3. In the Backups section, enable Automated backups and set a Start time\n4. Click Save to apply",
24+
"Terraform": "```hcl\nresource \"google_sql_database_instance\" \"<example_resource_name>\" {\n name = \"<example_resource_id>\"\n database_version = \"POSTGRES_14\"\n region = \"<REGION>\"\n\n settings {\n tier = \"db-custom-1-3840\"\n\n backup_configuration {\n enabled = true # Critical: turns on automated backups\n start_time = \"02:00\" # Critical: required to enable backups and set start time\n }\n }\n}\n```"
2125
},
2226
"Recommendation": {
23-
"Text": "It is recommended to have all SQL database instances set to enable automated backups.",
24-
"Url": "https://cloud.google.com/sql/docs/postgres/configure-ssl-instance/"
27+
"Text": "Enable **automated backups** on all Cloud SQL instances holding important data. Set retention and schedules to meet `RPO`/`RTO`, and enable point-in-time recovery. Apply **least privilege** to backup access, use **separation of duties**, consider cross-region resilience, and regularly test restores with monitoring and alerts for failures.",
28+
"Url": "https://hub.prowler.com/check/cloudsql_instance_automated_backups"
2529
}
2630
},
27-
"Categories": [],
31+
"Categories": [
32+
"resilience"
33+
],
2834
"DependsOn": [],
2935
"RelatedTo": [],
3036
"Notes": ""

prowler/providers/gcp/services/cloudsql/cloudsql_instance_mysql_local_infile_flag/cloudsql_instance_mysql_local_infile_flag.metadata.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
{
22
"Provider": "gcp",
33
"CheckID": "cloudsql_instance_mysql_local_infile_flag",
4-
"CheckTitle": "Ensure That the Local_infile Database Flag for a Cloud SQL MySQL Instance Is Set to Off",
4+
"CheckTitle": "Cloud SQL MySQL instance has the local_infile database flag set to off",
55
"CheckType": [],
66
"ServiceName": "cloudsql",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
9-
"Severity": "medium",
10-
"ResourceType": "DatabaseInstance",
11-
"ResourceGroup": "database",
12-
"Description": "Ensure That the Local_infile Database Flag for a Cloud SQL MySQL Instance Is Set to Off",
13-
"Risk": "The local_infile flag controls the server-side LOCAL capability for LOAD DATA statements. Depending on the local_infile setting, the server refuses or permits local data loading by clients that have LOCAL enabled on the client side.",
9+
"Severity": "high",
10+
"ResourceType": "sqladmin.googleapis.com/Instance",
11+
"Description": "**Cloud SQL for MySQL** instances are evaluated for the `local_infile` database flag being explicitly set to `off`, disabling use of `LOAD DATA LOCAL`.\n\nInstances where `local_infile` is absent or not `off` are identified.",
12+
"Risk": "With `local_infile` enabled, clients can send local files via `LOAD DATA LOCAL`. A stolen credential or SQL injection can coerce clients to leak files and mass-ingest unvetted data, compromising **confidentiality** and **integrity**, and aiding lateral movement through secrets imported into the database.",
1413
"RelatedUrl": "",
14+
"AdditionalURLs": [
15+
"https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/gcp/CloudSQL/disable-local-infile-flag.html",
16+
"https://cloud.google.com/sql/docs/mysql/flags"
17+
],
1518
"Remediation": {
1619
"Code": {
17-
"CLI": "gcloud sql instances patch INSTANCE_NAME --database-flags local_infile=off",
20+
"CLI": "gcloud sql instances patch <INSTANCE_NAME> --database-flags=local_infile=off",
1821
"NativeIaC": "",
19-
"Other": "https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/CloudSQL/disable-local-infile-flag.html",
20-
"Terraform": "https://docs.prowler.com/checks/gcp/cloud-sql-policies/bc_gcp_sql_1#terraform"
22+
"Other": "1. In Google Cloud Console, go to SQL\n2. Select the MySQL instance and click Edit\n3. In Database flags, add or locate \"local_infile\" and set it to Off\n4. Click Save to apply changes",
23+
"Terraform": "```hcl\nresource \"google_sql_database_instance\" \"<example_resource_name>\" {\n name = \"<example_resource_name>\"\n database_version = \"MYSQL_8_0\"\n region = \"<example_region>\"\n\n settings {\n tier = \"<example_tier>\"\n # Critical: disables LOCAL INFILE to pass the check\n database_flags {\n name = \"local_infile\" # sets the specific flag\n value = \"off\" # required value for compliance\n }\n }\n}\n```"
2124
},
2225
"Recommendation": {
23-
"Text": "It is recommended to set the local_infile database flag for a Cloud SQL MySQL instance to off.",
24-
"Url": "https://cloud.google.com/sql/docs/mysql/flags"
26+
"Text": "Keep `local_infile` set to `off`. Use governed import channels (e.g., controlled object storage imports) and enforce **least privilege** for bulk-loading. Apply **separation of duties** between ingestion and admin roles, validate file sources and formats, and monitor high-volume loads. *If ever needed, enable only briefly for vetted tasks.*",
27+
"Url": "https://hub.prowler.com/check/cloudsql_instance_mysql_local_infile_flag"
2528
}
2629
},
27-
"Categories": [],
30+
"Categories": [
31+
"vulnerabilities"
32+
],
2833
"DependsOn": [],
2934
"RelatedTo": [],
3035
"Notes": ""

prowler/providers/gcp/services/cloudsql/cloudsql_instance_mysql_skip_show_database_flag/cloudsql_instance_mysql_skip_show_database_flag.metadata.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
{
22
"Provider": "gcp",
33
"CheckID": "cloudsql_instance_mysql_skip_show_database_flag",
4-
"CheckTitle": "Ensure Skip_show_database Database Flag for Cloud SQL MySQL Instance Is Set to On",
4+
"CheckTitle": "Cloud SQL MySQL instance has skip_show_database flag set to on",
55
"CheckType": [],
66
"ServiceName": "cloudsql",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
9-
"Severity": "medium",
10-
"ResourceType": "DatabaseInstance",
11-
"ResourceGroup": "database",
12-
"Description": "Ensure Skip_show_database Database Flag for Cloud SQL MySQL Instance Is Set to On",
13-
"Risk": "'skip_show_database' database flag prevents people from using the SHOW DATABASES statement if they do not have the SHOW DATABASES privilege.",
9+
"Severity": "low",
10+
"ResourceType": "sqladmin.googleapis.com/Instance",
11+
"Description": "**Cloud SQL MySQL** instances configure the `skip_show_database` database flag to `on`, limiting use of `SHOW DATABASES` to accounts with the `SHOW DATABASES` privilege.",
12+
"Risk": "Without `skip_show_database` set to `on`, database names can be exposed to unprivileged users, reducing **confidentiality**. Attackers can perform schema **enumeration** and targeted probing, enabling **lateral movement** and privilege escalation against specific datasets.",
1413
"RelatedUrl": "",
14+
"AdditionalURLs": [
15+
"https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/gcp/CloudSQL/enable-skip-show-database-flag.html",
16+
"https://cloud.google.com/sql/docs/mysql/flags"
17+
],
1518
"Remediation": {
1619
"Code": {
17-
"CLI": "gcloud sql instances patch INSTANCE_NAME --database-flags skip_show_database=on",
20+
"CLI": "gcloud sql instances patch <INSTANCE_NAME> --database-flags=skip_show_database=on",
1821
"NativeIaC": "",
19-
"Other": "https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/CloudSQL/enable-skip-show-database-flag.html",
20-
"Terraform": ""
22+
"Other": "1. In Google Cloud Console, go to Cloud SQL > Instances\n2. Open your MySQL instance and click Edit\n3. Under Flags, click Add item, select skip_show_database, set value to ON\n4. Click Save",
23+
"Terraform": "```hcl\nresource \"google_sql_database_instance\" \"<example_resource_name>\" {\n name = \"<example_resource_name>\"\n database_version = \"MYSQL_8_0\"\n region = \"<example_region>\"\n\n settings {\n tier = \"db-custom-1-3840\"\n\n database_flags {\n name = \"skip_show_database\" # Critical: enforce hiding databases from users without SHOW DATABASES privilege\n value = \"on\" # Critical: set flag to 'on' to pass the check\n }\n }\n}\n```"
2124
},
2225
"Recommendation": {
23-
"Text": "It is recommended to set skip_show_database database flag for Cloud SQL Mysql instance to on.",
24-
"Url": "https://cloud.google.com/sql/docs/mysql/flags"
26+
"Text": "Set `skip_show_database` to `on` for all Cloud SQL MySQL instances. Enforce **least privilege** by granting `SHOW DATABASES` only when necessary and reviewing roles regularly. Use **defense in depth**: monitor access and admin actions, and plan changes in maintenance windows as flag updates may trigger restarts.",
27+
"Url": "https://hub.prowler.com/check/cloudsql_instance_mysql_skip_show_database_flag"
2528
}
2629
},
27-
"Categories": [],
30+
"Categories": [
31+
"identity-access"
32+
],
2833
"DependsOn": [],
2934
"RelatedTo": [],
3035
"Notes": ""

prowler/providers/gcp/services/cloudsql/cloudsql_instance_postgres_enable_pgaudit_flag/cloudsql_instance_postgres_enable_pgaudit_flag.metadata.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
{
22
"Provider": "gcp",
33
"CheckID": "cloudsql_instance_postgres_enable_pgaudit_flag",
4-
"CheckTitle": "Ensure That 'cloudsql.enable_pgaudit' Database Flag for each Cloud Sql Postgresql Instance Is Set to 'on' For Centralized Logging",
4+
"CheckTitle": "Cloud SQL PostgreSQL instance has 'cloudsql.enable_pgaudit' flag set to 'on'",
55
"CheckType": [],
66
"ServiceName": "cloudsql",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
9-
"Severity": "medium",
10-
"ResourceType": "DatabaseInstance",
11-
"ResourceGroup": "database",
12-
"Description": "Ensure That 'cloudsql.enable_pgaudit' Database Flag for each Cloud Sql Postgresql Instance Is Set to 'on' For Centralized Logging",
13-
"Risk": "Ensure cloudsql.enable_pgaudit database flag for Cloud SQL PostgreSQL instance is set to on to allow for centralized logging.",
9+
"Severity": "high",
10+
"ResourceType": "sqladmin.googleapis.com/Instance",
11+
"Description": "**Cloud SQL for PostgreSQL** instances are evaluated for the database flag `cloudsql.enable_pgaudit` being set to `on`",
12+
"Risk": "Without `cloudsql.enable_pgaudit`, **database activity** lacks granular audit trails. Undetected reads/writes enable insider abuse, credential reuse, or SQL injection without evidence, harming **confidentiality** and **integrity**. Poor traceability slows incident response, forensics, and undermines compliance.",
1413
"RelatedUrl": "",
14+
"AdditionalURLs": [
15+
"https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/gcp/CloudSQL/postgre-sql-audit-flag.html",
16+
"https://cloud.google.com/sql/docs/postgres/flags",
17+
"https://cloud.google.com/sql/docs/postgres/pg-audit"
18+
],
1519
"Remediation": {
1620
"Code": {
17-
"CLI": "gcloud sql instances patch INSTANCE_NAME --database-flags cloudsql.enable_pgaudit=On",
21+
"CLI": "gcloud sql instances patch <example_resource_id> --database-flags cloudsql.enable_pgaudit=on",
1822
"NativeIaC": "",
19-
"Other": "https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/CloudSQL/postgre-sql-audit-flag.html",
20-
"Terraform": ""
23+
"Other": "1. In Google Cloud Console, go to SQL\n2. Select your PostgreSQL instance and click Edit\n3. In Database flags, click Add item\n4. Set Flag to cloudsql.enable_pgaudit and Value to on\n5. Click Save and restart if prompted",
24+
"Terraform": "```hcl\nresource \"google_sql_database_instance\" \"<example_resource_name>\" {\n name = \"<example_resource_id>\"\n region = \"us-central1\"\n database_version = \"POSTGRES_14\"\n\n settings {\n tier = \"db-custom-1-3840\"\n database_flags {\n name = \"cloudsql.enable_pgaudit\" # Critical: enable pgAudit\n value = \"on\" # Critical: set flag to 'on' to pass the check\n }\n }\n}\n```"
2125
},
2226
"Recommendation": {
23-
"Text": "As numerous other recommendations in this section consist of turning on flags for logging purposes, your organization will need a way to manage these logs. You may have a solution already in place. If you do not, consider installing and enabling the open source pgaudit extension within PostgreSQL and enabling its corresponding flag of cloudsql.enable_pgaudit. This flag and installing the extension enables database auditing in PostgreSQL through the open-source pgAudit extension. This extension provides detailed session and object logging to comply with government, financial, & ISO standards and provides auditing capabilities to mitigate threats by monitoring security events on the instance. Enabling the flag and settings later in this recommendation will send these logs to Google Logs Explorer so that you can access them in a central location.",
24-
"Url": "https://cloud.google.com/sql/docs/postgres/flags"
27+
"Text": "Enable `cloudsql.enable_pgaudit` and configure **pgAudit** to log required classes (e.g., `read`, `write`, `ddl`) under least privilege. Centralize logs, enforce retention and RBAC, and monitor with alerts. *Scope auditing to sensitive data to reduce noise and overhead, and review coverage regularly.*",
28+
"Url": "https://hub.prowler.com/check/cloudsql_instance_postgres_enable_pgaudit_flag"
2529
}
2630
},
27-
"Categories": [],
31+
"Categories": [
32+
"logging",
33+
"forensics-ready"
34+
],
2835
"DependsOn": [],
2936
"RelatedTo": [],
3037
"Notes": ""

prowler/providers/gcp/services/cloudsql/cloudsql_instance_postgres_log_connections_flag/cloudsql_instance_postgres_log_connections_flag.metadata.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
{
22
"Provider": "gcp",
33
"CheckID": "cloudsql_instance_postgres_log_connections_flag",
4-
"CheckTitle": "Ensure That the Log_connections Database Flag for Cloud SQL PostgreSQL Instance Is Set to On",
4+
"CheckTitle": "Cloud SQL PostgreSQL instance has log_connections flag set to on",
55
"CheckType": [],
66
"ServiceName": "cloudsql",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "medium",
10-
"ResourceType": "DatabaseInstance",
11-
"ResourceGroup": "database",
12-
"Description": "Ensure That the Log_connections Database Flag for Cloud SQL PostgreSQL Instance Is Set to On",
13-
"Risk": "Enabling the log_connections setting causes each attempted connection to the server to be logged, along with successful completion of client authentication. This parameter cannot be changed after the session starts.",
10+
"ResourceType": "sqladmin.googleapis.com/Instance",
11+
"Description": "**Cloud SQL for PostgreSQL** instances have the `log_connections` flag set to `on`, causing the server to record every connection attempt and the result of client authentication.",
12+
"Risk": "Without connection logs, unauthorized access attempts can go unnoticed. Attackers may brute-force or reuse credentials without audit evidence, enabling stealthy data access (**confidentiality**), changes via compromised accounts (**integrity**), and connection floods that impact service (**availability**).",
1413
"RelatedUrl": "",
14+
"AdditionalURLs": [
15+
"https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/gcp/CloudSQL/enable-log-connections-flag.html",
16+
"https://cloud.google.com/sql/docs/postgres/flags"
17+
],
1518
"Remediation": {
1619
"Code": {
17-
"CLI": "gcloud sql instances patch INSTANCE_NAME --database-flags log_connections=on",
20+
"CLI": "gcloud sql instances patch <INSTANCE_NAME> --database-flags=log_connections=on",
1821
"NativeIaC": "",
19-
"Other": "https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/CloudSQL/enable-log-connections-flag.html",
20-
"Terraform": "https://docs.prowler.com/checks/gcp/cloud-sql-policies/bc_gcp_sql_3#terraform"
22+
"Other": "1. In Google Cloud Console, go to Cloud SQL > Instances\n2. Open your PostgreSQL instance and click Edit\n3. In Flags, click Add item, select log_connections, set value to on\n4. Click Save and confirm the restart",
23+
"Terraform": "```hcl\nresource \"google_sql_database_instance\" \"<example_resource_name>\" {\n name = \"<example_resource_name>\"\n database_version = \"POSTGRES_14\"\n region = \"<region>\"\n\n settings {\n tier = \"db-f1-micro\"\n\n # Critical: enables connection logging to pass the check\n database_flags {\n name = \"log_connections\" # critical\n value = \"on\" # critical\n }\n }\n}\n```"
2124
},
2225
"Recommendation": {
23-
"Text": "PostgreSQL does not log attempted connections by default. Enabling the log_connections setting will create log entries for each attempted connection as well as successful completion of client authentication which can be useful in troubleshooting issues and to determine any unusual connection attempts to the server.",
24-
"Url": "https://cloud.google.com/sql/docs/postgres/flags"
26+
"Text": "Enable `log_connections`=`on` for all PostgreSQL instances.\n- Apply **defense in depth**: also capture disconnects and audit events\n- Centralize logs, retain them, and alert on anomalies\n- Enforce **least privilege** and strong authentication to reduce exposure and improve detection",
27+
"Url": "https://hub.prowler.com/check/cloudsql_instance_postgres_log_connections_flag"
2528
}
2629
},
27-
"Categories": [],
30+
"Categories": [
31+
"logging"
32+
],
2833
"DependsOn": [],
2934
"RelatedTo": [],
3035
"Notes": ""

0 commit comments

Comments
 (0)