Description
MySQL’s LOAD DATA LOCAL sends a file from the client to the server. Both the server’s local_infile flag and the client’s LOCAL capability must allow it.
Potential impact
An untrusted server can request a file the client process can read. Disabling LOCAL also interrupts jobs that import local files.
Remediation
If you do not import local files, set the server flag to off and disable LOCAL on clients. Where imports are required, verify the server’s identity, restrict the client’s file access and SQL privileges, and test the approved imports.
Examples
Both examples configure the same MySQL 8.0 instance. Supply a supported engine version, machine type and other required settings for your environment.
Before
hcl
resource "google_sql_database_instance" "db" {
name = "mysql-instance"
database_version = "MYSQL_8_0"
region = "us-central1"
settings {
database_flags {
name = "local_infile"
value = "on"
}
}
}
After
hcl
resource "google_sql_database_instance" "db" {
name = "mysql-instance"
database_version = "MYSQL_8_0"
region = "us-central1"
settings {
tier = "db-f1-micro"
database_flags {
name = "local_infile"
value = "off"
}
}
}
Explanation:
- Before:
onlets the server accept local file imports. - After:
offdisables local imports on this server. The addeddb-f1-microis a separate machine type setting.