> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/web/nosql-injection/detection-of-nosql-injection.md).

# Detección de inyección NoSQL

### Detección de inyección NoSQL

**Objetivo del laboratorio**

Este laboratorio contiene una aplicación de comercio electrónico cuyo filtro de categorías se basa en una base de datos **MongoDB (NoSQL)**. / Una vulnerabilidad de inyección NoSQL te permite mostrar **productos no publicados**.

El objetivo es explotar esta vulnerabilidad para forzar a la aplicación a devolver todos los productos, incluidos aquellos que no deberían ser visibles.

**Contexto de la aplicación**

* Página de comercio electrónico con un filtro por categoría.
* Ejemplo de solicitud normal

```bash
filter?category=Accessories
```

<figure><img src="/files/5e145c6b9584f08e889049006c8cb6dded2dea68" alt=""><figcaption></figcaption></figure>

**Identificación de la vulnerabilidad**

Al añadir una **apóstrofo** al final del `category` parámetro, el servidor devuelve un error interno:

```bash
Error interno del servidor
El comando falló con el error 139 (JSInterpreterFailure):
SyntaxError: literal de cadena sin terminar....
```

<figure><img src="/files/697d871804543247212c6e24f8f99c1bd1296d41" alt=""><figcaption></figcaption></figure>

Este error revela varios elementos importantes:

* El backend usa **MongoDB**.
* Las entradas del usuario se interpretan en un **JavaScript** contexto del lado de la base de datos.
* La aplicación es vulnerable a la inyección \*\*NoSQL\*\*.

**Explotación de inyección NoSQL**

El objetivo es manipular la condición utilizada en la solicitud de MongoDB para que sea siempre verdadera.

Ejemplos de cargas útiles probadas:

```sql
' || 1==1 || '
' || true || '
' && 0 && '
```

Estas expresiones fuerzan que la condición sea verdadera, lo que provoca la visualización de \*\*todos los productos\*\*, incluidos los no publicados

<figure><img src="/files/5532abd0a6a8f94160d417ed7f1d4c45702ddadf" alt=""><figcaption></figcaption></figure>

#### Cargas útiles no funcionales (para comparación)

```sql
' && 0 && '
' || 1==2 || '
```

Estas condiciones se evalúan como falsas y no devuelven ningún producto

<figure><img src="/files/44cf442a4c579878fb2424778561791d151766cb" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/es/web/nosql-injection/detection-of-nosql-injection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
