You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: external/ExtPrograms.csv
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ EmailValidator,3.2.6,github.com/egulias/EmailValidator,3.2.6/4.0.1,needed by swi
6
6
ups-php,0.2,github.com/sanbornm/ups-php,0.2,"updated/fixed xml, etc to work"
7
7
fedex-php,31.0.0,www.fedex.com/wpor/web/jsp/drclinks.jsp?links=wss/getstarted.html,31.0.0,copy/edit RateAvailableServicesWebServiceClient.php into fedexshippingcalculator->getRates()
8
8
Smarty,3.1.27/4.3.4,smarty.net,4.3.4,
9
-
phpthumb,1.7.21exp,github.com/JamesHeinrich/phpThumb,1.7.21,phpThumb.config.php - we also allow & in parsing and err command
9
+
phpthumb,1.7.22exp,github.com/JamesHeinrich/phpThumb,1.7.22,phpThumb.config.php - we also allow & in parsing and err command
Copy file name to clipboardExpand all lines: external/class.upload/README.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,10 +89,10 @@ Don't forget to add `enctype="multipart/form-data"` in your form tag `<form>` if
89
89
90
90
### Namespacing
91
91
92
-
The class is now namespaced in the `Verot/Upload` namespace. If you have the error *Fatal error: Class 'Upload' not found*, then make sure your file belongs to the namespace, or instantiate the class with its fully qualified name:
92
+
The class is now namespaced in the `Verot/Upload` namespace. If you have the error *Fatal error: Class 'Upload' not found*, then `use` the class fully qualified name, or instantiate the class with its fully qualified name:
93
93
94
94
```php
95
-
namespace Verot\Upload;
95
+
use Verot\Upload\Upload;
96
96
$handle = new Upload($_FILES['image_field']);
97
97
```
98
98
or
@@ -168,6 +168,23 @@ echo $handle->process();
168
168
die();
169
169
```
170
170
171
+
### Warning about security
172
+
173
+
By default, the class relies on MIME type detection to assess whether the file can be uploaded or not. Several MIME type detection methods are used, depending on the server configuration. The class relies on a blacklist of dangerous file extensions to prevent uploads (or to rename dangerous scripts as text files), as well as a whitelist of accepted MIME types.
174
+
175
+
But it is not the purpose of this class to do in-depth checking and heuristics to attempt to detect maliciously crafted files. For instance, an attacker can craft a file that will have the correct MIME type, but will carry a malicious payload, such as a valid GIF file which would contain some code leading to a XSS vulnerability. If this GIF file has a .html extension, it may be uploaded (depending on the class's settings) and display an XSS vulnerability.
176
+
177
+
However, you can mitigate this by restricting the kind of files that can be uploaded, using `allowed` and `forbidden`, to whitelist and blacklist files depending on their MIME type or extension. *The most secure option would be to only whitelist extensions that you want to allow through, and then making sure that your server always serves the file with the content-type based on the file extension.*
178
+
179
+
For instance, if you only want to allow one type of file, you could whitelist only its file extension. In the following example, only .html files are let through, and are not converted to a text file:
180
+
```php
181
+
$handle->allowed = array('html');
182
+
$handle->forbidden = array();
183
+
$handle->no_script = false;
184
+
```
185
+
186
+
In the end, it is your responsibility to make sure the correct files are uploaded. But more importantly, it is your responsibility to serve the uploaded files correctly, for instance by forcing the server to always provide the content-type based on the file extension.
0 commit comments