Check out the new USENIX Web site. next up previous
Next: Finding the Object Origin Up: Security Code Layers and Previous: Security Code Layers and

Finding the Subject Origin URL

JavaScript has a number of possible ways to pass the control flow or to generate an additional thread of execution:

1.
Function/method call: e.g., v = foo(x); or u = otherWindow.foo(x);
2.
Dynamic generation of JavaScript code: e.g., document.write(foo(x);); or myWindow.eval(foo(x));.
3.
JavaScript URL: e.g., otherWindow.location = "javascript:foo(x)";
4.
JavaScript invocation through HTML (browser):
      
<a target=otherWin href="javascript:
   alert(window.location);" >
Also, code invoked through installed event handlers, ``script'' tags, etc.

Most ``traditional'' languages only have function/method calls. In those cases it is usually fairly straightforward to determine which entity originated the call sequence by inspecting the call stack, i.e., stack inspection. The additional methods and flexibility in JavaScript complicate this task. For instance, dynamic invocation has the flavor of a function call, but the passing of control does not take place instantly. In fact, a callee might be executing at a time when the caller is no longer on the stack. Therefore, we propose the use of proactive forward passing of the subject origin information. Whenever a passing of the control flow in the code is indicated (and whether it is about to take place right then or not), the interpreter sets the subject domain of the callee to the subject domain of the caller, in such a way that when the callee executes, this value can be easily retrieved.

We distinguish three cases:

Our goal is to arrive at a situation where, for every stack frame loaded, the correct subject origin can be retrieved from a well-defined location and, consequently, there will never be the need to search backward for it or even to fail and declare ``unknown origin'', as might occur in the current version of JavaScript (4.x browsers).


next up previous
Next: Finding the Object Origin Up: Security Code Layers and Previous: Security Code Layers and
Alain Mayer
8/30/1999