CVE-2015-10018: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability has been found in DBRisinajumi d2files and classified as critical. Affected by this vulnerability is the function actionUpload/actionDownloadFile of the file controllers/D2filesController.php. The manipulation leads to sql injection. Upgrading to version 1.0.0 is able to address this issue. The identifier of the patch is b5767f2ec9d0f3cbfda7f13c84740e2179c90574. It is recommended to upgrade the affected component. The identifier VDB-217561 was assigned to this vulnerability.
CWE description: The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
CVSS v3 base score: 9.8
Published: 2023-01-06T13:15Z
Repository: https://github.com/DBRisinajumi/d2files
Language: PHP
Files changed: controllers/D2filesController.php
Commit date: 2015-01-04 12:38:39 +0200
Commit message: SQL injection problem

Diff: diff --git a/controllers/D2filesController.php b/controllers/D2filesController.php
index 125f50e..ff03162 100644
--- a/controllers/D2filesController.php
+++ b/controllers/D2filesController.php
@@ -112,19 +112,19 @@ class D2filesController extends Controller
         
         // validate download action access
         //if (!Yii::app()->user->checkAccess($model_name . '.uploadD2File')) {
         D2files::extendedCheckAccess($model_name . '.uploadD2File');
         
-        if (!$this->performReadValidation($model_name, $model_id)) {
+        if (!$this->performReadValidation($model_name, (int)$model_id)) {
             throw new CHttpException(403, Yii::t("D2filesModule.model","You are not authorized to perform this action."));
         }
 
         Yii::import("vendor.dbrisinajumi.d2files.compnents.*");
         $oUploadHandler = new UploadHandlerD2files(
                         array(
                             'model_name' => $model_name,
-                            'model_id' => $model_id,
+                            'model_id' => (int)$model_id,
                         )
         );
         
         return true;
 
@@ -173,11 +173,11 @@ class D2filesController extends Controller
 
         Yii::import( "vendor.dbrisinajumi.d2files.compnents.*");
         $oUploadHandler = new UploadHandlerD2files(
                         array(
                             'model_name' => $model->model,
-                            'model_id' => $id,
+                            'model_id' => (int)$id,
                             'download_via_php' => TRUE,
                             'file_name' => $model->file_name,
                         )
         );  
     }

Vulnerable code:         if (!$this->performReadValidation($model_name, $model_id)) {
                            'model_id' => $model_id,
                            'model_id' => $id,
Fixed code:         if (!$this->performReadValidation($model_name, (int)$model_id)) {
                            'model_id' => (int)$model_id,
                            'model_id' => (int)$id,