CVE-2022-0896 (published 2022-03-09T12:15Z)

Improper Neutralization of Special Elements Used in a Template Engine in GitHub repository microweber/microweber prior to 1.3.

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

Weakness information:
cwe_id: CWE-94
cwe_name: Improper Control of Generation of Code ('Code Injection')
description: The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
extended_description: 
            When a product allows a user's input to contain code syntax, it might be possible for an attacker to craft the code in such a way that it will alter the intended control flow of the product. Such an alteration could lead to arbitrary code execution.
            Injection problems encompass a wide variety of issues -- all mitigated in very different ways. For this reason, the most effective way to discuss these weaknesses is to note the distinct features which classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed. The most classic instantiations of this category of weakness are SQL injection and format string vulnerabilities.
         
         

Fix information:
repo_url: https://github.com/microweber/microweber
commit_details: repo_url: https://github.com/microweber/microweber
author: Bozhidar Slaveykov
author_date: 2022-03-09 13:17:21+02:00
msg: Update AdminCommentController.php
repository: repo_url: https://github.com/microweber/microweber
repo_name: microweber/microweber
description: Drag and Drop Website Builder and CMS with E-commerce
repo_language: HTML
owner: microweber
file_changes: filename: AdminCommentController.php
change_type: ModificationType.MODIFY
diff: @@ -18,18 +18,16 @@ use MicroweberPackages\App\Http\Controllers\AdminController;
 use MicroweberPackages\Comment\Models\Comment;
 use MicroweberPackages\Comment\Events\NewComment;
 use MicroweberPackages\Comment\Notifications\NewCommentNotification;
+use MicroweberPackages\Helper\HTMLClean;
 use MicroweberPackages\User\Models\User;
 use MicroweberPackages\Utils\Mail\MailSender;
 
-
 class AdminCommentController extends AdminController
 {
     public function index(Request $request)
     {
-
         $contents = $this->getComments($request);
 
-
         return $this->view('comment::admin.comments.index', ['contents' => $contents]);
     }
 
@@ -42,7 +40,6 @@ class AdminCommentController extends AdminController
             $contents = $contents->filter($filter);
         }
 
-
         $contents = $contents->paginate($request->get('limit', 30))
             ->appends($request->except('page'));
 
@@ -148,12 +145,8 @@ class AdminCommentController extends AdminController
 
         $comment_body = $data['comment_body'];
 
-        // Claer HTML
-        $comment_body = $this->app->format->clean_html($comment_body);
-
-        // Clear XSS
-        $evil = ['(?<!\w)on\w*', 'xmlns', 'formaction', 'xlink:href', 'FSCommand', 'seekSegmentTime'];
-        $comment_body = $this->app->format->clean_xss($comment_body, true, $evil, 'removeEvilAttributes');
+        $cleanHtml = new HTMLClean();
+        $comment_body = $cleanHtml->onlyTags($comment_body);
 
         if (!empty($comment_body) and !empty($data['format']) and $data['format'] == 'markdown') {
             $comment_body = Markdown::convertToHtml($comment_body);

programming_language: PHP