// HackTricks · Web Pentesting

Ruby on Rails json pollution

Ruby on Rails _json pollution

Basic information

When a Rails endpoint receives a JSON body whose root value is not a hash, such as an array, the parsed value is exposed under the synthetic _json parameter. Depending on the parser and Rails version, an attacker-supplied _json member in an object can create an unexpected parameter shape or collide with application logic that also trusts _json.[1]

This becomes a security issue when validation or authorization checks one parameter representation but a later operation consumes the polluted _json value. The following object illustrates attacker-controlled values placed under that reserved-looking key:[1]

{
  "id": 123,
  "_json": [456, 789]
}

References

☧ CPTS · ordered posts

Locked

Unlock with your Main_Key through local GPG.

Start the local GPG helper

In your cheatsheet checkout, run:

npm run unlock:helper

Open the link it prints, or paste its pairing code below. Keep the terminal open until GPG finishes.

Import an index you already decrypted

Download the encrypted index, then decrypt with GPG:

gpg --output report-index.json --decrypt report-index.gpg

Your private key stays in GPG. The decrypted index is saved in this browser so you can reopen it after navigation, refreshes and restarts. Lock this browser or clear this site's browser data to remove the saved index. Nothing is uploaded.