Skip to content

Commit 8980f5e

Browse files
colinmollenhourmark-netalico
authored andcommitted
Merge pull request from GHSA-h632-p764-pjqm
Co-authored-by: Mark Lewis <[email protected]>
1 parent 0ef51ec commit 8980f5e

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

+6
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

+8-1
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,17 @@ public function read($filename, $dest = null)
457457
* @param int $mode
458458
*
459459
* @return int|boolean
460+
* @throws Exception
460461
*/
461462
public function write($filename, $src, $mode = null)
462463
{
463-
if (!$this->_isValidSource($src) || !$this->_isFilenameWriteable($filename)) {
464+
if (strpos($filename, chr(0)) !== false
465+
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $filename)
466+
) {
467+
throw new Exception('Detected malicious path or filename input.');
468+
}
469+
470+
if (!$this->_IsValidSource($src) || !$this->_isFilenameWriteable($filename)) {
464471
return false;
465472
}
466473

0 commit comments

Comments
 (0)