Headline
CVE-2021-4271: Add Markdown sanitization to close XSS vulnerability; credit to Marku… · panicsteve/w2wiki@8f1d047
A vulnerability was found in panicsteve w2wiki. It has been rated as problematic. Affected by this issue is the function toHTML of the file index.php of the component Markdown Handler. The manipulation leads to cross site scripting. The attack may be launched remotely. The name of the patch is 8f1d0470b4ddb1c7699e3308e765c11ed29542b6. It is recommended to apply a patch to fix this issue. The identifier of this vulnerability is VDB-216476.
@@ -82,6 +82,24 @@
// Support functions
function _handle_links($match)
{
return “<a href=\"” . SELF . VIEW . “/” . htmlentities($match[1]) . “\">” . htmlentities($match[1]) . "</a>";
}
function _handle_images($match)
{
return “<img src=\"” . BASE_URI . “/images/” . htmlentities($match[1]) . “\” alt=\"" . htmlentities($match[1]) . “\” />";
}
function _handle_message($match)
{
return "[<a href=\"message:" . htmlentities($match[1]) . "\">email</a>]";
}
function printToolbar()
{
global $upage, $page, $action;
@@ -149,9 +167,9 @@ function toHTML($inText)
}
}
$inText = preg_replace("/\[\[(.*?)\]\]/", “<a href=\"” . SELF . VIEW . "/\\1\">\\1</a>", $inText);
$inText = preg_replace(“/\{\{(.*?)\}\}/", “<img src=\"” . BASE_URI . “/images/\\1\” alt=\"\\1\” />", $inText);
$inText = preg_replace("/message:(.*?)\s/", "[<a href=\"message:\\1\">email</a>]", $inText);
$inText = preg_replace_callback("/\[\[(.*?)\]\]/", '_handle_links’, $inText);
$inText = preg_replace_callback("/\{\{(.*?)\}\}/", '_handle_images’, $inText);
$inText = preg_replace_callback("/message:(.*?)\s/", '_handle_message’, $inText);
$html = MarkdownExtra::defaultTransform($inText);
$inText = htmlentities($inText);