> For the complete documentation index, see [llms.txt](https://yasmeen-rezk.gitbook.io/my-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yasmeen-rezk.gitbook.io/my-notes/bug-bounty-playbook-v2/more-owasp/prototype-pollution.md).

# Prototype Pollution

No limit to what you can potentially do with this vulnerability.

**JS is a prototype-based language.**

* JS objects inherit features from one another using Prototypes meaning if the prototype object is modified in one object it will apply to every other object.
* Prototypes are used to overwrite functions, variables, and anything else.

<figure><img src="https://509923538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ2ZeCCTH4XZTY31hlbGx%2Fuploads%2FKirPiUcfWTDTWmq6kREd%2Fimage.png?alt=media&amp;token=e2e33d64-90c6-4376-913c-828b7a64d578" alt=""><figcaption><p>Prototype Figure</p></figcaption></figure>

### Exploitation

**Goal:** setting the “admin” variable to true.

<figure><img src="https://509923538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ2ZeCCTH4XZTY31hlbGx%2Fuploads%2FxWVWH8t2GmpXIYwUQ0uA%2Fimage.png?alt=media&amp;token=bb3be22f-838c-45c3-a4a4-aca4edbdec3c" alt=""><figcaption><p>Vulnerable code snippet</p></figcaption></figure>

During the merge process if it comes across a prototype object it will add that to the user object.

#### To do:

* Sending a prototype object with a variable called “admin” which is set to “true”
* The admin object inherited the admin variable from the modified prototype object.
* When the line checks to see if admin.admin is set to true it will pass.

<figure><img src="https://509923538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ2ZeCCTH4XZTY31hlbGx%2Fuploads%2FkmcyMpbVbI3GWrJNYTq4%2Fimage.png?alt=media&amp;token=fa56fb7e-390c-48b2-ae5b-a33f77543943" alt=""><figcaption></figcaption></figure>
