Bug 17904: Fix possible SQL injection in late orders
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 13 Jan 2017 15:46:51 +0000 (16:46 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Mon, 30 Jan 2017 11:22:33 +0000 (11:22 +0000)
To recreate:
/cgi-bin/koha/acqui/lateorders.plop=send_alert&ordernumber=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 d62f827..f6802ce 100644 (file)
@@ -478,10 +478,10 @@ sub SendAlerts {
                 carp "No order selected";
                 return { error => "no_order_selected" };
             }
                 carp "No order selected";
                 return { error => "no_order_selected" };
             }
-            $strsth .= join( ",", @$externalid ) . ")";
+            $strsth .= join( ",", ('?') x @$externalid ) . ")";
             $action = "ACQUISITION CLAIM";
             $sthorders = $dbh->prepare($strsth);
             $action = "ACQUISITION CLAIM";
             $sthorders = $dbh->prepare($strsth);
-            $sthorders->execute;
+            $sthorders->execute( @$externalid );
             $dataorders = $sthorders->fetchall_arrayref( {} );
         }
 
             $dataorders = $sthorders->fetchall_arrayref( {} );
         }