|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28632 LOAD DATA LOCAL security hole problem is stil not solved
Submitted: 2004-06-04 16:22 UTC Modified: 2004-06-04 17:27 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: unknown at masterhost dot ru Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.3.5RC2?-4.3.7 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: unknown at masterhost dot ru
New email:
PHP Version: OS:


 [2004-06-04 16:22 UTC] unknown at masterhost dot ru
 The file accesses with 'LOAD DATA LOCAL INFILE' are made by mysql client library, so you can access any file which webserver process can access to, IGNORING open_basedir option!
 This problem has been reported about year ago (Bug #23779 LOAD DATA LOCAL isn't respecting open_basedir), and you tried to resolve it:
  /* disable local infile option for open_basedir */ 
  if (strlen(PG(open_basedir))) { 
      client_flags ^= CLIENT_LOCAL_FILES; 

  You have used XOR, so if user specified options '128' as fifth parameter for mysql_connect() with enabled open_basedir restrictions, it should disable LOAD DATA LOCAL. But with '0' options given it enables LOAD DATA LOCAL, so we have it enabled by default!

  It seems it should be not just a XOR, may be 
    client_flags &= (32767^CLIENT_LOCAL_FILES); 
  or something like this.

Reproduce code:

$link = mysql_connect('host', 'user', 'password', false, 0);
$db_selected = mysql_select_db('database', $link);

$result = mysql_query("LOAD DATA LOCAL INFILE 'datafile.txt' INTO TABLE test");
if (!$result) {
   die('Invalid query: ' . mysql_error());



Expected result:
There shoule be an error:

Invalid query: The used command is not allowed with this MySQL version

But there isn't, query is successful... 

Actual result:
Data from file is inserted to 'test' table.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-04 16:37 UTC] unknown at masterhost dot ru
The problem presents with older versions too. I have checked it with 4.3.5RC2 and 4.3.7 on FreeBSD 4.9, but it seems other versions after May 2003 are vulnerable, and it's OS-independent.
 [2004-06-04 17:27 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu May 06 04:01:23 2021 UTC