Skip to content

Commit 788fb5b

Browse files
author
Shishir Jaiswal
committed
Bug#25043674 - MYSQLACCESS SCRIPT LOADS AND EXECUTES CODE
FROM THE CURRENT DIRECTORY DESCRIPTION =========== When 'mysqlaccess' tool is run, it reads (and executes) the content of its configuration file 'mysqlaccess.conf' from the current directory. This is not a recommended behaviour as someone with ill intentions can insert malicious instructions into this file which could be executed whenever this tool is run. ANALYSIS ======== The configuration file is presently looked for, in the following folders (in given order): 1. Current directory 2. SYSCONFDIR //This gets expanded 3. /etc/ Owing to the reasons mentioned above, we should not permit the file to be in the current directory. Since the other two folders are assumed to be accessible only to authorized people, the config file is safe to be read from there. FIX === Modified the script so that it looks for the config file now in the following two folders (in the given order): 1. SYSCONFDIR 2. /etc/ If it's absent from above locations but present in current directory, an error is thrown asking the user to move the file to one of the above locations and retry. NOTE ==== The location paths and their precedence are not documented for this tool. It needs to be noted as part of the associated documentation.
1 parent 2cc44da commit 788fb5b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

mysql-test/mysql-test-run.pl

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl
22
# -*- cperl -*-
33

4-
# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -2454,6 +2454,17 @@ sub environment_setup {
24542454
"$basedir/storage/myisam/myisampack",
24552455
"$basedir/myisam/myisampack"));
24562456

2457+
# ----------------------------------------------------
2458+
# mysqlaccess
2459+
# ----------------------------------------------------
2460+
my $mysqlaccess=
2461+
mtr_pl_maybe_exists("$bindir/scripts/mysqlaccess") ||
2462+
mtr_pl_maybe_exists("$path_client_bindir/mysqlaccess");
2463+
if ($mysqlaccess)
2464+
{
2465+
$ENV{'MYSQLACCESS'}= $mysqlaccess;
2466+
}
2467+
24572468
# ----------------------------------------------------
24582469
# mysqlhotcopy
24592470
# ----------------------------------------------------

scripts/mysqlaccess.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,22 @@ MySQLaccess::Report::Print_Header();
477477
# *****************************
478478
# Read configuration-file
479479
MySQLaccess::Debug::Print(1, "Reading configuration file...");
480-
if (-f "./$script_conf") {
481-
require "./$script_conf";
482-
}
483-
elsif (-f "@sysconfdir@/$script_conf") {
480+
if (-f "@sysconfdir@/$script_conf") {
481+
print "Configuration file '$script_conf' is found in '@sysconfdir@/'\n";
484482
require "@sysconfdir@/$script_conf";
485483
}
486484
elsif (-f "/etc/$script_conf") {
485+
print "Configuration file '$script_conf' is found in '/etc/'\n";
487486
require "/etc/$script_conf";
488487
}
488+
elsif (-f "./$script_conf") {
489+
print "\nERROR! Configuration file '$script_conf' is found in the current ";
490+
print "directory.\nThe permissible locations for this file are either ";
491+
print "@sysconfdir@/ or /etc/\n";
492+
print "Please move it to one of these locations and retry.\n\n";
493+
exit 0;
494+
}
495+
489496
490497
# ****************************
491498
# Read in all parameters

0 commit comments

Comments
 (0)