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:
Omar Ajoue
2022-09-20 10:41:37 +02:00
committed by GitHub
parent 479f78b3bc
commit a8030dbda5

View File

@@ -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') {