Common Attack Pattern Enumeration and Classification
A Community of Knowledge Resource for Building Secure Software
Attack Execution Flow
JSON is used as a transport mechanism between the client and the server
The target server cannot differentiate real requests from forged requests
The JSON object returned from the server can be accessed by the attacker's malicious code via a script tag
Gmail service was found to be vulnerable to a JSON Hijacking attack that enabled an attacker to get the contents of the victim's address book. An attacker could send an e-mail to the victim's gmail account (which ensures that the victim is logged in to gmail when he or she receives it) with a link to the attacker's malicious site. If the victim clicked on the link, a request (containing the victim's authenticated session cookie) would be sent to the gmail servers to fetch the victim's address book. This functionality is typically used by the Gmail service to get this data on the fly so that the user can be provided a list of contacts from which to choose the recipient of the e-mail.
Skill or Knowledge Level: Medium
Once this attack pattern is developed and understood, creating an exploit is not very complex.
No specialized hardware resources are required. The attacker needs to have knowledge of the URLs that need to be accessed on the target system to request the JSON objects.
Examine the typical asynchronous requests and responses between an AJAX client and the server to see how JSON objects are requested and what is returned.
Ensure that server side code can differentiate between legitimate requests and forged requests. The solution is similar to protection against Cross Site Request Forger (CSRF), which is to use a hard to guess random nonce (that is unique to the victim's session with the server) that the attacker has no way of knowing (at least in the absense of other weaknesses). Each request from the client to the server should contain this nonce and the server should reject all requests that do not contain the nonce.
Make the URLs in the system used to retrieve JSON objects unpredictable and unique for each user session.
Ensure that a mechanism is in place for the server side code to differentiate between legitimate requests and forged requests
Ensure that URLs used to request server responses that pass the JSON objects back to the client are hard to guess and are unique per user session