MySQL avoid unauthorized reading and SQL Injection vulnerabilities in PHP

in Categories Howto, Linux, MySQL, Security, Tips, UNIX last updated January 6, 2007

The LOAD DATA statement can load a file that is located on the server host, or it can load a file that is located on the client host when the LOCAL keyword is specified.

In a Web server environment where the clients are connecting from a Web server, a user could use LOAD DATA LOCAL to read any files that the Web server process has read access to (assuming that a user could run any command against the SQL server). In this environment, the client with respect to the MySQL server actually is the Web server, not the remote program being run by the user who connects to the Web server. Attacker can take advantage of this SQL injection via PHP/perl etc.

Open my.cnf file:
# vi my.cnf
Append following line [mysqld] section
local-infile=0

Save and restart MySQL server:
# /etc/init.d/mysql restart

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):