Skip to content

Commit

Permalink
fix(expression): prevent calls to constructor to forbid arbitrary cod…
Browse files Browse the repository at this point in the history
…e execution (n8n-io#4139)

* fix(expression): prevent calls to constructor to forbid arbitrary code execution
  • Loading branch information
krynble authored Sep 20, 2022
1 parent 32d604d commit fff9b5e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/workflow/src/Expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit fff9b5e

Please sign in to comment.