Skip to content
SQL injection Write-up Beginner

Authentication Bypass: NOSQL Injection on Buggy Buy’s Login

The login form was vulnerable to NoSQL injection because user input was passed directly into a MongoDB query. An attacker could bypass authentication by sending a JSON object with operators that make the query always true, logging in without valid credentials.

medium.com

Published on medium.com

Have you ever though how attackers bypass the login forms without knowing the actual credentials? Yes, because of the NOSQL injection.

Muniza Badar, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application inserted user-supplied JSON objects directly into the MongoDB query without validating or sanitising them, allowing query operators to alter the logic.

Impact

An attacker could log in without valid credentials, gaining access to the application as any user.

What the attacker needed

Access to the login page; ability to intercept HTTP requests

The fix

The application should validate and sanitise all input, avoid directly inserting user input into database queries, and use libraries that auto-sanitise or strict request schemas.

How it was found

  1. Start Burp Suite and turn on intercept.
  2. Open the Buggy Buy login page and sign in with any false credentials.
  3. Capture the HTTP POST request in Burp Suite.
  4. Send the request to Repeater and replace the email and password values with a NoSQL injection payload.
  5. Send the request and observe a 200 OK response, indicating successful login without valid credentials.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

NoSQL databases like MongoDB store data in flexible documents and often accept JSON-like input. If a website puts user input straight into a database query, an attacker can send special operators (like '$ne' meaning 'not equal') instead of a normal value. This can make the query match any user, so the login succeeds without a real password.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.