Skip to content

Commit 748b8ec

Browse files
authored
Update Readme.md
1 parent 31bd534 commit 748b8ec

File tree

1 file changed

+30
-1
lines changed
  • Wpt/Server Side vulnerability/NoSQL injection

1 file changed

+30
-1
lines changed

Wpt/Server Side vulnerability/NoSQL injection/Readme.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,33 @@ For URL-based inputs, you can insert query operators via URL parameters. For exa
168168
169169
> Note:
170170
>
171-
> You can use the [Content Type Converter](https://portswigger.net/bappstore/db57ecbe2cb7446292a94aa6181c9278) extension to automatically convert the request method and change a URL-encoded POST request to JSON.
171+
> You can use the [Content Type Converter](https://portswigger.net/bappstore/db57ecbe2cb7446292a94aa6181c9278) extension to automatically convert the request method and change a URL-encoded POST request to JSON.
172+
173+
## Detecting operator injection in MongoDB
174+
175+
Consider a vulnerable application that accepts a username and password in the body of a `POST` request:
176+
```
177+
{"username":"wiener","password":"peter"}
178+
```
179+
Test each input with a range of operators. For example, to test whether the username input processes the query operator, you could try the following injection:
180+
```
181+
{"username":{"$ne":"invalid"},"password":"peter"}
182+
```
183+
If the `$ne` operator is applied, this queries all users where the username is not equal to invalid.
184+
185+
If both the username and password inputs process the operator, it may be possible to bypass authentication using the following payload:
186+
```
187+
{"username":{"$ne":"invalid"},"password":{"$ne":"invalid"}}
188+
```
189+
This query returns all login credentials where both the username and password are not equal to invalid. As a result, you're logged into the application as the first user in the collection.
190+
191+
To target an account, you can construct a payload that includes a known username, or a username that you've guessed. For example:
192+
```
193+
{"username":{"$in":["admin","administrator","superadmin"]},"password":{"$ne":""}}
194+
```
195+
---
196+
| S.No | Name | Walkthrough |
197+
|--|--|--|
198+
| Lab 1 | [Exploiting NoSQL operator injection to bypass authentication](https://portswigger.net/web-security/nosql-injection/lab-nosql-injection-bypass-authentication) | [Link]() |
199+
200+
---

0 commit comments

Comments
 (0)