# Lab 1: Client-side prototype pollution via browser APIs

Primero ejecutamos el siguiente script de js en la consola:

```
Object.prototype
```

<figure><img src="/files/XBsmWNYURbWedyPrtQ51" alt=""><figcaption></figcaption></figure>

Luego de lo anterior, se procede a realizar un GET concatenando lo siguiente:

{% code overflow="wrap" %}

```
/?__proto__[variable]=gerhishere
```

{% endcode %}

Y al ejecutar nuevamente el script previo, sale lo siguiente:

<figure><img src="/files/GmJHuPL4nxRSaYwNlGFJ" alt=""><figcaption></figcaption></figure>

Y luego de lo anterior, validamos el codigo fuente para analizarlo:

<figure><img src="/files/es9ZRPZyOczXBcinE5rS" alt=""><figcaption></figcaption></figure>

El ataque de prototype pollution ocurre cuando un atacante puede modificar el prototipo de objetos base en JavaScript, como `Object.prototype`, lo que permite inyectar propiedades maliciosas que pueden ser utilizadas en todo el código que se basa en estos objetos.

En este caso, la función `deparam` podría ser explotada si los parámetros de la URL incluyen claves como `__proto__`. Por ejemplo, un atacante podría pasar una URL como esta:

Teniendo en cuenta lo anterior, se procede a modificar nuestro payload para desplegar una alerta en JS:

<figure><img src="/files/0ohHgLwnmNe2zp8tAsSb" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://books.spartan-cybersec.com/web/prototype-pollution/lab-1-client-side-prototype-pollution-via-browser-apis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
