CVE-2022-1032 (published 2022-03-29T08:15Z)

Insecure deserialization of not validated module file in GitHub repository crater-invoice/crater prior to 6.0.6.

Severity: MEDIUM
CVSS v2 base score: 6.5 (AV:N/AC:L/Au:S/C:P/I:P/A:P)
CVSS v3 base score: 7.2, HIGH (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-502
cwe_name: Deserialization of Untrusted Data
description: The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
extended_description: 
            It is often convenient to serialize objects for communication or to save them for later use. However, deserialized data or code can often be modified without using the provided accessor functions if it does not use cryptography to protect itself. Furthermore, any cryptography would still be client-side security -- which is a dangerous security assumption.
            Data that is untrusted can not be trusted to be well-formed.
            When developers place no restrictions on "gadget chains," or series of instances and method invocations that can self-execute during the deserialization process (i.e., before the object is returned to the caller), it is sometimes possible for attackers to leverage them to perform unauthorized actions, like generating a shell.
         
         

Fix information:
repo_url: https://github.com/crater-invoice/crater
commit_details: repo_url: https://github.com/crater-invoice/crater
author: theWorstComrade
author_date: 2022-03-29 09:25:35+02:00
msg: Module upload validation (#857)

https://huntr.dev/bounties/cb9a0393-be34-4021-a06c-00c7791c7622/
repository: repo_url: https://github.com/crater-invoice/crater
repo_name: crater-invoice/crater
description: Open Source Invoicing Solution for Individuals & Businesses
repo_language: PHP
owner: crater-invoice
file_changes: filename: UnzipModuleController.php
change_type: ModificationType.MODIFY
diff: @@ -3,18 +3,18 @@
 namespace Crater\Http\Controllers\V1\Admin\Modules;
 
 use Crater\Http\Controllers\Controller;
+use Crater\Http\Requests\UnzipUpdateRequest;
 use Crater\Space\ModuleInstaller;
-use Illuminate\Http\Request;
 
 class UnzipModuleController extends Controller
 {
     /**
      * Handle the incoming request.
      *
-     * @param  \Illuminate\Http\Request  $request
+     * @param  \Crater\Http\Requests\UnzipUpdateRequest  $request
      * @return \Illuminate\Http\Response
      */
-    public function __invoke(Request $request)
+    public function __invoke(UnzipUpdateRequest $request)
     {
         $this->authorize('manage modules');
 

programming_language: PHP
filename: UploadModuleController.php
change_type: ModificationType.MODIFY
diff: @@ -3,18 +3,18 @@
 namespace Crater\Http\Controllers\V1\Admin\Modules;
 
 use Crater\Http\Controllers\Controller;
+use Crater\Http\Requests\UploadModuleRequest;
 use Crater\Space\ModuleInstaller;
-use Illuminate\Http\Request;
 
 class UploadModuleController extends Controller
 {
     /**
      * Handle the incoming request.
      *
-     * @param  \Illuminate\Http\Request  $request
+     * @param  \Crater\Http\Requests\UploadModuleRequest  $request
      * @return \Illuminate\Http\Response
      */
-    public function __invoke(Request $request)
+    public function __invoke(UploadModuleRequest $request)
     {
         $this->authorize('manage modules');
 

programming_language: PHP
filename: UnzipUpdateRequest.php
change_type: ModificationType.ADD
diff: @@ -0,0 +1,37 @@
+<?php
+
+namespace Crater\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UnzipUpdateRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'path' => [
+                'required',
+                'regex:/^[\.\/\w\-]+$/'
+            ],
+            'module' => [
+                'required',
+                'string'
+            ]
+        ];
+    }
+}

programming_language: PHP
filename: UploadModuleRequest.php
change_type: ModificationType.ADD
diff: @@ -0,0 +1,40 @@
+<?php
+
+namespace Crater\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UploadModuleRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'avatar' => [
+                'required',
+                'file',
+                'mimes:zip',
+                'max:20000'
+            ],
+            'module' => [
+                'required',
+                'string',
+                'max:100'
+            ]
+        ];
+    }
+}

programming_language: PHP