CVE-2022-4642: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: A vulnerability was found in tatoeba2. It has been classified as problematic. This affects an unknown part of the component Profile Name Handler. The manipulation leads to cross site scripting. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used. Upgrading to version prod_2022-10-30 is able to address this issue. The name of the patch is 91110777fc8ddf1b4a2cf4e66e67db69b9700361. It is recommended to upgrade the affected component. The identifier VDB-216501 was assigned to this vulnerability.
CWE 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.
CVSS v3 base score: 5.4
Published: 2022-12-21T22:15Z
Repository: https://github.com/Tatoeba/tatoeba2
Language: Other
Files changed: src/Template/Email/html/new_private_message.ctp, src/Template/PrivateMessages/folder.ctp, src/Template/PrivateMessages/show.ctp
Commit date: 2022-10-30 12:29:41 +0100
Commit message: Sanitize private message title

This fixes an XSS vulnerability.

Refs #3002

Diff: diff --git a/src/Template/Email/html/new_private_message.ctp b/src/Template/Email/html/new_private_message.ctp
index 30f3a784f..968c8bf75 100644
--- a/src/Template/Email/html/new_private_message.ctp
+++ b/src/Template/Email/html/new_private_message.ctp
@@ -1,10 +1,10 @@
 <?php
 echo $this->Html->tag("p", "You have received a private message from <strong>$sender</strong>.");
 
 echo $this->Html->div(null,
-    "<strong>Title:</strong> $title",
+    "<strong>Title:</strong> ".h($title),
     array('style' => 'background:#666666;color:#ffffff;padding:10px;')
 );
 
 echo $this->Html->div(null,
     $this->Messages->formatContent($message),
diff --git a/src/Template/PrivateMessages/folder.ctp b/src/Template/PrivateMessages/folder.ctp
index 0d024470b..180382ac2 100644
--- a/src/Template/PrivateMessages/folder.ctp
+++ b/src/Template/PrivateMessages/folder.ctp
@@ -136,11 +136,11 @@ $this->set('title_for_layout', $this->Pages->formatTitle(
                 ]);
                 ?>
                 <md-list-item class="md-2-line <?= $unread ?>" href="<?= $url ?>">
                     <?= $this->Members->image($user, array('class' => 'md-avatar')); ?>
                     <div class="md-list-item-text" layout="column">
-                        <h3><?= $this->safeForAngular($messageTitle) ?></h3>
+                        <h3><?= h($this->safeForAngular($messageTitle)) ?></h3>
                         <p>
                         <?php
                         echo $label;
                         echo ', ';
                         echo $this->Date->ago($msg->date);
diff --git a/src/Template/PrivateMessages/show.ctp b/src/Template/PrivateMessages/show.ctp
index 5339c5bb0..2ab81cc46 100644
--- a/src/Template/PrivateMessages/show.ctp
+++ b/src/Template/PrivateMessages/show.ctp
@@ -52,11 +52,11 @@ $this->set('title_for_layout', $this->Pages->formatTitle(
 
     <md-content class="md-whiteframe-1dp" flex>
         <md-toolbar class="md-hue-1">
             <div class="md-toolbar-tools">
                 <h2 flex>
-                    <?= $this->safeForAngular($message->title) ?>
+                    <?= h($this->safeForAngular($message->title)) ?>
                 </h2>
             </div>
         </md-toolbar>
         <?php
         $author = $message->author;

Vulnerable code:     "<strong>Title:</strong> $title",
                        <h3><?= $this->safeForAngular($messageTitle) ?></h3>
                    <?= $this->safeForAngular($message->title) ?>
Fixed code:     "<strong>Title:</strong> ".h($title),
                        <h3><?= h($this->safeForAngular($messageTitle)) ?></h3>
                    <?= h($this->safeForAngular($message->title)) ?>