[Security] NoSQL Injection Vulnerability in Auth Controllers
Description:
While reviewing the authentication boilerplate generated by Celtrix (authController.js), I noticed that the login/signup logic trusts the email field directly from req.body without strict type validation (User.findOne({ email })).
Technical Details:
Because Express parses incoming JSON directly into objects, a user can pass a MongoDB query operator instead of a string. For example, if a user sends {"email": {"$gt": ""}, "password": "..."}, it bypasses the exact-match requirement. Mongoose interprets the operator object, resulting in a classic NoSQL Injection that can lead to authentication bypass in the apps developers are building with Celtrix.
Proposed Solution
Update the generated authentication templates
The fix implements a strict type-guard before the database query execution. By ensuring that the email and password inputs from req.body are strictly primitive strings, we prevent Express and Mongoose from parsing and executing malformed JSON objects (like {"$gt": ""}) as query operators.
Hey, @JoeCelaster I'm ready to work on this. Could you please assign this issue to me for GSSoC'26.
sure @afnan0304 , assigned !