Experiencing a Security Breach?

24 Hour Hotline: +1 (866) 659-9097 Option 5

General

+1 (312) 873-7500

Monday - Friday 8:00 AM - 6:00 PM CT (UTC -6)

Sales

Contact a Trustwave solution specialist.

+1 (888) 878-7817

Monday - Friday 8:30 AM - 5:30 PM CT (UTC -6)

Loading...

Blogs & Stories

SpiderLabs Blog

Attracting more than a half-million annual readers, this is the security community's go-to destination for technical breakdowns of the latest threats, critical vulnerability disclosures and cutting-edge research.

JSON Hijacking Demystified

JavaScript Object Notation (JSON) is alanguage and platform independent format for data interchange. JSON is inwidespread use with a number of JSON parsers and libraries available fordifferent languages. While some information is available for JSON hijackingthis attack is not very well understood.

JSON Hijacking as the name suggests is anattack similar to Cross-Site Request Forgery where an attacker can access cross-domainsensitive JSON data from applications that return sensitive data as arrayliterals to GET requests. An example of a JSON call returning an array literalis shown below:

Step 2: The malicious page willtry and access sensitive data from the application that the user is logged into.This can be done by embedding a script tag in an HTML page since thesame-origin policy does not apply to script tags. <script src="http://<jsonsite>/json_server.php"></script>

The browserwill make a GET request to json_server.php and any authentication cookies ofthe user will be sent along with the request.

Step 3: At this point while themalicious site has executed the script it does not have access to any sensitivedata. Getting access to the data can be achieved by using an object prototypesetter. In the code below an object prototypes property is being bound to the definedfunction when an attempt is being made to set the "ccnum" property.

Object.prototype.__defineSetter__('ccnum',function(obj){

secrets =secrets.concat(" ", obj);

});

At this point the malicious sitehas successfully hijacked the sensitive financial data (ccnum) returned byjson_server.php

It should be noted that not allbrowsers support this method; the proof of concept was done on Firefox 3.x.This method has now been deprecated and replaced by the useObject.defineProperty There isalso a variation of this attack that should work on all browsers where fullnamed JavaScript (e.g. pi=3.14159) is returned instead of a JSON array.

There are several ways in which JSONHijacking can be prevented:

Since SCRIPT tags can onlygenerate HTTP GET requests, only return JSON objects to POST requests.