Skip to content

Commit

Permalink
fix(core): Prevent theoretical polynomial regex attack
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Sep 18, 2024
1 parent 9516c71 commit 9f4a814
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit 9f4a814

Please sign in to comment.