pressbooks / pressbooks

Open publishing. Open web. Open source.
https://pressbooks.org/
GNU General Public License v3.0
421 stars 133 forks source link

WordPress 'Upload File Types" setting for multisite not working correctly for Pressbooks #1803

Closed mcgratay closed 1 year ago

mcgratay commented 5 years ago

Description

Super admins should be able to whitelist file extensions across a whole network when that extension isn't already permitted by default. This prevents the "Sorry, this file type is not permitted for security reasons" notification that regular users receive when uploading disallowed file types.

This setting no longer works, and file extensions added and saved in the 'Upload file type' textbox are still banned across the network. Tested file types include:

Users report that nlogo file types were permitted when they began the project, but have since been resulting in the same security error.

Screen Shot 2019-10-15 at 11 36 32 AM

Relevant threads:

Steps to Reproduce

  1. Go to Network Admin > Settings > Network Settings and scroll to the 'Upload File Types' setting
  2. Add nlogo or another file extension not permitted on the network by default, then save changes
  3. Access the editor for a chapter, then click Add Media
  4. Drag a sample file of the file type you just whitelisted into the media drag and drop area
  5. See if an error appears

Expected behavior: Super admins can choose which file types are permitted network-wide

Actual behavior: Only WordPress default file types are permitted network-wide

dac514 commented 5 years ago

Would like to use this bug as an opportunity to better understand:

Particularly this claim:

Fixes issues related to #40175 that have been present since WordPress 4.7.1 https://core.trac.wordpress.org/ticket/40175

mcgratay commented 5 years ago

Additional file extensions to evaluate include:

SteelWagstaff commented 5 years ago

For the nlogo issue, there's a Unizin bedrock plugin that allows a few extra mime types: https://github.com/pressbooks/wisc-bedrock/blob/master/web/app/mu-plugins/unizin-allow-upload-extensions.php. Not sure if it's no longer installed or has stopped working or if the issue is something else altogether.

SteelWagstaff commented 5 years ago

Some context from the past: https://wpengine.com/support/non-image-upload-errors-wordpress-4-7-1/ + https://core.trac.wordpress.org/ticket/39550 + https://core.trac.wordpress.org/ticket/40175 (@greatislander was quite knowledgeable on these issues).

greatislander commented 5 years ago

Would be happy to chat about this at some point, @SteelWagstaff, @connerbw & @mcgratay. The underlying issue hasn't been fully resolved in WordPress core and there are also nuances in terms of how the network admin whitelist interacts with uploaded file validation.

dac514 commented 5 years ago

If "Lord of the files" is installed, and the Network Administrator wants to allow extra file extensions under Network Settings, and we can guess the mime type, then Upload File Types should work now.

Bonus: If SVGs have been enabled, "Lord of the files" will sanitize them at the upload stage to make sure they do not contain any dangerous exploits

LOTF can be installed on a network by running: composer require wpackagist-plugin/blob-mimes

It installs a debug menu that can only be seen by super-admins, or administrators (capability: manage_options)

lord-of-the-files-1 1

lord-of-the-files-1 2

dac514 commented 5 years ago

Related: https://github.com/Blobfolio/blob-mimes/issues/9