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)
committerKyle M Hall <kyle@bywatersolutions.com>
Mon, 30 Jan 2017 11:21:19 +0000 (11:21 +0000)
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>
C4/Letters.pm

index 3ff39b1..d62f827 100644 (file)
@@ -501,10 +501,10 @@ sub SendAlerts {
                 return { error => "no_order_selected" };
             }
 
-            $strsth .= join( ",", @$externalid ) . ")";
+            $strsth .= join( ",", ('?') x @$externalid ) . ")";
             $action = "CLAIM ISSUE";
             $sthorders = $dbh->prepare($strsth);
-            $sthorders->execute;
+            $sthorders->execute( @$externalid );
             $dataorders = $sthorders->fetchall_arrayref( {} );
         }