Removal of WeakMap/WeakSet clear
waldron.rick at gmail.com
Wed Dec 3 10:28:33 PST 2014
On Wed, Dec 3, 2014 at 1:10 PM, Jason Orendorff <jason.orendorff at gmail.com>
> On Wed, Dec 3, 2014 at 9:04 AM, David Bruant <bruant.d at gmail.com> wrote:
> > A script which builds a weakmap may legitimately later assume the
> weakmap is
> > filled. However, passing the weakmap to a mixed-trusted (malicious or
> > script may result in the weakmap being cleared (and break the assumption
> > the weakmap being filled and trigger all sorts of bugs). Like all dumb
> > things, at web-scale, it will happen.
> OK. I read the whole thing, and I appreciate your writing it.
> There's something important that's implicit in this argument that I
> still don't have yet. If you were using literally any other data
> structure, any other object, passing a direct reference to it around
> to untrusted code would not only be dumb, but obviously something the
> ES spec should not try to defend against. Right? It would be goofy.
> The language just is not that hardened. Arguably, the point of a data
> structure is to be useful for storing data, not to be "secure" against
> code that **has a direct reference to it**. No?
> So what's missing here is, I imagine you must see WeakMap, unlike all
> the other builtin data structures, as a security feature.
> Specifically, it must be a kind of secure data structure where
> inserting or deleting particular keys and values into the WeakMap does
> *not* pose a threat, but deleting them all does.
> Can you explain that a bit more?
> I see the invariant you're talking about, I agree it's elegant, but to
> be useful it also has to line up with some plausible security use case
> and threat model.
As Mark presented it in the meeting (
"the mapping from weakmap/key pair value can only be observed or affected
by someone who has both the weakmap and the key. With clear(), someone with
only the WeakMap would've been able to affect the WeakMap-and-key-to-value
(This is the same thing that David was explaining, but slightly different
As I understand this explanation, removing clear() simply closes off a path
that would otherwise allow for potentially malicious meddling—no more, no
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss