Skip to content

Commit 8430a4d

Browse files
committed
AC-1843: Fixed path traversal issue for error reporting
1 parent 031fe7e commit 8430a4d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pub/errors/default/page.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
// phpcs:ignoreFile
68
?>
79
<!doctype html>
810
<html xmlns="http://www.w3.org/1999/xhtml" >
911
<head>
1012
<title><?= $this->pageTitle ?></title>
11-
<base href="<?= $this->getViewFileUrl() ?>" />
13+
<base href="<?= $this->escaper->escapeHtml($this->getViewFileUrl()) ?>" />
1214
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1315
<meta name="robots" content="*"/>
1416
<link rel="stylesheet" href="css/styles.css" type="text/css" />

pub/errors/processor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function getViewFileUrl()
270270
$errorPath = strpos($errorDir, $indexDir) === 0 ?
271271
str_replace($indexDir, '', $errorDir) : $errorPathSuffix;
272272

273-
return $this->getBaseUrl() . $errorPath . $this->_config->skin . '/';
273+
return ltrim($this->getBaseUrl() . $errorPath . $this->_config->skin . '/','.');
274274
}
275275

276276
/**
@@ -595,7 +595,7 @@ private function redirectToBaseUrl()
595595
*/
596596
private function isReportIdValid(string $reportId): bool
597597
{
598-
return (bool)preg_match('/[a-fA-F0-9]{64}/', $reportId);
598+
return (bool)preg_match('/^[a-fA-F0-9]{64}$/', $reportId);
599599
}
600600

601601
/**

0 commit comments

Comments
 (0)