MediaWiki allow ‘.exe’ files to be uploaded

January 22nd, 2020

This error surfaces when trying to upload exe files.

When trying to upload .exe files to a MediaWiki instance, this error will sometimes appear. This can happen even if its in your allowed file types array.

**Let me preface this post by saying, in general, it is not advisable to allow exe files to be uploaded for security reasons.

I have a privately hosted wiki for storing various files and code snippets for my personal use, and recently I attempted to upload an exe file and was met with the error message:

".exe" is not a permitted file type.

I already have mime checking disabled via

$wgVerifyMimeType = false;

and had ‘exe’ added in $wgFileExtensions.

Though again, this is not advisable unless you are the only one who will be accessing this MediaWiki instance.

As it turns out, some file types are blacklisted so that even if it’s added to the list of allowed extensions they will still not be uploaded.

To get around this, add the line

$wgFileBlacklist = array_diff($wgFileBlacklist, array('exe'));

to your LocalSettings.php

This works for other banned extensions such as .dll. To do DLL files, add this line instead:

$wgFileBlacklist = array_diff($wgFileBlacklist, array('dll'));

For both EXE and DLL, use this:

$wgFileBlacklist = array_diff($wgFileBlacklist, array('exe', 'dll'));

**Note: A MediaWiki update changed the syntax to:

$wgProhibitedFileExtensions = array_diff(
    [ 'exe', 'dll' ] 
$wgMimeTypeExclusions = array_diff(
    [ 'application/x-msdownload' ]

If the previous command did not work for you use the updated command above.


Leave a Reply

Your email address will not be published. Required fields are marked *