CVE-2023-0313 (published 2023-01-15T22:15Z)

Cross-site Scripting (XSS) - Stored in GitHub repository thorsten/phpmyfaq prior to 3.1.10.

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

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/thorsten/phpmyfaq
commit_details: repo_url: https://github.com/thorsten/phpmyfaq
author: Thorsten Rinne
author_date: 2022-12-15 21:11:57+01:00
msg: fix: added missing conversion to HTML entities
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: category.main.php
change_type: ModificationType.MODIFY
diff: @@ -79,8 +79,8 @@ if (!defined('IS_VALID_PHPMYFAQ')) {
                 $categoryLang = Filter::filterInput(INPUT_POST, 'lang', FILTER_UNSAFE_RAW);
                 $categoryData = [
                     'lang' => $categoryLang,
-                    'name' => Filter::filterInput(INPUT_POST, 'name', FILTER_UNSAFE_RAW),
-                    'description' => Filter::filterInput(INPUT_POST, 'description', FILTER_UNSAFE_RAW),
+                    'name' => Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_SPECIAL_CHARS),
+                    'description' => Filter::filterInput(INPUT_POST, 'description', FILTER_SANITIZE_SPECIAL_CHARS),
                     'user_id' => Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT),
                     'group_id' => Filter::filterInput(INPUT_POST, 'group_id', FILTER_VALIDATE_INT),
                     'active' => Filter::filterInput(INPUT_POST, 'active', FILTER_VALIDATE_INT),

programming_language: PHP
filename: news.php
change_type: ModificationType.MODIFY
diff: @@ -7,13 +7,13 @@
  * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  * obtain one at http://mozilla.org/MPL/2.0/.
  *
- * @package phpMyFAQ
- * @author Thorsten Rinne <thorsten@phpmyfaq.de>
- * @author Matteo Scaramuccia <matteo@phpmyfaq.de>
+ * @package   phpMyFAQ
+ * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
+ * @author    Matteo Scaramuccia <matteo@phpmyfaq.de>
  * @copyright 2003-2022 phpMyFAQ Team
- * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
- * @link https://www.phpmyfaq.de
- * @since 2003-02-23
+ * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
+ * @link      https://www.phpmyfaq.de
+ * @since     2003-02-23
  */
 
 use phpMyFAQ\Comments;
@@ -21,7 +21,7 @@ use phpMyFAQ\Date;
 use phpMyFAQ\Entity\CommentType;
 use phpMyFAQ\Filter;
 use phpMyFAQ\Helper\LanguageHelper;
-use phpMyFAQ\News;
+use phpMyFAQ\News;use phpMyFAQ\Strings;
 
 if (!defined('IS_VALID_PHPMYFAQ')) {
     http_response_code(400);
@@ -66,7 +66,9 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                     </div>
 
                     <div class="form-group row">
-                        <label class="col-3 col-form-label" for="authorName"><?= $PMF_LANG['ad_news_author_name'] ?></label>
+                        <label class="col-3 col-form-label" for="authorName">
+                        <?= $PMF_LANG['ad_news_author_name'] ?>
+                        </label>
                         <div class="col-9">
                             <input class="form-control" type="text" name="authorName" id="authorName"
                                    value="<?= $user->getUserData('display_name') ?>">
@@ -74,7 +76,9 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                     </div>
 
                     <div class="form-group row">
-                        <label class="col-3 col-form-label" for="authorEmail"><?= $PMF_LANG['ad_news_author_email'] ?></label>
+                        <label class="col-3 col-form-label" for="authorEmail">
+                        <?= $PMF_LANG['ad_news_author_email'] ?>
+                        </label>
                         <div class="col-9">
                             <input class="form-control" type="email" name="authorEmail" id="authorEmail"
                                    value="<?= $user->getUserData('email') ?>">
@@ -94,7 +98,9 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                     </div>
 
                     <div class="form-group row">
-                        <label class="col-3 col-form-label" for="comment"><?= $PMF_LANG['ad_news_allowComments'] ?></label>
+                        <label class="col-3 col-form-label" for="comment">
+                        <?= $PMF_LANG['ad_news_allowComments'] ?>
+                        </label>
                         <div class="col-9 checkbox">
                             <label>
                                 <input type="checkbox" name="comment" id="comment" value="y">
@@ -106,12 +112,15 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                     <div class="form-group row">
                         <label class="col-3 col-form-label" for="link"><?= $PMF_LANG['ad_news_link_url'] ?></label>
                         <div class="col-9">
-                            <input class="form-control" type="text" name="link" id="link" placeholder="http://www.example.com/">
+                            <input class="form-control" type="text" name="link" id="link"
+                            placeholder="http://www.example.com/">
                         </div>
                     </div>
 
                     <div class="form-group row">
-                        <label class="col-3 col-form-label" for="linkTitle"><?= $PMF_LANG['ad_news_link_title'] ?></label>
+                        <label class="col-3 col-form-label" for="linkTitle">
+                        <?= $PMF_LANG['ad_news_link_title'] ?>
+                        </label>
                         <div class="col-9">
                             <input type="text" name="linkTitle" id="linkTitle" class="form-control">
                         </div>
@@ -207,7 +216,7 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
         foreach ($newsHeader as $newsItem) {
             ?>
                     <tr>
-                        <td><?= $newsItem['header'] ?></td>
+                        <td><?= Strings::htmlentities($newsItem['header']) ?></td>
                         <td><?= $date->format($newsItem['date']) ?></td>
                         <td>
                             <a class="btn btn-primary" href="?action=edit-news&amp;id=<?= $newsItem['id'] ?>">
@@ -254,7 +263,7 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                         <label class="col-3 col-form-label" for="newsheader"><?= $PMF_LANG['ad_news_header'] ?></label>
                         <div class="col-9">
                             <input type="text" name="newsheader" id="newsheader" class="form-control"
-                                   value="<?= $newsData['header'] ?? '' ?>">
+                                   value="<?= Strings::htmlentities($newsData['header']) ?? '' ?>">
                         </div>
                     </div>
 
@@ -270,16 +279,20 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                     </div>
 
                     <div class="form-group row">
-                        <label class="col-3 col-form-label" for="authorName"><?= $PMF_LANG['ad_news_author_name'] ?></label>
+                        <label class="col-3 col-form-label" for="authorName">
+                        <?= $PMF_LANG['ad_news_author_name'] ?>
+                        </label>
                         <div class="col-9">
-                            <input type="text" name="authorName" value="<?= $newsData['authorName'] ?>" class="form-control">
+                            <input type="text" name="authorName" class="form-control"
+                                value="<?= Strings::htmlentities($newsData['authorName']) ?>">
                         </div>
                     </div>
 
                     <div class="form-group row">
                         <label class="col-3 col-form-label" for="authorEmail"><?= $PMF_LANG['ad_news_author_email'] ?></label>
                         <div class="col-9">
-                            <input type="email" name="authorEmail" value="<?= $newsData['authorEmail'] ?>" class="form-control">
+                            <input type="email" name="authorEmail" class="form-control"
+                                value="<?= Strings::htmlentities($newsData['authorEmail']) ?>">
                         </div>
                     </div>
 
@@ -315,15 +328,16 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
                     <div class="form-group row">
                         <label class="col-3 col-form-label" for="link"><?= $PMF_LANG['ad_news_link_url'] ?></label>
                         <div class="col-9">
-                            <input type="text" id="link" name="link" value="<?= $newsData['link'] ?>" class="form-control">
+                            <input type="text" id="link" name="link"
+                            value="<?= Strings::htmlentities($newsData['link']) ?>" class="form-control">
                         </div>
                     </div>
 
                     <div class="form-group row">
                         <label class="col-3 col-form-label" for="linkTitle"><?= $PMF_LANG['ad_news_link_title'] ?></label>
                         <div class="col-9">
-                            <input type="text" id="linkTitle" name="linkTitle" value="<?= $newsData['linkTitle'] ?>"
-                            class="form-control">
+                            <input type="text" id="linkTitle" name="linkTitle"
+                            value="<?= Strings::htmlentities($newsData['linkTitle']) ?>" class="form-control">
                         </div>
                     </div>
 
@@ -429,14 +443,14 @@ if ('add-news' == $action && $user->perm->hasPermission($user->getUserId(), 'add
     <?php
     $dateStart = Filter::filterInput(INPUT_POST, 'dateStart', FILTER_UNSAFE_RAW);
     $dateEnd = Filter::filterInput(INPUT_POST, 'dateEnd', FILTER_UNSAFE_RAW);
-    $header = Filter::filterInput(INPUT_POST, 'newsheader', FILTER_UNSAFE_RAW);
+    $header = Filter::filterInput(INPUT_POST, 'newsheader', FILTER_SANITIZE_SPECIAL_CHARS);
     $content = Filter::filterInput(INPUT_POST, 'news', FILTER_SANITIZE_SPECIAL_CHARS);
     $author = Filter::filterInput(INPUT_POST, 'authorName', FILTER_UNSAFE_RAW);
     $email = Filter::filterInput(INPUT_POST, 'authorEmail', FILTER_VALIDATE_EMAIL);
     $active = Filter::filterInput(INPUT_POST, 'active', FILTER_UNSAFE_RAW);
     $comment = Filter::filterInput(INPUT_POST, 'comment', FILTER_UNSAFE_RAW);
-    $link = Filter::filterInput(INPUT_POST, 'link', FILTER_UNSAFE_RAW);
-    $linkTitle = Filter::filterInput(INPUT_POST, 'linkTitle', FILTER_UNSAFE_RAW);
+    $link = Filter::filterInput(INPUT_POST, 'link', FILTER_SANITIZE_SPECIAL_CHARS);
+    $linkTitle = Filter::filterInput(INPUT_POST, 'linkTitle', FILTER_SANITIZE_SPECIAL_CHARS);
     $newsLang = Filter::filterInput(INPUT_POST, 'langTo', FILTER_UNSAFE_RAW);
     $target = Filter::filterInput(INPUT_POST, 'target', FILTER_UNSAFE_RAW);
 

programming_language: PHP
filename: faq.php
change_type: ModificationType.MODIFY
diff: @@ -7,13 +7,13 @@
  * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  * obtain one at http://mozilla.org/MPL/2.0/.
  *
- * @package phpMyFAQ
- * @author Thorsten Rinne <thorsten@phpmyfaq.de>
- * @author Lars Tiedemann <larstiedemann@yahoo.de>
+ * @package   phpMyFAQ
+ * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
+ * @author    Lars Tiedemann <larstiedemann@yahoo.de>
  * @copyright 2002-2022 phpMyFAQ Team
- * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
- * @link https://www.phpmyfaq.de
- * @since 2002-08-27
+ * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
+ * @link      https://www.phpmyfaq.de
+ * @since     2002-08-27
  */
 
 use phpMyFAQ\Attachment\AttachmentException;
@@ -338,7 +338,7 @@ $template->parse(
         'baseHref' => $faqSystem->getSystemUri($faqConfig),
         'solutionId' => $faq->faqRecord['solution_id'],
         'solutionIdLink' => Link::getSystemRelativeUri() . '?solution_id=' . $faq->faqRecord['solution_id'],
-        'question' => $question,
+        'question' => Strings::htmlentities($question),
         'answer' => $answer,
         'faqDate' => $date->format($faq->faqRecord['date']),
         'faqAuthor' => $author,

programming_language: PHP
filename: index.php
change_type: ModificationType.MODIFY
diff: @@ -539,7 +539,7 @@ $tplMainPage = [
     'metaTitle' => Strings::htmlspecialchars(str_replace('"', '', $faqConfig->getTitle() . $title)),
     'metaDescription' => Strings::htmlspecialchars($metaDescription ?? ''),
     'metaKeywords' => Strings::htmlspecialchars($keywords),
-    'metaPublisher' => $faqConfig->get('main.metaPublisher'),
+    'metaPublisher' => Strings::htmlspecialchars($faqConfig->get('main.metaPublisher')),
     'metaLanguage' => $PMF_LANG['metaLanguage'],
     'metaRobots' => $faqSeo->getMetaRobots($action),
     'phpmyfaqversion' => $faqConfig->getVersion(),

programming_language: PHP
filename: news.php
change_type: ModificationType.MODIFY
diff: @@ -8,13 +8,13 @@
  * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  * obtain one at http://mozilla.org/MPL/2.0/.
  *
- * @package phpMyFAQ
- * @author Thorsten Rinne <thorsten@phpmyfaq.de>
- * @author Matteo Scaramuccia <matteo@scaramuccia.com>
+ * @package   phpMyFAQ
+ * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
+ * @author    Matteo Scaramuccia <matteo@scaramuccia.com>
  * @copyright 2006-2022 phpMyFAQ Team
- * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
- * @link https://www.phpmyfaq.de
- * @since 2006-07-23
+ * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
+ * @link      https://www.phpmyfaq.de
+ * @since     2006-07-23
  */
 
 use phpMyFAQ\Captcha;
@@ -25,6 +25,7 @@ use phpMyFAQ\Filter;
 use phpMyFAQ\Glossary;
 use phpMyFAQ\Helper\CaptchaHelper;
 use phpMyFAQ\News;
+use phpMyFAQ\Strings;
 use phpMyFAQ\User\CurrentUser;
 
 if (!defined('IS_VALID_PHPMYFAQ')) {
@@ -74,9 +75,9 @@ if (strlen($news['link']) > 0) {
     $newsContent .= sprintf(
         '</p><p>%s<a href="%s" target="%s">%s</a>',
         $PMF_LANG['msgInfo'],
-        $news['link'],
+        Strings::htmlentities($news['link']),
         $news['target'],
-        $news['linkTitle']
+        Strings::htmlentities($news['linkTitle'])
     );
 }
 
@@ -121,11 +122,11 @@ $template->parse(
     'mainPageContent',
     [
         'writeNewsHeader' => $newsMainHeader,
-        'writeHeader' => $newsHeader,
-        'mainPageContent' => $newsContent,
+        'writeHeader' => Strings::htmlentities($newsHeader),
+        'mainPageContent' => Strings::htmlentities($newsContent),
         'writeDateMsg' => $newsDate,
         'msgAboutThisNews' => $PMF_LANG['msgAboutThisNews'],
-        'writeAuthor' => ($news['active'] && (!$expired)) ? $PMF_LANG['msgAuthor'] . ': ' . $news['authorName'] : '',
+        'writeAuthor' => ($news['active'] && (!$expired)) ? $PMF_LANG['msgAuthor'] . ': ' . Strings::htmlentities($news['authorName']) : '',
         'editThisEntry' => $editThisEntry,
         'writeCommentMsg' => $commentMessage,
         'msgWriteComment' => $PMF_LANG['newsWriteComment'],

programming_language: PHP
filename: Bootstrap.php
change_type: ModificationType.MODIFY
diff: @@ -25,7 +25,7 @@ use phpMyFAQ\Init;
 // Debug mode:
 // - false debug mode disabled
 // - true  debug mode enabled
-const DEBUG = false;
+const DEBUG = true;
 if (DEBUG) {
     ini_set('display_errors', '1');
     ini_set('display_startup_errors', '1');

programming_language: PHP
filename: Category.php
change_type: ModificationType.MODIFY
diff: @@ -787,13 +787,13 @@ class Category
 
         $oLink = new Link($url, $this->config);
         $oLink->id = 'category_' . $categoryId;
-        $oLink->itemTitle = $categoryName;
-        $oLink->text = $categoryName;
+        $oLink->itemTitle = Strings::htmlentities($categoryName);
+        $oLink->text = Strings::htmlentities($categoryName);
 
         if ($hasChildren) {
             $oLink->text .= sprintf(
                 '<i aria-hidden="true" class="fa fa-caret-right" title="%s"></i>',
-                $categoryName
+                Strings::htmlentities($categoryName)
             );
         }
 
@@ -890,8 +890,8 @@ class Category
                 );
                 $oLink = new Link($url, $this->config);
                 $oLink->text = sprintf('<span>%s</span>', $category);
-                $oLink->itemTitle = $category;
-                $oLink->tooltip = $description[$key];
+                $oLink->itemTitle = Strings::htmlentities($category);
+                $oLink->tooltip = Strings::htmlentities($description[$key]);
                 if (0 === $key) {
                     $oLink->setRelation('index');
                 }

programming_language: PHP
filename: DatabaseHelper.php
change_type: ModificationType.MODIFY
diff: @@ -31,7 +31,7 @@ class DatabaseHelper
     /**
      * @var Configuration
      */
-    private $config;
+    private Configuration $config;
 
     /**
      * Constructor.

programming_language: PHP
filename: CategoryHelper.php
change_type: ModificationType.MODIFY
diff: @@ -241,9 +241,9 @@ class CategoryHelper extends Helper
                     $parent
                 );
                 $oLink = new Link($url, $this->config);
-                $oLink->itemTitle = $categoryName;
-                $oLink->text = $categoryName;
-                $oLink->tooltip = $description;
+                $oLink->itemTitle = Strings::htmlentities($categoryName);
+                $oLink->text = Strings::htmlentities($categoryName);
+                $oLink->tooltip = !is_null($description) ?? Strings::htmlentities($description);
 
                 $output .= $oLink->toHtmlAnchor();
                 $open = $level;
@@ -274,7 +274,7 @@ class CategoryHelper extends Helper
                 $categories .= sprintf(
                     '<li><a href="?action=show&cat=%d">%s</a></li>',
                     $cat['id'],
-                    $cat['name']
+                    Strings::htmlentities($cat['name'])
                 );
             }
         }
@@ -323,7 +323,7 @@ class CategoryHelper extends Helper
             }
 
             $categories .= '>';
-            $categories .= $indent . $cat['name'] . "</option>\n";
+            $categories .= $indent . Strings::htmlentities($cat['name']) . "</option>\n";
             ++$i;
         }
 
@@ -355,7 +355,7 @@ class CategoryHelper extends Helper
                 '<a href="' . Strings::htmlentities($category['url']) . '">' .
                 Strings::htmlentities($category['name']) . '</a>' .
                 '</h4>' .
-                '<p class="card-text">' . $category['description'] . '</p>' .
+                '<p class="card-text">' . Strings::htmlentities($category['description']) . '</p>' .
                 '</div>' .
                 '</div>';
             if ($key % 2 === 0) {
@@ -504,9 +504,9 @@ class CategoryHelper extends Helper
                 $parent
             );
             $oLink = new Link($url, $this->config);
-            $oLink->itemTitle = $categoryName;
-            $oLink->text = $categoryName;
-            $oLink->tooltip = $description;
+            $oLink->itemTitle = Strings::htmlentities($categoryName);
+            $oLink->text = Strings::htmlentities($categoryName);
+            $oLink->tooltip = !is_null($description) ?? Strings::htmlentities($description);
 
             $output .= $oLink->toHtmlAnchor() . $numFaqs;
             $open = $level;

programming_language: PHP
filename: FaqHelper.php
change_type: ModificationType.MODIFY
diff: @@ -163,12 +163,12 @@ class FaqHelper extends Helper
      * Creates an overview with all categories with their FAQs.
      *
      * @param Category $category
-     * @param Faq $faq
-     * @param string $language
+     * @param Faq      $faq
+     * @param string   $language
      * @return string
      * @throws Exception
      */
-    public function createOverview(Category $category, Faq $faq, $language = ''): string
+    public function createOverview(Category $category, Faq $faq, string $language = ''): string
     {
         global $PMF_LANG;
 
@@ -209,8 +209,8 @@ class FaqHelper extends Helper
      * Creates a list of links with available languages to edit a FAQ
      * in the admin backend.
      *
-     * @param  $faqId
-     * @param  $faqLang
+     * @param int    $faqId
+     * @param string $faqLang
      * @return string
      */
     public function createFaqTranslationLinkList(int $faqId, string $faqLang): string

programming_language: PHP
filename: QuestionHelper.php
change_type: ModificationType.MODIFY
diff: @@ -31,13 +31,13 @@ use phpMyFAQ\User;
 class QuestionHelper
 {
     /** @var Configuration */
-    private $config;
+    private Configuration $config;
 
     /** @var Category */
-    private $category;
+    private Category $category;
 
     /** @var array */
-    private $translation;
+    private array $translation;
 
     /**
      * QuestionHelper constructor.

programming_language: PHP
filename: TagsHelper.php
change_type: ModificationType.MODIFY
diff: @@ -7,8 +7,7 @@
  * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  * obtain one at http://mozilla.org/MPL/2.0/.
  *
- * @package    phpMyFAQ\Helper
- * @subpackage TagsHelper
+ * @package    phpMyFAQ
  * @author     Thorsten Rinne <thorsten@phpmyfaq.de>
  * @copyright  2013-2022 phpMyFAQ Team
  * @license    http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
@@ -20,6 +19,7 @@ namespace phpMyFAQ\Helper;
 
 use phpMyFAQ\Filter;
 use phpMyFAQ\Helper;
+use phpMyFAQ\Strings;
 
 /**
  * Class TagsHelper
@@ -32,7 +32,7 @@ class TagsHelper extends Helper
      *
      * @var array
      */
-    private $taggingIds;
+    private array $taggingIds;
 
     /**
      * Renders the tag list.
@@ -61,7 +61,7 @@ class TagsHelper extends Helper
      */
     public function renderSearchTag(int $tagId, string $tagName): string
     {
-        $taggingIds = str_replace($tagId, '', $this->getTaggingIds());
+        $taggingIds = str_replace((string) $tagId, '', $this->getTaggingIds());
         $taggingIds = str_replace(' ', '', $taggingIds);
         $taggingIds = str_replace(',,', ',', $taggingIds);
         $taggingIds = trim(implode(',', $taggingIds), ',');
@@ -70,11 +70,11 @@ class TagsHelper extends Helper
             '<a class="btn btn-primary m-1" href="?action=search&amp;tagging_id=%s">%s ' .
             '<i aria-hidden="true" class="fa fa-minus-square"></i></a> ',
             $taggingIds,
-            $tagName
+            Strings::htmlentities($tagName)
         ) : sprintf(
             '<a class="btn btn-primary m-1" href="?action=search&amp;search=">%s ' .
             '<i aria-hidden="true" class="fa fa-minus-square"></i></a> ',
-            $tagName
+            Strings::htmlentities($tagName)
         );
     }
 
@@ -83,7 +83,7 @@ class TagsHelper extends Helper
      *
      * @return array
      */
-    public function getTaggingIds()
+    public function getTaggingIds(): array
     {
         return $this->taggingIds;
     }
@@ -93,7 +93,7 @@ class TagsHelper extends Helper
      *
      * @param array $taggingIds The tag IDs as array
      */
-    public function setTaggingIds(array $taggingIds)
+    public function setTaggingIds(array $taggingIds): void
     {
         $this->taggingIds = array_filter($taggingIds, function ($tagId) {
             return Filter::filterVar($tagId, FILTER_VALIDATE_INT);
@@ -117,7 +117,7 @@ class TagsHelper extends Helper
             '<span class="badge badge-dark">%d</span></a>',
             implode(',', $this->getTaggingIds()) . ',' . $tagId,
             '<i aria-hidden="true" class="fa fa-plus-square"></i> ',
-            $tagName,
+            Strings::htmlentities($tagName),
             $relevance
         );
     }

programming_language: PHP
filename: News.php
change_type: ModificationType.MODIFY
diff: @@ -59,7 +59,7 @@ class News
      * @return string
      * @throws Exception
      */
-    public function getNews($showArchive = false, $active = true): string
+    public function getNews(bool $showArchive = false, bool $active = true): string
     {
         $output = '';
         $news = $this->getLatestData($showArchive, $active);
@@ -75,7 +75,7 @@ class News
             $oLink = new Link($url, $this->config);
 
             if (isset($item['header'])) {
-                $oLink->itemTitle = $item['header'];
+                $oLink->itemTitle = Strings::htmlentities($item['header']);
             }
 
             $output .= sprintf(
@@ -83,7 +83,7 @@ class News
                 ' class="pmf-news-heading"',
                 $item['id'],
                 $oLink->toString(),
-                $item['header']
+                Strings::htmlentities($item['header'])
             );
 
             $output .= sprintf('%s', $item['content']);
@@ -303,16 +303,16 @@ class News
             $this->config->getDb()->nextId(Database::getTablePrefix() . 'faqnews', 'id'),
             $data['date'],
             $data['lang'],
-            $data['header'],
-            $data['content'],
-            $data['authorName'],
+            $this->config->getDb()->escape($data['header']),
+            $this->config->getDb()->escape($data['content']),
+            $this->config->getDb()->escape($data['authorName']),
             $data['authorEmail'],
             $data['dateStart'],
             $data['dateEnd'],
             $data['active'],
             $data['comment'],
-            $data['link'],
-            $data['linkTitle'],
+            $this->config->getDb()->escape($data['link']),
+            $this->config->getDb()->escape($data['linkTitle']),
             $data['target']
         );
 
@@ -355,16 +355,16 @@ class News
             Database::getTablePrefix(),
             $data['date'],
             $data['lang'],
-            $data['header'],
-            $data['content'],
-            $data['authorName'],
+            $this->config->getDb()->escape($data['header']),
+            $this->config->getDb()->escape($data['content']),
+            $this->config->getDb()->escape($data['authorName']),
             $data['authorEmail'],
             $data['dateStart'],
             $data['dateEnd'],
             $data['active'],
             $data['comment'],
-            $data['link'],
-            $data['linkTitle'],
+            $this->config->getDb()->escape($data['link']),
+            $this->config->getDb()->escape($data['linkTitle']),
             $data['target'],
             $id
         );

programming_language: PHP
filename: Utils.php
change_type: ModificationType.MODIFY
diff: @@ -232,7 +232,7 @@ class Utils
     {
         // sometimes Zend Optimizer causes segfaults with debug_backtrace()
         if (extension_loaded('Zend Optimizer')) {
-            $ret = '<code>' . $string . "</code><br>\n";
+            $ret = '<code>' . Strings::htmlentities($string) . "</code><br>\n";
         } else {
             $debug = debug_backtrace();
             $ret = '';
@@ -240,7 +240,7 @@ class Utils
                 $ret = $debug[2]['file'] . ':<br>';
                 $ret .= $debug[2]['class'] . $debug[1]['type'];
                 $ret .= $debug[2]['function'] . '() in line ' . $debug[2]['line'];
-                $ret .= ': <code>' . $string . "</code><br>\n";
+                $ret .= ': <code>' . Strings::htmlentities($string) . "</code><br>\n";
             }
         }
 

programming_language: PHP
filename: startpage.php
change_type: ModificationType.MODIFY
diff: @@ -36,6 +36,7 @@ if (!is_null($archived)) {
 } else {
     $writeNewsHeader = ' ' . $PMF_LANG['msgNews'];
     $showAllNews = sprintf('<a href="?%snewsid=0">%s</a>', $sids, $PMF_LANG['newsShowArchive']);
+    $archived = false;
 }
 
 $startPageCategories = $category->getHomeCategories();

programming_language: PHP