Skip to content

ReDoS vulnerability in email validation regex (Event.js) #111

@thedhanawada

Description

@thedhanawada

Security: Polynomial Regular Expression (ReDoS)

Source: GitHub Code Scanning alerts #6 and #7

Description

The email validation regex /^[^\s@]+@[^\s@]+\.[^\s@]+$/ used in two locations has overlapping character classes that cause polynomial (O(n^2)) backtracking on crafted input.

Affected Locations

  1. core/events/Event.js:153_validateAttendees() (constructor path)
  2. core/events/Event.js:923_isValidEmail() method

Attack Vector

Input like "user@" + "a".repeat(50) (no dot after @) forces the regex engine to try all possible splits between the second and third [^\s@]+ groups before failing. This creates O(n^2) backtracking that can hang the event loop.

Exploitable via:

  • ICS import with crafted attendee email
  • Direct API call to Event constructor with malicious attendee data

Fix

Replace with a non-backtracking pattern. The overlap is between [^\s@]+ before the . and [^\s@]+ after it — both can match the same characters.

// Option 1: Prevent overlap by excluding dot from middle group
const emailRegex = /^[^\s@]+@[^\s@.]+\.[^\s@]+$/;

// Option 2: Simpler pattern (sufficient for basic validation)
const emailRegex = /^[^\s@]+@[^\s@]+$/;

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    phase:0-foundationImmediate fixes and test infrastructurepriority:highImportant for next milestonetype:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions