Browse Source

fix(core): Prevent theoretical polynomial regex attack

https://github.com/vendure-ecommerce/vendure/security/code-scanning/43
Michael Bromley 1 year ago
parent
commit
9f4a814fce
1 changed files with 5 additions and 0 deletions
  1. 5 0
      packages/core/src/common/utils.ts

+ 5 - 0
packages/core/src/common/utils.ts

@@ -76,6 +76,11 @@ export function normalizeEmailAddress(input: string): string {
  * identifiers for other authentication methods.
  */
 export function isEmailAddressLike(input: string): boolean {
+    if (input.length > 1000) {
+        // This limit is in place to prevent abuse via a polynomial-time regex attack
+        // See https://github.com/vendure-ecommerce/vendure/security/code-scanning/43
+        throw new Error('Input too long');
+    }
     return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input.trim());
 }