In SQL, quotes change grammar. In document databases, types and operators change the query. If the parser accepts an object where it expected a string, the attacker can supply an operator.
The login passes JSON directly into a document query. A password object such as `{"$ne": null}` means not equal to null, which is true for the admin password, so the check is bypassed.
- Inspect the login request format
- Send an operator instead of a string
- Reach the admin console and capture the flag
JSON value type to query operator
Where to look before you type a payload
The API accepts JSON or a query-string syntax that can express nested objects and operators.
The handler places client input into a document query, sometimes after string interpolation.
The database treats a key beginning with $ as an operator rather than a literal field value.
The operator changes the predicate, often matching the first or every document.
Open one hint at a time. The first two build the model; the last two point at the boundary.
Hint 1
Inspect the login content type.
Hint 2
Send an object instead of a string.
Hint 3
The login accepts JSON. Replace the password string with {"$ne":null}.
Hint 4 · near the answer
Log in as admin and capture the flag.
Observe → Hypothesize → Test → Prove → Explain
This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.
Evidence log
Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.
Preview the evidence report
# Lab evidence report — Message Match - Family: NoSQL Injection - Lab ID: web-nosql-message - Date: 2026-12-05 ## Workflow ### Observe - [ ] Open "Message Match" and record /login, the HTTP method and the role you are given. - [ ] List every parameter, header, cookie and object identifier the normal flow exposes. - [ ] Save a baseline response: status, body shape, timing and the fields that change by user. ### Hypothesize - [ ] Name the server decision that protects /login, and the evidence it should use. - [ ] Use the clue as a constraint, not an answer: The login accepts JSON. Try a password object with $ne: null. - [ ] Predict the exact status, body or state change that would prove the decision is missing. ### Test - [ ] Start from the baseline and change one value: the password value type. - [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result. - [ ] Capture the full request and response for the winning attempt, including the flag. ### Prove - [ ] Capture the flag and name the exact foreign object, role or state change it proves. - [ ] Repeat from a clean session and confirm the result is not cached or stale. - [ ] State impact precisely: what data or action did you actually obtain? ### Explain - [ ] State the root cause without naming the payload: which decision failed? - [ ] Name the control that prevents recurrence and the layer where it belongs. - [ ] Write one regression test that fails before the fix and passes after it. ## Evidence ### Target and baseline _Not recorded._ ### Hypothesis _Not recorded._ ### Winning request _Not recorded._ ### Proof _Not recorded._ ### Root cause _Not recorded._ ### Control and regression test _Not recorded._ ## Analyst conclusion The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.
False positives to rule out
- A JSON body is accepted but the password field is cast to a string: test whether the cast rejects or stringifies the object.
- A 500 error follows an operator: it may be a parser error rather than a successful injection; confirm with a controlled boolean or timing test.
- The UI sends a string: the API may still accept JSON with a different content type.
Regression tests to name
- Operator in login: The schema rejects the request and no user is returned
- Nested filter: The server rejects operator keys or maps only allowlisted fields
- Content type: The handler enforces the same scalar validation
- Validate types and reject objects where scalars are expected.
- Strip or reject query operators from user input.
- Use a schema and parameterized query builders.
الحقن ليس محصورًا في SQL؛ تغيير نوع القيمة قد يتجاوز الفحص.