Bug 17903: Fix possible SQL injection in serial claims
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 13 Jan 2017 15:40:59 +0000 (16:40 +0100)
committerJulian Maurice <julian.maurice@biblibre.com>
Mon, 30 Jan 2017 14:54:18 +0000 (15:54 +0100)
To recreate:
/cgi-bin/koha/serials/claims.pl?serialid=1)and%20(select*from(select(sleep(20)))a)--%20&letter_code=0

Notice the delay.

The SQL query is not constructed correctly, placeholders must be used.

This vulnerability has been reported by MDSec.

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 179ff58b0980f348821c727c2fa79a5eca310901)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

C4/Letters.pm

index 798ae9e..5cc824d 100644 (file)
@@ -477,9 +477,9 @@ sub SendAlerts {
             return { error => "no_order_selected" };
         }
 
-        $strsth .= join( ",", @$externalid ) . ")";
+        $strsth .= join( ",", ('?') x @$externalid ) . ")";
         my $sthorders = $dbh->prepare($strsth);
-        $sthorders->execute;
+        $sthorders->execute( @$externalid );
         my $dataorders = $sthorders->fetchall_arrayref( {} );
 
         my $sthbookseller =