Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

caplet · The Caplet Group

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 72
  • Category: Security
  • Founded: May 11, 2007
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Messages 204 - 233 of 349   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#204 From: Larry Koved <koved@...>
Date: Mon May 5, 2008 2:12 am
Subject: Reminder: Web 2.0 Security and Privacy
larrykoved
Send Email Send Email
 

Reminder -- less than 3 week until the workshop!

W2SP 2008: Web 2.0 Security and Privacy 2008
Thursday, May 22
The Claremont Resort, Oakland, California Sponsored by the 2008 IEEE Symposium on Security and Privacy

The goal of this one day workshop is to bring together researchers and practitioners from academia and industry to focus on understanding Web 2.0 security and privacy issues, and establishing new collaborations in these areas.

Registration: Workshop registration will only be available at the 2008 IEEE Symposium on Security and Privacy and 2008 IEEE Symposium on Security and Privacy conference web site, but not on the day of the workshop.

2008 workshop web site:         http://seclab.cs.rice.edu/w2sp/2008/
2007 workshop web site:         http://seclab.cs.rice.edu/w2sp/2007/


#205 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 2:47 am
Subject: [Fwd: ADsafe attack]
david.hopwood@...
Send Email Send Email
 
-------- Original Message --------
To: Douglas Crockford <douglas@...>
Subject: ADsafe attack
From: David-Sarah Hopwood <david.hopwood@...>

(function () {
      var concat = [].concat;
      var array = concat();
      var global = ADSAFE.get(array, 0);
      global.alert('hi');
})();

This passes ADsafe and alerts on Firefox 2.0.0.14. IE seems to be more
picky about calling built-in methods on objects of the wrong type;
'concat()' throws a TypeError on IE (but I don't know whether the same
issue is exploitable some other way).

I think the problem starts with allowing the '[].concat': since methods of
the built-in types refer to 'this', it's possible for the global object to
leak from such a method when it is called as a plain function.

I don't know how to fix it while still allowing property accesses using
'.', short of blacklisting all property names that correspond to methods
of built-in types. That would be very ugly and error-prone, since you'd
have to know about any non-standard methods.

I'll wait for your response before making this public. It is also relevant
to Jacaranda, so I'd like to discuss it at the Friday meeting with MarkM
et al.

--
David-Sarah Hopwood

#206 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 2:49 am
Subject: [Fwd: Re: ADsafe attack]
david.hopwood@...
Send Email Send Email
 
-------- Original Message --------
From: Douglas Crockford <douglas@...>
To: David-Sarah Hopwood <david.hopwood@...>,  Mark
Miller <erights@...>
Subject: Re: ADsafe attack

David-Sarah Hopwood wrote:
> (function () {
>     var concat = [].concat;
>     var array = concat();
>     var global = ADSAFE.get(array, 0);
>     global.alert('hi');
> })();
>
> This passes ADsafe and alerts on Firefox 2.0.0.14. IE seems to be more
> picky about calling built-in methods on objects of the wrong type;
> 'concat()' throws a TypeError on IE (but I don't know whether the same
> issue is exploitable some other way).
>
> I think the problem starts with allowing the '[].concat': since methods of
> the built-in types refer to 'this', it's possible for the global object to
> leak from such a method when it is called as a plain function.
>
> I don't know how to fix it while still allowing property accesses using
> '.', short of blacklisting all property names that correspond to methods
> of built-in types. That would be very ugly and error-prone, since you'd
> have to know about any non-standard methods.
>
> I'll wait for your response before making this public. It is also relevant
> to Jacaranda, so I'd like to discuss it at the Friday meeting with MarkM
> et al.

That is distressing. It appears to be safe on Opera, Safari, and IE, but
ADsafe surely fails on Firefox.

I don't trust a blacklist approach to guard dot, so that would mean
outlawing dot except in a few specific cases, which would make use of the
language close to unbearable.

So instead, I will fix Firefox:

Array.prototype.concat = function () {
      var concat = Array.prototype.concat;
      return function () {
          if (this === window) {
              throw {
                  name: "ADsafe",
                  message: "ADsafe violation."
              };
          }
          return concat.apply(this, arguments);
      };
}();

We will have to do this for all of the Array methods that return this. It is
galling, but I don't see a better alternative.

I think we should also add language to ES3.1 15.4.4.4 and elsewhere that
force the methods to throw when they are called as functions (with this ===
window).

Go ahead and make it public.

#207 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 1:43 pm
Subject: [Fwd: Re: ADsafe attack]
david.hopwood@...
Send Email Send Email
 
[This might be a duplicate; I'm having trouble posting to this list
from my usual account.]

-------- Original Message --------
From: David-Sarah Hopwood <david.hopwood@...>
To: Douglas Crockford <douglas@...>
Subject: Re: ADsafe attack

Douglas Crockford wrote:
> I don't trust a blacklist approach to guard dot, so that would mean
outlawing dot except in a few specific cases, which would make use of
the language close to unbearable.
>
> So instead, I will fix Firefox:
>
> Array.prototype.concat = function () {
>     var concat = Array.prototype.concat;
>     return function () {
>         if (this === window) {
>             throw {
>                 name: "ADsafe",
>                 message: "ADsafe violation."
>             };
>         }
>         return concat.apply(this, arguments);
>     };
> }();
>
> We will have to do this for all of the Array methods that return
this.

Not just Array; all of the methods accessible in the public API. The
problem with that approach is that there may be methods that are not
standardized, and that are also not enumerable.

If there were a way to enumerate all properties of an object
regardless
of DontEnum attributes, then it would be possible to perform this fix
automatically and reliably. Otherwise, it doesn't seem to be possible
(without rewriting) to allow unrestricted use of both '.' and '()'.

> It is galling, but I don't see a better alternative.

Jacaranda doesn't allow unrestricted use of '.'; it allows only
"foo.method(...)", "this.property", and "foo.$get('property')".
It's possible to do a 'lightweight' rewriting of "foo.property" to
"foo.$get('property')", where the rewriter is not in the TCB.

> I think we should also add language to ES3.1 15.4.4.4 and elsewhere
that force the methods to throw when they are called as functions
(with this === window).
>
> Go ahead and make it public.

OK -- can I also forward this conversation?
[The answer was yes.]

--
David-Sarah Hopwood

#208 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 1:44 pm
Subject: [Fwd: Re: ADsafe attack]
david.hopwood@...
Send Email Send Email
 
-------- Original Message --------
From: Douglas Crockford <douglas@...>
To: David-Sarah Hopwood <david.hopwood@...>,
Mark Miller <erights@...>
Subject: Re: ADsafe attack

I found three of Firefox's Array methods return window when called as
functions.
ADSAFE is now wrapping them:

      var mozilla = function (name) {
          var method = Array.prototype[name];
          Array.prototype[name] = function () {
              if (this === window) {
                  error();
              }
              return method.apply(this, arguments);
          };
      };

      mozilla('concat');
      mozilla('reverse');
      mozilla('sort');

I am worried about the extra Array methods (map, reduce, et al) but I
haven't found a hole yet.

#209 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 1:44 pm
Subject: [Fwd: Re: ADsafe attack]
david.hopwood@...
Send Email Send Email
 
-------- Original Message --------
From: Douglas Crockford <douglas@...>
To: David-Sarah Hopwood <david.hopwood@...>
Subject: Re: ADsafe attack

David-Sarah Hopwood wrote:
> Not just Array; all of the methods accessible in the public API. The
> problem with that approach is that there may be methods that are not
> standardized, and that are also not enumerable.

The public API is the stuff that ADsafe allows. The ADSAFE object may
not
contain any method that can leak. The ADsafe contract does not allow
adding
methods to the public objects that can leak. ADsafe does not allow
the public
objects to be used as values, so

      var o = Object;
      for (name in o) {

is not allowed.

It also includes anything that Firefox provides that ADsafe does not
block. Does it have any more tricks?

#210 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 7:02 pm
Subject: Re: [Fwd: Re: ADsafe attack]
david.hopwood@...
Send Email Send Email
 
Douglas Crockford wrote:
> I don't trust a blacklist approach to guard dot, so that would mean
> outlawing dot except in a few specific cases, which would make use of
> the language close to unbearable.
>
> So instead, I will fix Firefox:
>
> Array.prototype.concat = function () {
>     var concat = Array.prototype.concat;
>     return function () {
>         if (this === window) {
>             throw {
>                 name: "ADsafe",
>                 message: "ADsafe violation."
>             };
>         }
>         return concat.apply(this, arguments);
>     };
> }();

I'm not convinced that it is sufficiently robust to just check for
(this === window). This should work:

    function robustify(aType, methodName) {
        var proto = aType.prototype;
        var oldMethod = proto[methodName];

        if ({}.__proto__ !== undefined) {
            aType.prototype[methodName] = function () {
                if (this.__proto__ !== proto) {
                    throw {name: "ADsafe", message: "ADsafe violation."};
                }
                return oldMethod.apply(this, arguments);
            };
        } else {
            proto._type___ = proto;
            if (Object.dontEnum !== undefined) {
                Object.dontEnum(proto, '_type___');
            }
            aType.prototype[methodName] = function () {
                if (this._type___ !== proto) {
                    throw {name: "ADsafe", message: "ADsafe violation."};
                }
                return oldMethod.apply(this, arguments);
            };
        }
    }

    robustify(Array, 'concat');

However, without having a way to enumerate all of the functions,
including undocumented ones, defined on the prototypes of
{Object,Function,Array,String,Boolean,Number,Math,Date,RegExp,*Error},
you still risk missing one that could potentially leak 'this'.

Any chance of an Object.__allKeys__(object) method, which ignores
DontEnum, in ES3.1?

--
David-Sarah Hopwood

#211 From: "Douglas Crockford" <douglas@...>
Date: Wed May 21, 2008 7:09 pm
Subject: [Fwd: Re: ADsafe attack]
douglascrock...
Send Email Send Email
 
--- In caplet@yahoogroups.com, David-Sarah Hopwood <david.hopwood@...>
wrote:
> Any chance of an Object.__allKeys__(object) method, which ignores
> DontEnum, in ES3.1?

We are considering an Object.keys method, but it will only return the
own, enumerable property names.

#212 From: "Douglas Crockford" <douglas@...>
Date: Wed May 21, 2008 7:13 pm
Subject: [Fwd: Re: ADsafe attack]
douglascrock...
Send Email Send Email
 
--- In caplet@yahoogroups.com, David-Sarah Hopwood <david.hopwood@...>
wrote:
> I'm not convinced that it is sufficiently robust to just check for
> (this === window).

Why? The test is intended to reject invocations of the method as a
function. What cases are missed?

#213 From: "Mark S. Miller" <erights@...>
Date: Wed May 21, 2008 7:14 pm
Subject: Re: Re: [Fwd: Re: ADsafe attack]
erights@...
Send Email Send Email
 
On Wed, May 21, 2008 at 12:02 PM, David-Sarah Hopwood
<david.hopwood@...> wrote:
> Any chance of an Object.__allKeys__(object) method, which ignores
> DontEnum, in ES3.1?

Yes! The about-to-be-specified Object.getProperties(obj) will provide
a reflective description of all an object's own properties. This
operation itself will not be visible from Caja, and I wouldn't
recommend that it be visible from ADsafe, but in both cases it's
useful within the runtime libraries of these secure subsets, to help
enforce useful properties, as you explain.


--
     Cheers,
     --MarkM

#214 From: David-Sarah Hopwood <david.hopwood@...>
Date: Wed May 21, 2008 11:19 pm
Subject: Object.getProperties (was: ADsafe attack)
david.hopwood@...
Send Email Send Email
 
Mark S. Miller wrote:
> On Wed, May 21, 2008 at 12:02 PM, David-Sarah Hopwood
> <david.hopwood@...> wrote:
>> Any chance of an Object.__allKeys__(object) method, which ignores
>> DontEnum, in ES3.1?
>
> Yes! The about-to-be-specified Object.getProperties(obj) will provide
> a reflective description of all an object's own properties. This
> operation itself will not be visible from Caja, and I wouldn't
> recommend that it be visible from ADsafe, but in both cases it's
> useful within the runtime libraries of these secure subsets, to help
> enforce useful properties, as you explain.

That's why I suggested a name using the __...__ convention.

Otherwise, a subset language that does not do rewriting must do one of:
   - blacklist the name 'getProperties', which is ugly;
   - rebind 'Object' when running subset code, which does not have
     well-defined semantics and may cause compatibility problems;
   - block access to 'Object', which would not otherwise be necessary.

Actually, a better idea would be to move *all* of the methods proposed
to be added to Object, to a new global 'Reflect'. Rebinding 'Reflect'
in order to provide tamed versions of these operations when running
subset code would not have the same problems as rebinding 'Object',
since 'Reflect' is not used for anything else.

--
David-Sarah Hopwood

#215 From: "Douglas Crockford" <douglas@...>
Date: Wed May 21, 2008 11:40 pm
Subject: Re: Object.getProperties (was: ADsafe attack)
douglascrock...
Send Email Send Email
 
--- In caplet@yahoogroups.com, David-Sarah Hopwood <david.hopwood@...>
wrote:
> That's why I suggested a name using the __...__ convention.
>
> Otherwise, a subset language that does not do rewriting must do one of:
>   - blacklist the name 'getProperties', which is ugly;
>   - rebind 'Object' when running subset code, which does not have
>     well-defined semantics and may cause compatibility problems;
>   - block access to 'Object', which would not otherwise be necessary.
>
> Actually, a better idea would be to move *all* of the methods proposed
> to be added to Object, to a new global 'Reflect'. Rebinding 'Reflect'
> in order to provide tamed versions of these operations when running
> subset code would not have the same problems as rebinding 'Object',
> since 'Reflect' is not used for anything else.

Mark came up with a better idea: ADsafe denies any access to Object.

#216 From: David-Sarah Hopwood <david.hopwood@...>
Date: Thu May 22, 2008 12:17 am
Subject: Re: Re: Object.getProperties
david.hopwood@...
Send Email Send Email
 
Douglas Crockford wrote:
> --- In caplet@yahoogroups.com, David-Sarah Hopwood <david.hopwood@...>
> wrote:
>> That's why I suggested a name using the __...__ convention.
>>
>> Otherwise, a subset language that does not do rewriting must do one of:
>>   - blacklist the name 'getProperties', which is ugly;
>>   - rebind 'Object' when running subset code, which does not have
>>     well-defined semantics and may cause compatibility problems;
>>   - block access to 'Object', which would not otherwise be necessary.
>>
>> Actually, a better idea would be to move *all* of the methods proposed
>> to be added to Object, to a new global 'Reflect'. Rebinding 'Reflect'
>> in order to provide tamed versions of these operations when running
>> subset code would not have the same problems as rebinding 'Object',
>> since 'Reflect' is not used for anything else.
>
> Mark came up with a better idea: ADsafe denies any access to Object.

I don't want to have to do that in Jacaranda (where it would otherwise
be safe to allow first-class access to Object).

--
David-Sarah Hopwood

#217 From: "Douglas Crockford" <douglas@...>
Date: Thu May 22, 2008 12:54 pm
Subject: ADsafe and bind
douglascrock...
Send Email Send Email
 
ADsafe will block the bind method. The bind method proposed for ES3.1
is safe, but the bind methods provided by the current Ajax libraries
are not because they can bind to the global object. Since ADsafe does
not allow the definition of methods that use this, little is lost by
blocking bind.

#218 From: David-Sarah Hopwood <david.hopwood@...>
Date: Thu May 22, 2008 2:12 pm
Subject: Re: ADsafe and bind
david.hopwood@...
Send Email Send Email
 
Douglas Crockford wrote:
> ADsafe will block the bind method. The bind method proposed for ES3.1
> is safe, but the bind methods provided by the current Ajax libraries
> are not because they can bind to the global object.

Don't some of these libraries have other aliases for bind-like methods?
For example Prototype has 'bindAsEventListener', although I don't know of
any specific attack based on that in the context of ADsafe.

--
David-Sarah Hopwood

#219 From: David-Sarah Hopwood <david.hopwood@...>
Date: Thu May 22, 2008 2:22 pm
Subject: Re: ADsafe and bind
david.hopwood@...
Send Email Send Email
 
David-Sarah Hopwood wrote:
> Douglas Crockford wrote:
>> ADsafe will block the bind method. The bind method proposed for ES3.1
>> is safe, but the bind methods provided by the current Ajax libraries
>> are not because they can bind to the global object.
>
> Don't some of these libraries have other aliases for bind-like methods?
> For example Prototype has 'bindAsEventListener', although I don't know of
> any specific attack based on that in the context of ADsafe.

While I remember, I think you also need to blacklist 'stack'.

<http://code.google.com/p/google-caja/wiki/ErrorExposesParameterValues>

--
David-Sarah Hopwood

#220 From: "Douglas Crockford" <douglas@...>
Date: Fri May 23, 2008 2:53 am
Subject: ADsafe and JSLint
douglascrock...
Send Email Send Email
 
ADsafe now allows long dot expressions that refine the allowed global
variables. So

     ADSAFE.koda.bosanda.bosoya.tikki.ottobo();

is now acceptable.

JSLint's UI now allows the specification of allowed global variables.
The names can be entered into a field, separated with commas. It is
recommended that the names be in all upper caps to distinguish them
from constructors and ordinary variables.

#221 From: "Douglas Crockford" <douglas@...>
Date: Sat May 24, 2008 9:45 pm
Subject: ADsafe.get(object, name)
douglascrock...
Send Email Send Email
 
I relaxed some of the restrictions on the get method. It still
requires that the object is in fact an object (and not a function),
but it allows the returning of any value, including inherited values
and functions. The name must be a number or a string not starting with
_ and not on the banned list, which is currently

apply, arguments, call, callee, caller, constructor, eval, prototype,
unwatch, valueOf, watch

#222 From: "Douglas Crockford" <douglas@...>
Date: Sun Jun 1, 2008 6:25 am
Subject: ADSAFE.id, ADSAFE.lib, ADSAFE.go
douglascrock...
Send Email Send Email
 
http://ADsafe.org/ now describes three methods that provide the
linkage between the guest code and the ADsafe runtime.

#223 From: "Douglas Crockford" <douglas@...>
Date: Tue Jun 3, 2008 8:40 pm
Subject: adsafe.js
douglascrock...
Send Email Send Email
 
The first edition of adsafe.js is available at
http://adsafe.org/adsafe.js. It still lacks dom wrappage and
interwidget communication.

#224 From: "Adam Barth" <hk9565@...>
Date: Fri Jun 6, 2008 9:18 am
Subject: Re: adsafe.js
hk9565
Send Email Send Email
 
On Tue, Jun 3, 2008 at 1:40 PM, Douglas Crockford <douglas@...> wrote:
> The first edition of adsafe.js is available at
> http://adsafe.org/adsafe.js. It still lacks dom wrappage and
> interwidget communication.

Attached is a rough first draft of a safe DOM wrapper.  The main idea
is that untrusted script views DOM nodes simply as integer handles.
To read or mutate the DOM, the untrusted code passes the appropriate
handles to the SafeDOM API, which interacts with the real DOM.  The
SafeDOM library is intended to limit the untrusted code to interacting
only with the portion of the document tree that descends from
root_node.  Also, element creation and modification can be controlled
by a policy, as demonstrated by the implementation of createElement.

The attached code is completely untested.  It is intended to sketch
out an architecture for how the DOM API could be safely exposed to
JavaScript which passes the ADsafe validator.

Adam

#225 From: David-Sarah Hopwood <david.hopwood@...>
Date: Sat Jun 7, 2008 2:43 am
Subject: Re: adsafe.js
david.hopwood@...
Send Email Send Email
 
Adam Barth wrote:
> On Tue, Jun 3, 2008 at 1:40 PM, Douglas Crockford <douglas@...>
wrote:
>> The first edition of adsafe.js is available at
>> http://adsafe.org/adsafe.js. It still lacks dom wrappage and
>> interwidget communication.
>
> Attached is a rough first draft of a safe DOM wrapper.  The main idea
> is that untrusted script views DOM nodes simply as integer handles.

It would be easy to make the handles opaque:

    var nodes = [];

    function handleToNode(handle) {
      return handle.__node__;
    }

    function nodeToHandle(node) {
      if (!node) return null;

      // Check if we've seen this node before.
      var handle = node.__safe_dom_handle__;
      if (handleToNode(handle) === node)
        return handle;

      // Need to allocate a new handle and add it to the nodes array.
      nodes[nodes.length] = node;
      var handle = makeHandle(node);
      node.__safe_dom_handle__ = handle;
      return handle;
    }

    function makeHandle(node) {
      return {__node__: node};
    }

    function assertHandle(handle) {
      if (handle.__node__ !== void 0)
        throw INVALID_HANDLE_ERR;
    }

[...]
    API.getElementById = function(id) {
      assertString(id);

      var n = nodes.length;
      for (var i = 0; i < n; ++i) {
        var node = nodes[i];
        if (node.getAttribute && node.getAttribute('id') === id)
          return node.__safe_dom_handle__;
      }
      return null;
    };

This approach prevents a script from relying on the fact that you're
implementing handles as integers. More importantly, though, it allows
the handle objects to implement tamed DOM methods (using lexical
encapsulation), allowing the API to look more like the original DOM:

    function makeHandle(node) {
      return {
        __node__: node,
        hasChildNodes: function () {
          return node.hasChildNodes();
        },
        getNodeType: function () {
          return node.nodeType;
        },
        getNodeName: function () {
          return node.nodeName;
        },
        getNodeValue: function () {
          return node.nodeValue;
        },
        getFirstChild: function () {
          return nodeToHandle(node.firstChild);
        },
        getLastChild: function () {
          return nodeToHandle(node.lastChild);
        },
        getNextSibling: function () {
          if (node === root_node) return null;
          return nodeToHandle(node.nextSibling);
        },
        getPreviousSibling: function () {
          if (node === root_node) return null;
          return nodeToHandle(node.parentNode);
        }
      };
    }

(It's also possible to support properties like 'nodeValue' directly rather
than via getter methods, but in that case mutable properties would have to
be kept in sync whenever the underlying node changed -- unless you rely on
Mozilla or ES3.1 property getters.)

Note that, unlike in Caja or Jacaranda, these methods cannot refer to
'this', because ADsafe does not prevent obtaining a property that holds
a function and then calling it with 'this' bound to the global object.
ADsafe also does not prevent setting arbitrary properties (unless they
start with _ or are blacklisted), so there is no encapsulation between
objects created by a given script, including handle objects. However,
encapsulation is not strictly needed for ADsafe's threat model.
Caja, Cajita and Jacaranda incur much greater implementation complexity
(less so for Jacaranda, but still more than ADsafe) in order to support
this encapsulation.

--
David-Sarah Hopwood

#226 From: David-Sarah Hopwood <david.hopwood@...>
Date: Sat Jun 7, 2008 2:58 am
Subject: Re: adsafe.js
david.hopwood@...
Send Email Send Email
 
David-Sarah Hopwood wrote:
> Note that, unlike in Caja or Jacaranda, these methods cannot refer to
> 'this', because ADsafe does not prevent obtaining a property that holds
> a function and then calling it with 'this' bound to the global object.
> ADsafe also does not prevent setting arbitrary properties (unless they
> start with _ or are blacklisted), so there is no encapsulation between
> objects created by a given script, including handle objects. However,
> encapsulation is not strictly needed for ADsafe's threat model.

I was slightly unclear here. Encapsulation of the underlying DOM node
objects from the script is required; in the implementation I suggested,
that is achieved by a combination of holding the node in a property that
starts with _, and lexical closures. Encapsulation of other properties
of the handle objects from the script is not required: it does not matter
that a script can replace methods of a handle object, for example.

--
David-Sarah Hopwood

#227 From: David-Sarah Hopwood <david.hopwood@...>
Date: Sat Jun 7, 2008 11:14 pm
Subject: Re: adsafe.js
david.hopwood@...
Send Email Send Email
 
David-Sarah Hopwood wrote:
> Adam Barth wrote:
>> On Tue, Jun 3, 2008 at 1:40 PM, Douglas Crockford
>> <douglas@...> wrote:
>>> The first edition of adsafe.js is available at
>>> http://adsafe.org/adsafe.js. It still lacks dom wrappage and
>>> interwidget communication.
>>
>> Attached is a rough first draft of a safe DOM wrapper.  The main idea
>> is that untrusted script views DOM nodes simply as integer handles.
>
> It would be easy to make the handles opaque:
>
[...]
>     node.__safe_dom_handle__ = handle;
[...]
>   function makeHandle(node) {
>     return {__node__: node};
>   }

This will leak memory on IE (even after the nodes array has become
unreferenced after leaving the page), because JScript's excuse for a
garbage collector cannot collect cycles that involve a DOM object.
That problem could be fixed by having the node object store the index
of the handle in the nodes array, rather than a reference to the handle.

--
David-Sarah Hopwood

#228 From: "Kris Zyp" <kris@...>
Date: Mon Jun 9, 2008 5:29 pm
Subject: window.name transport
kriszyp
Send Email Send Email
 
I have been investigating an idea for a secure cross-site transport. It seems unlikely that no one has done anything like this before, but I can't find any evidence of it. But I wanted to run this by you, see if I was missing something obvious. The basic idea is this: do a request with an iframe (GET or POST) to a cross-domain target, and then the target responds with an page that sets it's window.name to the content of the resource that was requested. The requester then changes the iframe back to a page that is in same domain as the requester, and the requesting page can then retrieve the name of frame's window.name to retrieve the data from the target resource. This has several advantages:
1. It is secure, JSONP/script tag insertion is not. That is, it is as secure as other frame based secure transports like fragment identifier messaging (FIM), and Subspace. Frames also have their security issues, with phishing and such, but that is quite a different security exploit.
2. It is much faster than FIM, because it doesn't have to deal with small packet size of a fragment identifier, and it doesn't have as much "machine gun" sound effects. It is also faster than Subspace. Subspace requires two iframes and two local html files to be loaded to do a request. Frame Naming only requires one iframe and one local file.
3. It is simpler and more secure than Subspace and FIM. FIM is somewhat complicated, and Subspace is very complicated. Subspace also has a number of extra restrictions and setup requirements, like declaring all of the target hosts before hand and having DNS entries for a number of different particular hosts. window.name is very simple and easy to use.
 
The main advantage of Subspace over window.name is that Subspace uses the script tag/JSONP loading technique which has pretty decent acceptance and implementation. window.name is easier for servers to implement than FIM, but it still requires a few lines of HTML and String quoting around the resource.
 
Here is a demonstration of my implementation of window.name: http://sitepen.com/labs/code/secure/dojox/io/tests/windowName.html. This is based on Dojo, and by default connects to a x-domain resource served from my demo version of Persevere (I added the window.name capability to it), but you can give it any URL that will output data via the window.name format. It appears to work in all the major browsers. The idea is based Thomas Franke's new library for doing session variables with window.name, but this obviously a completely different goal. I think you could also adapt this technique for doing cross-frame messaging (emulate postMessage). Also, my apologies that the demo is slow, it is using an "unbuilt" version of Dojo. It is much faster when built.
 
Anyway, does this seem like a reasonable approach to cross-site requests (while we wait for XDR and/or XHR/AC)?
Kris
 
 

#229 From: "Kris Zyp" <kris@...>
Date: Mon Jun 9, 2008 6:31 pm
Subject: dojox.secure
kriszyp
Send Email Send Email
 
Recently I have been working on a new project, dojox.secure, to add a secure mechanism to Dojo for loading and executing untrusted code and widgets, and I wanted to share what I have now and see if there is any feedback the API, and security holes that people might be aware. dojox.secure is based on ADsafe and is intended to provide a full turnkey framework for loading untrusted widgets. dojox.secure consists of several key components:
1. xhrPlugins - This is the XHR plugin architecture that allows developers to easily use the most appropriate cross-site mechanism to securely load untrusted cross-site resources (the previously window.name transport could plugin here).
2. ADsafe style object-capability validator. This validator ensures that loaded untrusted JavaScript can not access the global environment, it can only access objects that have been specifically granted to the sandbox. This can run on the client, and can consequently be used when resources are directly loaded from the browser.
3. Secure DOM facade. This is a DOM wrapper that only allows access to a provided element and it's children. Query operations and such are limited to this subset of the DOM. This performs checks on all innerHTML sets, DOM manipulation, and CSS to ensure that unsafe priviledge escalating code does not enter the DOM.
4. Safe Dojo Library - This is a safe subset of the Dojo library that can be used by the untrusted code. Safe versions of several otherwise unsafe, but very important functions are included such as query(). There are also some additional language functions that are provided to compensate for the language restrictions enforced by the object-capability validator.
5. Sandbox creator that brings all these components together so developers can easily load HTML or scripts and sandbox them within a single DOM element. The sandbox will also provides loading facilities for dependencies that these resources may have (scripts and css files) and safely loads and sandboxes them as well.
 
The current demo and the API that is available for untrusted code can be seen here:
An example of creating the sandbox and loading untrusted code looks like:
var sandboxContainerElement = document.getElementById("sandbox");
var sandbox = dojox.secure.sandbox(sandboxContainerElement);
 
You can currently load HTML or JavaScript from the sandbox object (or directly execute preloaded JavaScript). Scripts can interact with their DOM subset using the provided "element" variable. I have also considered an alternate scheme where one could execute untrusted JavaScript which would return an object that would have a render(element) method that the container code could execute to display a widget within a provided element. I think this approach could be more organized and efficient, but less traditional in terms of how a script interacts with the DOM.
 
Let me know if anyone has any thoughts on this design, and if you can find any security exploits. Hopefully the demo page makes it as easy possible to test possible exploits (so you don't have to report uneasy feelings).
Thanks,
Kris
----- Original Message -----
From: Kris Zyp
Sent: Monday, April 21, 2008 10:58 AM
Subject: dojox.secure

I have been working on experimental project to create a mechanism for securely running untrusted scripts with Dojo. This project uses ADsafe-like object-capability limiting in combination with a DOM facade. The idea is that an untrusted script can executed, but it will only have access to that part of the DOM (and it's descendants) that you provide it, and it won't be able to access the window object or other sensitive global objects (like cookies). Anyway, I presume that I don't have an airtight implementation yet, but I would love to have some help in trying to find holes in this security model, to see if this is going to work. I have created a test page, where you can enter a script and execute it and interact with the DOM, and see if you can access anything outside the provided sandbox:
This system does create limitations (several are noted on the page) on what you can do in JavaScript and with the DOM.
 
This would be used in combination with some type of secure loading mechanism (proxy, cross-site XHR, XDR, postMessage, etc.), to load a script in text form, and then the secure loader would execute it. I think this may have some real potential, we could provide a means for untrusted widgets and ads to be securely loaded such that they couldn't mess with main page.
 
Thanks,
Kris
 

#230 From: "Douglas Crockford" <douglas@...>
Date: Mon Jun 9, 2008 8:12 pm
Subject: ADsafe DOM API
douglascrock...
Send Email Send Email
 
I am developing an Ajax library for ADsafe. It applies a capability
discipline to the dom tree, blocking access to parents and siblings.

It wraps collections of dom nodes in lightweight 'bunch' objects that
can act on all of the nodes they hold. It is my hope that the utility
of the package will offset the inconvenience and inefficiency of
intermediation.

http://adsafe.org/dom.html

#231 From: "Douglas Crockford" <douglas@...>
Date: Sat Jun 21, 2008 11:33 pm
Subject: JSLint and ADsafe
douglascrock...
Send Email Send Email
 
I created a safe option in JSLint for checking the safe subset. The
adsafe option assumes the safe option, and additionally checks for
ADsafe widget conventions.

#232 From: "Mark S. Miller" <erights@...>
Date: Fri Jun 27, 2008 4:03 pm
Subject: Re: [Caja] eval() in FF3 - just in case...
erights@...
Send Email Send Email
 
On Fri, Jun 27, 2008 at 1:44 AM, Mario Heiderich
<Mario.Heiderich@...> wrote:
>
> http://peter.michaux.ca/article/8069
>
> Just in case this is not known/intercepted yet.

Wow. No, we had no idea. I admit that I am shocked that the one tight
encapsulation mechanism in JavaScript itself -- lexical closures --
has now been ruined. Fortunately, all safe JavaScript subsets (Caja,
Cajita, ADsafe, FBJS, Jacaranda) already prevent access to the eval
function, as they must. So we should all be safe from this particular
new hole. However, so long as browser vendors feel free to quietly
introduce holes this large in existing functions...


--
     Cheers,
     --MarkM

#233 From: "Mark S. Miller" <erights@...>
Date: Fri Jun 27, 2008 8:50 pm
Subject: Re: [Caja] eval() in FF3 - just in case...
erights@...
Send Email Send Email
 
On Fri, Jun 27, 2008 at 12:39 PM, Brendan Eich <brendan@...> wrote:
> There's no "now" -- this old eval extension was added over ten years ago:
>
>
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/js/src/jsobj.c&rev=3.2&mark\
=580-590

Hi Brendan, I was completely unaware of this history and did indeed
think that this was a newly opened hole. I'm very pleased to find that
it isn't. I'm especially pleased to hear that you folks plan to remove
this in a future release. Thanks for the clarification!


--
     Cheers,
     --MarkM

Messages 204 - 233 of 349   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help