Bug 15760: Avoid SQL injections
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 11 Feb 2016 10:16:12 +0000 (10:16 +0000)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Thu, 11 Feb 2016 19:42:31 +0000 (19:42 +0000)
Asking on #dbix-class, ribasushi told me to set quote_names to the
connection options.

Indeed it does the fix, globally :)

Test plan:
1/ Add the following snippet to the a script (mainpage.pl is a good candidate)
 use Koha::Virtualshelves;
 my $s = Koha::Virtualshelves->search({}, { order_by => '1,(select case when (3*2*1=6 AND 000227=000227) then 1 else 1*(select table_name from information_schema.tables)end)=1' });
 $s->next;
2/ Execute the script
=> Without the patch, you should not get any error. If you have the mysql logs
enable, you will see the query
=> With the patch applied, you will get a "unknown column" error

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
Koha/Database.pm

index 82d831f..a8f4eab 100644 (file)
@@ -79,6 +79,7 @@ sub _new_schema {
             RaiseError => $ENV{DEBUG} ? 1 : 0,
             PrintError => 1,
             unsafe => 1,
+            quote_names => 1,
             on_connect_do => [
                 $encoding_query || (),
                 $tz_query || (),