Remote Code Execution via Custom JS Function in Flowise
Flowise's Custom JS Function sandbox allows any module listed in the TOOL_FUNCTION_BUILTIN_DEP environment variable to be required inside the NodeVM sandbox. When an administrator follows the sample configuration that includes fs, an authenticated user who can create a chatflow can read arbitrary files, extract secrets, and access the database.
medium.com
Published on medium.com
During a security review of Flowise v3.1.1, I identified a path that allows authenticated users capable of creating chatflows to achieve arbitrary server-side code execution when dangerous Node.js built-in modules are exposed through the TOOLFUNCTIONBUILTINDEP configuration option.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code appends any module named in the TOOL_FUNCTION_BUILTIN_DEP environment variable directly to the NodeVM allowlist without validation or capability reduction, so the sandbox's security depends entirely on which modules are exposed.
Impact
An authenticated user who can create chatflows could read arbitrary files, extract encryption keys and session secrets, access the database, and execute operating system commands when dangerous modules are exposed; the vendor classified this as working as intended because the modules are not enabled by default.
What the attacker needed
Authenticated user able to create chatflows; administrator sets TOOL_FUNCTION_BUILTIN_DEP to include fs…
The fix
The vendor did not treat this as a vulnerability to fix, but agreed that the example configuration should not encourage enabling dangerous modules such as fs and indicated documentation improvements would be made.
How it was found
- Deploy Flowise with the TOOL_FUNCTION_BUILTIN_DEP environment variable set to include fs.
- Log in to the Flowise UI and complete the initial organisation setup.
- Create a chatflow and add a Custom JS Function node, selecting Ending Node as the output.
- Paste JavaScript that uses require('fs') to read files and return their contents.
- Save the chatflow, then send any message to trigger execution and receive the file contents in the chat response.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Flowise lets people build chatflows that can run small pieces of JavaScript. Normally the code runs in a restricted box (a sandbox) that cannot touch the server's files. But if the administrator turns on extra Node.js modules like fs (file system), the box is no longer restrictive, and anyone allowed to build a chatflow can read server files and secrets.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.