The vulnerability exists because Parse Server's LiveQuery feature did not properly handle invalid regular expressions supplied by a client during subscription. The root cause is twofold: first, the server accepted and stored subscriptions containing malformed regex patterns without validation. Second, when a database event triggered a subscription match, the code that executed the regex would throw an uncaught exception if the pattern was invalid, crashing the entire server process.
The analysis of the patch commits reveals the key functions involved. The vulnerability is initiated in the 'subscribe' event handler within ParseLiveQueryServer._onConnect, which formerly lacked validation. The patch introduces a new function, _validateQueryConstraints, to reject invalid queries at subscription time.
The actual crash occurred within the safeRegexTest function in QueryTools.js. This function would re-throw exceptions from the RegExp constructor, leading to a process termination. The patch modifies safeRegexTest to catch these exceptions and return false instead of crashing.
As a further safeguard, the calls to ParseLiveQueryServer._matchesSubscription (which triggers the regex matching) within the _onAfterSave and _onAfterDelete event handlers were wrapped in try-catch blocks. This ensures that even if an invalid regex somehow made it into the system, it would not cause a denial of service. Therefore, these three functions are the critical points in the execution flow of this vulnerability.