Closed BaciHanma closed 9 months ago
After noticing a security hole in the file upload functionality, I thoroughly reviewed and updated the code to ensure a higher level of system security. Here are the main actions and changes made:
Changes and their purpose: Checking allowed file extensions:
I added an additional check for file extensions in addition to the already existing MIME type check. This ensures that only allowed image file formats (eg .png, .jpeg, .gif) are accepted. This step helps prevent malicious scripts from being loaded by bypassing file type checking. Filename Security Assurance:
I modified the filename generation logic to use only safe characters and a unique code, along with lowercase letters for the file extension. This helps prevent potential attacks that could be performed by manipulating file names. Double Check File Type:
I implemented both MIME type and file extension checking to double check that the uploaded file is indeed of an allowed type. This additional layer of security reduces the risk of restrictions being bypassed during the upload process. Code Optimization and Duplication Removal:
I removed unnecessary code duplication related to file inclusion (require_once) to reduce the chance of errors and improve code maintainability. Security Measures Results: These changes not only prevent malicious files from being uploaded to the system, but also increase the overall resistance of the application against various security threats. The file upload feature now carefully checks and validates each uploaded file, ensuring that only verified and safe files are accepted.
In addition, these updates improve system security by reducing the potential risk of malicious code execution and ensuring that the file upload process is controlled and secure. Thanks for the comments
After installation, log in to the backend using default account password tester/1234 Select core settings -> Settings Select upload file Intercept traffic packets, modify filename to a PHP file name suffix, and change the content to PHP code.
You can upload without authen:
view uploaded files execute php code correctly On line 52 of update_setting.php: It is not enough to filter file_types and file_size, you need to filter file_name and file_extensions