CVE-2023-1883 (published 2023-04-05T17:15Z)

Improper Access Control in GitHub repository thorsten/phpmyfaq prior to 3.1.12.

CVSS v3 base score: 5.4, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-284
cwe_name: Improper Access Control
description: The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
extended_description: 
            Access control involves the use of several protection mechanisms such as:
            
               Authentication (proving the identity of an actor)
               Authorization (ensuring that a given actor can access a resource), and
               Accountability (tracking of activities that were performed)
            
            When any mechanism is not applied or otherwise fails, attackers can compromise the security of the product by gaining privileges, reading sensitive information, executing commands, evading detection, etc.
            There are two distinct behaviors that can introduce access control weaknesses:
               
                  Specification: incorrect privileges, permissions, ownership, etc. are explicitly specified for either the user or the resource (for example, setting a password file to be world-writable, or giving administrator capabilities to a guest user). This action could be performed by the program or the administrator.
                  Enforcement: the mechanism contains errors that prevent it from properly enforcing the specified access control requirements (e.g., allowing the user to specify their own privileges, or allowing a syntactically-incorrect ACL to produce insecure settings). This problem occurs within the program itself, in that it does not actually enforce the intended security policy that the administrator specifies.
               
         
		 

Fix information:
repo_url: https://github.com/thorsten/phpmyfaq
commit_details: repo_url: https://github.com/thorsten/phpmyfaq
author: Thorsten Rinne
author_date: 2023-02-14 19:14:05+01:00
msg: fix: added check if news or FAQs are active
repository: repo_url: https://github.com/thorsten/phpmyfaq
repo_name: thorsten/phpMyFAQ
description: phpMyFAQ - Open Source FAQ web application for PHP 8.1+ and MySQL, PostgreSQL and other databases
repo_language: PHP
owner: thorsten
file_changes: filename: ajaxservice.php
change_type: ModificationType.MODIFY
diff: @@ -185,13 +185,8 @@ switch ($action) {
         }
 
         if (
-            !is_null($username) && !is_null($mailer) && !is_null($comment) && $stopWords->checkBannedWord(
-                $comment
-            ) && !$faq->commentDisabled(
-                $id,
-                $languageCode,
-                $type
-            )
+            !is_null($username) && !is_null($mailer) && !is_null($comment) && $stopWords->checkBannedWord($comment) &&
+            !$faq->commentDisabled($id, $languageCode, $type) && !$faq->isActive($id, $languageCode, $type)
         ) {
             try {
                 $faqSession->userTracking('save_comment', $id);

programming_language: PHP
filename: Faq.php
change_type: ModificationType.MODIFY
diff: @@ -1258,6 +1258,39 @@ class Faq
         return false;
     }
 
+    public function isActive(int $recordId, string $recordLang, string $commentType = 'faq'): bool
+    {
+        if ('news' === $commentType) {
+            $table = 'faqnews';
+        } else {
+            $table = 'faqdata';
+        }
+
+        $query = sprintf(
+            "
+            SELECT
+                active
+            FROM
+                %s%s
+            WHERE
+                id = %d
+            AND
+                lang = '%s'",
+            Database::getTablePrefix(),
+            $table,
+            $recordId,
+            $this->config->getDb()->escape($recordLang)
+        );
+
+        $result = $this->config->getDb()->query($query);
+
+        if ($row = $this->config->getDb()->fetchObject($result)) {
+            return !(($row->active === 'y' || $row->active === 'yes'));
+        } else {
+            return true;
+        }
+    }
+
     /**
      * Checks, if comments are disabled for the FAQ record.
      *
@@ -1268,7 +1301,7 @@ class Faq
      */
     public function commentDisabled(int $recordId, string $recordLang, string $commentType = 'faq'): bool
     {
-        if ('news' == $commentType) {
+        if ('news' === $commentType) {
             $table = 'faqnews';
         } else {
             $table = 'faqdata';

programming_language: PHP