CVE-2022-35945: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: GLPI stands for Gestionnaire Libre de Parc Informatique and is a Free Asset and IT Management Software package, that provides ITIL Service Desk features, licenses tracking and software auditing. Information associated to registration key are not properly escaped in registration key configuration page. They can be used to steal a GLPI administrator cookie. Users are advised to upgrade to 10.0.3. There are no known workarounds for this issue. ### Workarounds Do not use a registration key created by an untrusted person.
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: 6.1
Published: 2022-09-14T18:15Z
Repository: https://github.com/glpi-project/glpi
Language: PHP
Files changed: src/GLPINetwork.php
Commit date: 2022-09-14 13:51:49 +0200
Commit message: Escape GLPI-Network registration information

Diff: diff --git a/src/GLPINetwork.php b/src/GLPINetwork.php
index d751b75aa42c..fdadaa2c0fbb 100644
--- a/src/GLPINetwork.php
+++ b/src/GLPINetwork.php
@@ -31,10 +31,11 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  *
  * ---------------------------------------------------------------------
  */
 
+use Glpi\Toolbox\Sanitizer;
 use Glpi\Toolbox\VersionParser;
 
 class GLPINetwork extends CommonGLPI
 {
     public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
@@ -103,24 +104,24 @@ class GLPINetwork extends CommonGLPI
                 echo "<tr class='tab_bg_2'>";
                 echo "<td></td>";
                 echo "<td>";
                 echo "<div class=' " . (($informations['is_valid'] && $informations['subscription']['is_running'] ?? false) ? 'ok' : 'red') . "'> ";
                 echo "<i class='fa fa-info-circle'></i>";
-                echo $informations['validation_message'];
+                echo Sanitizer::encodeHtmlSpecialChars($informations['validation_message']);
                 echo "</div>";
                 echo "</td>";
                 echo "</tr>";
             }
 
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . __('Subscription') . "</td>";
-            echo "<td>" . ($informations['subscription'] !== null ? $informations['subscription']['title'] : __('Unknown')) . "</td>";
+            echo "<td>" . ($informations['subscription'] !== null ? Sanitizer::encodeHtmlSpecialChars($informations['subscription']['title']) : __('Unknown')) . "</td>";
             echo "</tr>";
 
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . __('Registered by') . "</td>";
-            echo "<td>" . ($informations['owner'] !== null ? $informations['owner']['name'] : __('Unknown')) . "</td>";
+            echo "<td>" . ($informations['owner'] !== null ? Sanitizer::encodeHtmlSpecialChars($informations['owner']['name']) : __('Unknown')) . "</td>";
             echo "</tr>";
         }
 
         if ($canedit) {
             echo "<tr class='tab_bg_2'>";

Vulnerable code:                 echo $informations['validation_message'];
            echo "<td>" . ($informations['subscription'] !== null ? $informations['subscription']['title'] : __('Unknown')) . "</td>";
            echo "<td>" . ($informations['owner'] !== null ? $informations['owner']['name'] : __('Unknown')) . "</td>";
Fixed code: use Glpi\Toolbox\Sanitizer;
                echo Sanitizer::encodeHtmlSpecialChars($informations['validation_message']);
            echo "<td>" . ($informations['subscription'] !== null ? Sanitizer::encodeHtmlSpecialChars($informations['subscription']['title']) : __('Unknown')) . "</td>";
            echo "<td>" . ($informations['owner'] !== null ? Sanitizer::encodeHtmlSpecialChars($informations['owner']['name']) : __('Unknown')) . "</td>";