en · de

JSON/JavaScript based vulnerability

by Thomas,
assono GmbH, Standort Kiel,


Under certain circumstances there is a vulnerability, when a web server creates responses in JSON format or as JavaScript, which is quite usual in AJAX applications.

Scenario:
There is a web application, which uses XMLHttpRequest aka AJAX to get confidential data. The response is generated in JSON format or pure JavaScript. The application is usable after a user authentication only (or at least the data returned depends on user credentials).

Furthermore there is a malicious web site on a different server, whos creator wants to spy out some secret data. Therefore the page contains a <script> tag with a src arttribute pointing to a URL to the above web application, returning data as JSON or JavaScript. Different from XMLHttpRequest, which can only point to the same origin, <script> tags allow to get JavaScript from any server.

At the top of the same page there is a extension of the JavaScript Object oder Array object, which is called, whenever a new Object or Array is created.

Thus by executing the mentioned <script> tag, for each new object or array the extension is called and has access to the confidential data, which it can send (using another AJAX call) to the malicious web server.


But there are a lot of preconditions to be met:

The new parameter OutputFormat=JSON
of the ReadViewEntries URL command, which
was introduced in Domino 7.0.2, is not affected, since it always returns
a JavaScript object (not an array) on the top level.


But for self created JSON - perhaps
in agents or HTML views - you should check, if you have to prevent this
vulnerability.


There are (at least) 2 methods to protect
your application:

  1. The server-side code expects some kind of information as parameter, which the server has sent to the browser. This could be a randomly created number, which is sent in form of a cookie. After the call, the server checks, if this information is part of the call's parameter (and if it is equal to the sent information). If not, no content is returned. Since the same origin policy prevents access to this cookie for JavaScript code not originating from the same server, the malicius web page cannot access it.
  2. You can create a JavaScript response, which cannot be executed directly. For example, you prepend while(true); to the answer. In your client-side application you could easily modifiy the response before evaluating it. You could cut out the first line or just prepend //, thus making the first line a comment.

For a detailled inspection please read
the analysis of Fortify Software.


Source: http://www.fortifysoftware.com/advisory.jsp

Technical article JavaScript Security Development

You have questions about this article? Contact us: blog@assono.de

Sie wollen eine individuelle Beratung oder einen Workshop? Read more

More interesting entries

Any questions? Contact us.

If you want to know more about our offers, you can contact us at any time. There are several ways to contact us for a non-binding first consultation.

assono GmbH

Location Kiel (headquarters)
assono GmbH
Lise-Meitner-Straße 1–7
24223 Schwentinental

Location Hamburg
assono GmbH
Bornkampsweg 58
22761 Hamburg

Phone numbers:
Human resources department: +49 4307 900 407
Marketing department: +49 4307 900 411

E-Mail adresses:
contact@assono.de
bewerbung@assono.de