CVE-2022-4820: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: A vulnerability classified as problematic has been found in FlatPress. This affects an unknown part of the file admin/panels/entry/admin.entry.list.php of the component Admin Area. The manipulation leads to cross site scripting. It is possible to initiate the attack remotely. The name of the patch is 229752b51025e678370298284d42f8ebb231f67f. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-216999.
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-12-28T21:15Z
Repository: https://github.com/flatpressblog/flatpress
Language: PHP
Files changed: admin/panels/entry/admin.entry.list.php, admin/panels/entry/admin.entry.list.tpl
Commit date: 2022-12-25 20:32:55 +0100
Commit message: fixes #180, possible XSS in entry list

Diff: diff --git a/admin/panels/entry/admin.entry.list.php b/admin/panels/entry/admin.entry.list.php
index 98511325..d2d5e926 100755
--- a/admin/panels/entry/admin.entry.list.php
+++ b/admin/panels/entry/admin.entry.list.php
@@ -37,19 +37,21 @@ class admin_entry_list extends AdminPanelActionValidated {
 		// $smarty = $this->smarty;
 
 		// parameters for the list
 		// start offset and count (now defaults to 8...)
 
+		$this->smarty->assign('formtarget', strip_tags($_SERVER ['PHP_SELF']));
 		$this->smarty->assign('categories_all', entry_categories_get('defs'));
 		$this->smarty->assign('saved_flags', entry_flags_get());
 
 		$defcount = 8; // <-- no magic numbers! todo: add config option?
 
 		global $fpdb;
 
-		if (!empty($_REQUEST ['entry']))
+		if (!empty($_REQUEST ['entry'])) {
 			utils_redirect('admin.php?p=entry&action=write&entry=' . $_REQUEST ['entry']);
+		}
 
 		isset($_REQUEST ['m']) ? $params ['m'] = $_REQUEST ['m'] : null;
 		isset($_REQUEST ['y']) ? $params ['y'] = $_REQUEST ['y'] : null;
 		// $params['start'] = isset($_REQUEST['start'])? $_REQUEST['start'] : 0;
 		$params ['count'] = isset($_REQUEST ['count']) ? $_REQUEST ['count'] : $defcount;
diff --git a/admin/panels/entry/admin.entry.list.tpl b/admin/panels/entry/admin.entry.list.tpl
index 25a3e16d..52520ec5 100755
--- a/admin/panels/entry/admin.entry.list.tpl
+++ b/admin/panels/entry/admin.entry.list.tpl
@@ -23,11 +23,11 @@
 
 {include file="shared:errorlist.tpl"}
 
 <p>{$panelstrings.descr}</p>
 
-<form method="get" action="{$smarty.server.PHP_SELF}?p=entry">
+<form method="get" action="{$formtarget}?p=entry">
 <p> <input type="hidden" name="p" value="entry" /> </p>
 <fieldset><legend>{$panelstrings.filter}</legend>
 	<select name="category" class="alignleft">
 	<option label="{$lang.admin.entry.list.nofilter}" value="all">{$panelstrings.nofilter}</option>
 	{*html_options options=$lang.entry.flags.short selected=$smarty.request.cat*}

Vulnerable code: 		if (!empty($_REQUEST ['entry']))
<form method="get" action="{$smarty.server.PHP_SELF}?p=entry">
Fixed code: 		$this->smarty->assign('formtarget', strip_tags($_SERVER ['PHP_SELF']));
		if (!empty($_REQUEST ['entry'])) {
		}
<form method="get" action="{$formtarget}?p=entry">