> For the complete documentation index, see [llms.txt](https://books.spartan-cybersec.com/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://books.spartan-cybersec.com/web/prototype-pollution/lab-1-client-side-prototype-pollution-via-browser-apis.md).

# 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
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://books.spartan-cybersec.com/web/prototype-pollution/lab-1-client-side-prototype-pollution-via-browser-apis.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.
