File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,6 +159,8 @@ function llxFooter()
159159$ type = 'application/octet-stream ' ;
160160if (GETPOST ('type ' , 'alpha ' )) $ type =GETPOST ('type ' , 'alpha ' );
161161else $ type =dol_mimetype ($ original_file );
162+ // Security: Force to octet-stream if file is a dangerous file
163+ if (preg_match ('/\.noexe$/i ' , $ original_file )) $ type = 'application/octet-stream ' ;
162164
163165// Security: Delete string ../ into $original_file
164166$ original_file = str_replace ("../ " , "/ " , $ original_file );
@@ -215,7 +217,7 @@ function llxFooter()
215217}
216218
217219// Security:
218- // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
220+ // We refuse directory transversal change and pipes in file names
219221if (preg_match ('/\.\./ ' , $ fullpath_original_file ) || preg_match ('/[<>|]/ ' , $ fullpath_original_file ))
220222{
221223 dol_syslog ("Refused to deliver file " .$ fullpath_original_file );
@@ -227,6 +229,7 @@ function llxFooter()
227229clearstatcache ();
228230
229231$ filename = basename ($ fullpath_original_file );
232+ $ filename = preg_replace ('/\.noexe$/i ' , '' , $ filename );
230233
231234// Output file on browser
232235dol_syslog ("document.php download $ fullpath_original_file filename= $ filename content-type= $ type " );
You can’t perform that action at this time.
0 commit comments