Skip to content
Access control Write-up Intermediate

CVE-2018-2813: MySQL Missing Privilege Check

MySQL server versions 5.6.39 and prior did not enforce the FILE privilege when using the DATA DIRECTORY or INDEX DIRECTORY option in an ALTER TABLE ... PARTITION statement. An attacker with low privileges could write files to arbitrary directories on the server, as demonstrated by creating a table file in /tmp.

amlw.dev

Published on amlw.dev

MySQL server versions 5.6.39 and prior were missing a file privilege check. The server documentation states that “as of MySQL 5.6.35, the FILE privilege is required to use the DATA DIRECTORY or INDEX DIRECTORY table option.” The access checks were not performing when making an ALTER TABLE statement with PARTITION.

The author, on amlw.dev

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker with a low-privileged MySQL account could write files to arbitrary directories on the server, potentially leading to further compromise, though the text does not specify the full extent.

What the attacker needed

A low-privileged MySQL account; access to a database

The fix

The vulnerability was fixed in later MySQL versions by ensuring the FILE privilege is checked for ALTER TABLE with PARTITION as well.

How it was found

  1. Set up a MySQL database and a low-privileged user with access to that database.
  2. As the low-privileged user, attempt to create a table with a partition using DATA DIRECTORY; this is denied.
  3. Create a normal table without the DATA DIRECTORY option.
  4. Alter the table to add a partition with DATA DIRECTORY; this succeeds.
  5. Check the filesystem to see that the table file was written to the specified directory.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

MySQL has a permission called FILE that controls whether a user can read or write files on the server's disk. The report shows that even when a low-privileged user was blocked from using a file-related option in one command (CREATE TABLE), they could still use the same option in another command (ALTER TABLE with PARTITION) because the permission check was missing. This let them write files to places they shouldn't, like the /tmp folder.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.