No Code Attached Yet
avatar toivo
toivo
14 Jan 2022

Steps to reproduce the issue

Code review of libraries/src/Helper/MediaHelper.php lines 243 - 252

		// Media file names should never have executable extensions buried in them.
		$executables = array_merge(self::EXECUTABLES, InputFilter::FORBIDDEN_FILE_EXTENSIONS);

		// Remove allowed executables from array
		if (count($allowedExecutables))
		{
			$executable = array_diff($executables, $allowedExecutables);
		}

		$check = array_intersect($filetypes, $executables);

Line 249 should be:

			$executables = array_diff($executables, $allowedExecutables);

Additional comments

Compare the above to MediaHelper::checkFileExtension in lines 177 to 183:

		// Remove allowed executables from array
		if (count($allowedExecutables))
		{
			$executables = array_diff($executables, $allowedExecutables);
		}

		if (in_array($extension, $executables, true))

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
3.00

avatar toivo toivo - open - 14 Jan 2022
avatar toivo toivo - change - 14 Jan 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 14 Jan 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Jan 2022
avatar richard67
richard67 - comment - 14 Jan 2022

Line 249 should be:
$executables = array_diff($executables, $allowedExecutables);

From reading code I'd say you are right.

avatar akshitrattan
akshitrattan - comment - 15 Jan 2022

after going through the entire file I too think that line 249 should be changed
However, when I upload a restricted file type( E.g.- I tried uploading an SVG image, which is a restricted file type), considering this code snippet, I should not get an error, but I still get an error that I can't upload the file type
Can anyone explain to me why this happens?

avatar brianteeman
brianteeman - comment - 15 Jan 2022

@akshitrattan restricted file type and executable files are completely different things

avatar akshitrattan
akshitrattan - comment - 15 Jan 2022

@akshitrattan restricted file type and executable files are completely different things

oh, so as in a file like .exe??

avatar brianteeman
brianteeman - comment - 15 Jan 2022

/**
* A special list of blocked executable extensions, skipping executables that are
* typically executable in the webserver context as those are fetched from
* Joomla\CMS\Filter\InputFilter
*
* @var string[]
* @since 4.0.0
*/
public const EXECUTABLES = array(
'js', 'exe', 'dll', 'go', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta',
'ins', 'isp', 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb',
'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh', 'html', 'htm', 'msi'
);

avatar akshitrattan
akshitrattan - comment - 15 Jan 2022

/**
* A special list of blocked executable extensions, skipping executables that are
* typically executable in the webserver context as those are fetched from
* Joomla\CMS\Filter\InputFilter
*
* @var string[]
* @since 4.0.0
*/
public const EXECUTABLES = array(
'js', 'exe', 'dll', 'go', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta',
'ins', 'isp', 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb',
'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh', 'html', 'htm', 'msi'
);

thanks a lot, now I'm familiar with the exact meaning of the term

avatar richard67
richard67 - comment - 15 Jan 2022

Who wants to make a pull request to fix that? I think the main challenge is to find good testing instructions for a real human test. As far as I can see there are no unit tests for the media helper yet, so I think it needs some kind of human test to make sure nothing is broken.

avatar akshitrattan
akshitrattan - comment - 15 Jan 2022

Who wants to make a pull request to fix that? I think the main challenge is to find good testing instructions for a real human test. As far as I can see there are no unit tests for the media helper yet, so I think it needs some kind of human test to make sure nothing is broken.

i'll make a PR

avatar richard67 richard67 - close - 15 Jan 2022
avatar richard67
richard67 - comment - 15 Jan 2022

Closing as having a pull request. Please test #36695 . Thanks in advance.

avatar richard67 richard67 - change - 15 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-15 13:31:23
Closed_By richard67

Add a Comment

Login with GitHub to post a comment