Skip to content

Fix global query server crash when filter or validate throws null#5945

Open
vamsi2246 wants to merge 1 commit intoapache:mainfrom
vamsi2246:fix-second-js-bug
Open

Fix global query server crash when filter or validate throws null#5945
vamsi2246 wants to merge 1 commit intoapache:mainfrom
vamsi2246:fix-second-js-bug

Conversation

@vamsi2246
Copy link

Overview

This PR fixes a critical unhandled exception bug in the global query server event loop (loop.js).

Details

If a user document filter function throws null or undefined, the unhandled null bubbles up directly to handleError(e) in loop.js. This function immediately accesses e[0], throwing a TypeError: Cannot read properties of null. Because handleError has no error boundary of its own, this completely crashes the couchjs OS process, failing the query system.

A similar unsafe pattern exists in validate.js.

This patch adds explicit null checks to the global event handler, preventing arbitrary null exceptions from causing a full couchjs denial-of-service, ensuring they are properly returned as error messages over JSON instead.

When a filter or validate function throws null,
the global event loop in loop.js unsafely tries
to access its properties, crashing couchjs.
This adds safe null checks to the global handler
to prevent complete denial of service.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant