mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(expression): prevent calls to constructor to forbid arbitrary code execution (#4139)
* fix(expression): prevent calls to constructor to forbid arbitrary code execution
This commit is contained in:
parent
479f78b3bc
commit
a8030dbda5
|
@ -249,6 +249,15 @@ export class Expression {
|
|||
data.Boolean = Boolean;
|
||||
data.Symbol = Symbol;
|
||||
|
||||
const constructorValidation = new RegExp(/\.\s*constructor/gm);
|
||||
if (parameterValue.match(constructorValidation)) {
|
||||
throw new ExpressionError('Expression contains invalid constructor function call', {
|
||||
causeDetailed: 'Constructor override attempt is not allowed due to security concerns',
|
||||
runIndex,
|
||||
itemIndex,
|
||||
});
|
||||
}
|
||||
|
||||
// Execute the expression
|
||||
const returnValue = this.renderExpression(parameterValue, data);
|
||||
if (typeof returnValue === 'function') {
|
||||
|
|
Loading…
Reference in a new issue