Secure the file upload functionality

Abstract

How to secure the upload folder, disable the upload watcher and prevent uploads of certain file types to Sitecore.

Applies to

All core roles

Sitecore Installation Framework

File upload is not secure by default.

Azure Toolkit

File upload is not secure by default.

You can strengthen the security of your Sitecore installation if you deny script and execute permissions for the upload folder.

Deny Script and Execute permissions for the upload folder

If you allow users to modify the content of the upload folder, you also give them the permissions to place scripts and executable programs in the folder. Executing these scripts and programs can cause an unexpected behavior on the server.

To avoid this, you can deny permissions to run scripts and executable files in the upload folder and thereby prevent an uploaded file from being executed on the server side when a user attempts to download it.

Note

You only need to perform this step if your configuration allows content authors to place files directly in the upload folder. For example, if you use a shared directory or FTP server, content authors can quickly place a lot of media in the media library.

For more information, see the Microsoft website.

To deny both Script and Execute permissions for the upload folder.

  1. Open the Internet Information Services (IIS) manager.

  2. Navigate to and click the upload folder for the relevant website, and then under the IIS section, double-click Handler Mappings.

    FEE1C21AA0144F8FAE53E56913F4CE2C.png
  3. In the Actions pane, click Edit Feature Permissions.

  4. In the Edit Feature Permissions dialog box, clear the Script and Execute check boxes and click OK.

    handler-mappings-21.png

If your configuration allows content authors to place files directly in the temp folder, for example, using a shared directory or an FTP server, you should also deny users Script and Execute permissions for the temp folder.

This also helps to avoid potential security problems, for example, if .aspx files are saved in the temp folder (for example, from custom code).

Disable the Upload Watcher

To ensure that the only way to upload files to Sitecore is from the Media Library, you should disable the Upload Watcher. This means that you can only upload files from within the Sitecore client and have control over the files that are uploaded.

When you disable the Upload Watcher, files that are placed in the upload folder are not automatically uploaded to the Media Library.

To disable the Upload Watcher:

  • Open the web.config file and remove the following string from the <system.webServer><modules> section:

<add type="Sitecore.Resources.Media.UploadWatcher,Sitecore.Kernel" name="SitecoreUploadWatcher"/>