mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-26 03:52:23 -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.Boolean = Boolean;
|
||||||
data.Symbol = Symbol;
|
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
|
// Execute the expression
|
||||||
const returnValue = this.renderExpression(parameterValue, data);
|
const returnValue = this.renderExpression(parameterValue, data);
|
||||||
if (typeof returnValue === 'function') {
|
if (typeof returnValue === 'function') {
|
||||||
|
|
Loading…
Reference in a new issue