Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit aeb47e5

Browse files
committed
SECURITY FIX: Only allow image file types by default.
This prevents remote code execution in Apache servers version 2.3.9+ with the default configuration (AllowOverride None). Since Apache version 2.3.9, .htaccess support is disabled by default: https://httpd.apache.org/docs/current/mod/core.html#allowoverride Without the configuration in the .htaccess file, allowing uploads of all file types allows remote code execution. Thanks to @lcashdol for reporting the vulnerability (Closes #3514).
1 parent 39607fd commit aeb47e5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

server/php/index.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,17 @@
1212

1313
error_reporting(E_ALL | E_STRICT);
1414
require('UploadHandler.php');
15-
$upload_handler = new UploadHandler();
15+
$upload_handler = new UploadHandler(array(
16+
17+
// SECURITY NOTICE:
18+
// Only change the accept_file_types setting after making sure that any
19+
// allowed file types cannot be executed by the webserver in the files
20+
// directory (e.g. PHP scripts), nor executed by the browser when downloaded
21+
// (e.g. HTML files with embedded JavaScript code).
22+
// e.g. in Apache, make sure the provided .htaccess file is present in the
23+
// files directory and .htaccess support has been enabled:
24+
// https://httpd.apache.org/docs/current/howto/htaccess.html
25+
26+
// By default, only allow file uploads with image file extensions:
27+
'accept_file_types' => '/\.(gif|jpe?g|png)$/i'
28+
));

0 commit comments

Comments
 (0)