Skip to content

Commit a082d54

Browse files
committed
fix(@angular-devkit/build-angular): limit error message length to are passed to RegExp.
Webpack errors can sometimes be several hundred of thousands of characters long as it may contain the entire bundle. This can cause a ReDoS, this change limits the message that is passed to the RegExp to 2000 characters. Closes angular#24771
1 parent 6335cf9 commit a082d54

File tree

1 file changed

+1
-1
lines changed
  • packages/angular_devkit/build_angular/src/webpack/utils

1 file changed

+1
-1
lines changed

packages/angular_devkit/build_angular/src/webpack/utils/stats.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export function statsErrorsToString(
414414
// See: https://github.com/webpack/webpack/issues/15980
415415
const message = statsConfig.errorStack
416416
? error.message
417-
: /[\s\S]+?(?=\n+\s+at\s)/.exec(error.message)?.[0] ?? error.message;
417+
: /[\s\S]+?(?=\n+\s+at\s)/.exec(error.message.substring(0, 2000))?.[0] ?? error.message;
418418

419419
if (!/^error/i.test(message)) {
420420
output += r('Error: ');

0 commit comments

Comments
 (0)