Secure the file upload functionality
All core roles
Sitecore Installation Framework
File upload is not secure by default.
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.
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.
Open the Internet Information Services (IIS) manager.
Navigate to and click the upload folder for the relevant website, and then under the IIS section, double-click Handler Mappings.
In the Actions pane, click Edit Feature Permissions.
In the Edit Feature Permissions dialog box, clear the Script and Execute check boxes and click OK.
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
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"/>
Prevent a user from uploading certain file types
If you want to have complete control and prevent users from uploading certain file types, for example, .exe and .dll, you can use the Upload Filter tool.
Download and install the Upload Filter tool
The Upload Filter tool is a Sitecore package that you can download.
The Upload Filter tool contains the following files:
To install the Upload Filter tool:
On the Sitecore Launchpad, click Control Panel.
Under the Administration section, click Install a Package.
Follow the steps in the wizard to first download the package and then install it.
Configure the Upload Filter tool
After you install the Upload Filter tool, you must configure it.
To configure the Upload Filter tool:
<processors> <uiUpload> <processor mode="on" type="Sitecore.Pipelines.Upload.CheckExtension, Sitecore.UploadFilter" patch:before="*"> <param desc="Allowed extensions (comma separated)"></param> <param desc="Blocked extensions (comma separated)">exe,dll</param> </processor> </uiUpload> </processors>
To prevent users from uploading certain file types:
Allowed extensionsparameter, enter a comma-separated list of the file extension types that can be uploaded.
Blocked extensionsparameter, enter a comma-separated list of the file extension types that cannot be uploaded.
You must enter the file extension without the dot.Important
If you set the
Allowed extensionsparameter, the
Blocked extensionsparameter is ignored.
If you try to upload a file type that is on the blocked list, you see the following message:
After you install the Upload Filter tool, the Upload dialog can freeze if an error occurs during the upload process. This is a known issue for which there is a solution.