SQL statements with sensitive information may be logged Affecting Cloud SQL service in Google


Severity

0.0
medium
0
10
    Severity Framework
    Snyk CCSS
    Rule category
    Logging / Configuration

Is your enviroment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
    Frameworks
    CIS-Controls CIS-Google HIPAA ISO-27001 NIST-800-53 SOC-2
  • Snyk ID SNYK-CC-00354
  • credit Snyk Research Team

Description

The PostgreSQL database instance flag 'log_min_duration_statement' defines the minimum amount of execution time of a SQL statement in milliseconds where the total duration of the statement is logged. Disabling it means there will be no logging of SQL statements because some may include sensitive information that should be not be recorded in logs.

How to fix?

Set the settings.database_flags.name attribute to "log_min_duration_statement" and settings.database_flags.value attribute to -1.

Example Configuration

resource "google_sql_database_instance" "allowed" {
  name             = "master-instance"
  database_version = "POSTGRES_11"
  region           = "us-central1"

  settings {
    tier = "db-f1-micro"
    database_flags {
      name  = "log_min_duration_statement"
      value = -1
    }
  }
}