MySQL arbitrary read file by client

Actually, when you try to load data local into a table the content of a file the MySQL or MariaDB server asks the client to read it and send the content. Then, if you can tamper a mysql client to connect to your own MySQL server, you can read arbitrary files. Please notice that this is the behaviour using:

load data local infile "/etc/passwd" into table test FIELDS TERMINATED BY '\n';

(Notice the "local" word) Because without the "local" you can get:

mysql> load data infile "/etc/passwd" into table test FIELDS TERMINATED BY '\n';

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

Initial PoC: https://github.com/allyshka/Rogue-MySql-Server In this paper you can see a complete description of the attack and even how to extend it to RCE: https://paper.seebug.org/1113/ Here you can find an overview of the attack: http://russiansecurity.expert/2016/04/20/mysql-connect-file-read/

Last updated