Skip to content

MDEV-40159: Complete priv escalation for low priv user upon backup re…#5285

Open
sanja-byelkin wants to merge 1 commit into
10.6from
10.6-MDEV-40159
Open

MDEV-40159: Complete priv escalation for low priv user upon backup re…#5285
sanja-byelkin wants to merge 1 commit into
10.6from
10.6-MDEV-40159

Conversation

@sanja-byelkin

Copy link
Copy Markdown
Member

…store: DATA/INDEX DIRECTORY, symlinks

Correct append function called vor walue in quotes

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a SQL injection vulnerability where a low-privilege user could inject malicious SQL commands via a crafted DATA DIRECTORY path containing unescaped single quotes. The fix replaces packet->append with packet->append_for_single_quote in sql/sql_show.cc to ensure directory paths are properly escaped. A new test case has been added to verify the fix. I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses MDEV-40159, closing a privilege-escalation path where a low-privilege user can inject SQL via DATA DIRECTORY/INDEX DIRECTORY values that are later re-emitted (e.g., via SHOW CREATE TABLE / mysqldump) and executed during restore by a higher-privileged user.

Changes:

  • Escape directory paths when emitting DATA DIRECTORY / INDEX DIRECTORY in sql/sql_show.cc.
  • Add a new mysql-test regression case (mysqldump-exploit) to validate the exploit is prevented.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
sql/sql_show.cc Changes directory path emission to use single-quote-aware escaping when generating CREATE statements.
mysql-test/main/mysqldump-exploit.test Adds a regression test that attempts to plant an injected directory path and verifies the backdoor user is not created on restore.
mysql-test/main/mysqldump-exploit.result Captures expected output for the new regression test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sql/sql_show.cc
Comment on lines 1685 to 1689
filename= winfilename;
#endif
packet->append(filename, length);
packet->append_for_single_quote(filename, length);
packet->append('\'');
}
Comment thread mysql-test/main/mysqldump-exploit.test Outdated
CREATE DATABASE restoreddb;
--exec $MYSQL restoreddb < $MYSQLTEST_VARDIR/tmp/m40159_dump.sql 2>/dev/null

# The backdoor admin now exists with GRANT ALL PRIVILEGES ON *.*.
Comment thread mysql-test/main/mysqldump-exploit.test Outdated
Comment on lines +1 to +3
--source include/have_innodb.inc
--source include/have_symlink.inc

Comment thread mysql-test/main/mysqldump-exploit.result Outdated
Correct append function called for value in quotes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants