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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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