Flowise: Unrestricted File Upload of JavaScript Allows RCE
Overview
Flowise versions prior to 3.1.0 are vulnerable to a critical file upload vulnerability. The application's chatflow configuration file upload mechanism can be manipulated to accept files with the `application/javascript` MIME type. While the frontend interface typically restricts JavaScript uploads, this bypass allows attackers to upload `.js` files to the server. These uploaded JavaScript files can function as persistent web shells, enabling an attacker to execute arbitrary Node.js code on the server. Successful exploitation could lead to complete compromise of the Flowise instance and any connected systems. The vulnerability stems from insufficient validation of the MIME type during the file upload process, allowing untrusted code execution and potential data exfiltration or system manipulation.
Affected Systems
Testing Guide
1. Access a Flowise instance running a version prior to 3.1.0. 2. Navigate to the chatflow creation or editing interface. 3. Attempt to upload a file with a `.js` extension. 4. Observe if the file is accepted by the server, especially if renaming the file to bypass simple extension checks. 5. If possible, craft a simple Node.js web shell and attempt to upload it by manipulating the request to include `application/javascript` as the MIME type. Confirm if the uploaded script can be accessed and executed.
Mitigation Steps
- Update Flowise to version 3.1.0 or later. - Implement strict server-side MIME type validation for all file uploads. - Restrict file upload directories to prevent execution of uploaded scripts. - Regularly review server logs for suspicious file upload activity. - Use an allowlist for permitted file extensions and MIME types.
Patch Details
3.1.0