Skip to content

Commit d16fc6c

Browse files
Merge pull request from GHSA-h632-p764-pjqm
Co-authored-by: Mark Lewis <[email protected]>
1 parent 45330ff commit d16fc6c

File tree

2 files changed

+14
-1
lines changed
  • app/code/core/Mage/Catalog/Model/Product/Attribute/Backend
  • lib/Varien/Io

2 files changed

+14
-1
lines changed

app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ public function addImage(
276276
$move = false,
277277
$exclude = true
278278
) {
279+
if (strpos($file, chr(0)) !== false
280+
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $file)
281+
) {
282+
throw new Exception('Detected malicious path or filename input.');
283+
}
284+
279285
$file = realpath($file);
280286

281287
if (!$file || !file_exists($file)) {

lib/Varien/Io/File.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,17 @@ public function read($filename, $dest = null)
484484
* @param int $mode
485485
*
486486
* @return int|boolean
487+
* @throws Exception
487488
*/
488489
public function write($filename, $src, $mode = null)
489490
{
490-
if (!$this->_isValidSource($src) || !$this->_isFilenameWriteable($filename)) {
491+
if (strpos($filename, chr(0)) !== false
492+
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $filename)
493+
) {
494+
throw new Exception('Detected malicious path or filename input.');
495+
}
496+
497+
if (!$this->_IsValidSource($src) || !$this->_isFilenameWriteable($filename)) {
491498
return false;
492499
}
493500

0 commit comments

Comments
 (0)