Home / Learn Secure SQL / NoSQL Injection: the Same Idea, a Different Query Language
NoSQL Injection: the Same Idea, a Different Query Language
The code/data separation problem is not unique to SQL.
How to think about this
What it is
NoSQL databases (document stores, key-value stores, and others) have their own query languages or query-object structures, and the same core problem — a query's structure being influenced by untrusted input rather than only its values — can occur there too, in whatever form that specific database's query language takes.
Why it matters
This lesson matters for teams using a mixed stack (a relational database alongside a NoSQL one): the specific syntax differs entirely, but the underlying discipline (never let untrusted input shape a query's structure, always use that database's safe parameter-passing mechanism) is the same lesson, applied to a different technology.
Mechanically speaking
For any NoSQL database in your stack, learn that specific database's recommended safe query-construction mechanism (most provide one), and apply the same code-review discipline to it that this course has applied to SQL throughout.
Shows up in
- Web application code review
- Backend development
- Database administration
// Safe: username is treated purely as a value to match
db.collection('users').find({ username: username });
// Most NoSQL drivers provide an explicit, safe way to pass values;
// consult your specific driver's documentation for its recommended pattern.This course is scoped to relational/SQL databases, but the underlying principle generalizes: whatever query language you use, untrusted input must never be allowed to shape the query's structure, only its values.
Check yourself
1. NoSQL injection is best understood as...
The underlying principle is the same across query languages.