CVE-2018-25086: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: A vulnerability was found in sea75300 FanPress CM up to 3.6.3. It has been classified as problematic. This affects the function getArticlesPreview of the file inc/controller/action/system/templatepreview.php of the component Template Preview. The manipulation leads to cross site scripting. It is possible to initiate the attack remotely. Upgrading to version 3.6.4 is able to address this issue. The patch is named c380d343c2107fcee55ab00eb8d189ce5e03369b. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-230235.
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: 2023-06-01T07:15Z
Repository: https://github.com/sea75300/fanpresscm3
Language: PHP
Files changed: inc/controller/action/system/help.php, inc/controller/action/system/templatepreview.php
Commit date: 2018-01-15 22:00:40 +0100
Commit message: * Bugfix: Hilfe wird unter PHP 7 nicht angezeigt
* Bugfix: Mögliche XSS-Lücke in Template-Vorschau
Diff: diff --git a/inc/controller/action/system/help.php b/inc/controller/action/system/help.php
index f043ebcc..c2dcc55a 100644
--- a/inc/controller/action/system/help.php
+++ b/inc/controller/action/system/help.php
@@ -43,16 +43,22 @@
          */
         public function process() {
             if (!parent::process()) return false;
 
             $contents = $this->cache->read();
-            if ($this->cache->isExpired() || !is_array($contents)) {
+            if (!is_array($contents)) {
+                $contents = [];
+            }
+
+            if ($this->cache->isExpired()) {
                 $xml = simplexml_load_string($this->lang->getHelp());
                 foreach ($xml->chapter as $chapter) {
                     $headline = trim($chapter->headline);
                     $contents[$headline] = trim($chapter->text);
-                }                
+                }
+                
+                $this->cache->write($contents, FPCM_LANGCACHE_TIMEOUT);
             }            
             
             $contents = $this->events->runEvent('extendHelp', $contents);
             $this->view->assign('chapters', $contents);
 
diff --git a/inc/controller/action/system/templatepreview.php b/inc/controller/action/system/templatepreview.php
index a49ff351..60987fae 100644
--- a/inc/controller/action/system/templatepreview.php
+++ b/inc/controller/action/system/templatepreview.php
@@ -60,10 +60,11 @@
          */
         public function process() {
             if (!parent::process()) return false;
 
             $this->template = $this->getTemplateById($this->tid);
+
             switch ($this->tid) {
                 case 1 :
                     $this->getArticlesPreview();
                     break;
                 case 2 :
@@ -154,11 +155,15 @@
                 '{{sources}}'                       => ''
             );
             $this->template->setReplacementTags($replacements);
             $parsed[] = $this->template->parse();
 
-            $this->view->assign('content', implode(PHP_EOL, $parsed));
+            $this->view->assign('content', str_replace(
+                ['<script>', '</script>'],
+                ['&lt;script_diabled_in_preview&gt;', '&lt;/script_diabled_in_preview&gt;'],
+                implode(PHP_EOL, $parsed))
+            );
             $this->view->assign('commentform', '');
 
         }
 
         private function getArticlePreview() {

Vulnerable code:             if ($this->cache->isExpired() || !is_array($contents)) {
                }                
            $this->view->assign('content', implode(PHP_EOL, $parsed));
Fixed code:             if (!is_array($contents)) {
                $contents = [];
            }

            if ($this->cache->isExpired()) {
                }
                
                $this->cache->write($contents, FPCM_LANGCACHE_TIMEOUT);

            $this->view->assign('content', str_replace(
                ['<script>', '</script>'],
                ['&lt;script_diabled_in_preview&gt;', '&lt;/script_diabled_in_preview&gt;'],
                implode(PHP_EOL, $parsed))
            );