All the vulnerabilities related to the version 0.7.12 of the package
ses's global contour bindings leak into Compartment lexical scope
Web pages and web extensions using ses
and the Compartment
API to evaluate third-party code in an isolated execution environment that have also elsewhere used const
, let
, and class
bindings in the top-level scope of a <script>
tag will have inadvertently revealed these bindings in the lexical scope of third-party code.
This compromise is addressed in ses
version 1.12.0
. The mechanism for confining third-party code involves a with
block and a semi-opaque scope Proxy
. The proxy previously revealed any named property to the surrounding lexical scope if it were absent on globalThis
, so that the third-party code would receive an informative ReferenceError
, relying on the invalid assumption that only properties of globalThis
are in the top-level lexical scope. The solution makes the scope proxy fully opaque. Consequently, accessing an unbound free lexical name will produce undefined
instead of throwing ReferenceError
.
Assigning to an unbound free lexical name will continue to throw a ReferenceError
.
This problem can be mitigated either by avoiding top-level let
, const
, or class
bindings in <script>
tags, which is an existing industry best-practice, or change these to var
bindings to be reflected on globalThis
, or upgrade ses
to version 1.12.0
or greater.
Some bundlers by default transform top-level let
, const
, and class
bindings to var
.
This vulnerability was disclosed by @mingijunggrape in the course of their studies at UNIST (Ulsan National Institute of Science and Technology) as a member of the Web Security Lab (https://websec-lab.github.io/).
Hardening of TypedArrays with non-canonical numeric property names in SES
What kind of vulnerability is it? Who is impacted?
In Hardened JavaScript, programs can harden
objects to safely share objects with co-tenant programs without risk of these other programs tampering with their API surface. Hardening does not guarantee that objects are pure or immutable, so a hardened Map
, for example is superficially tamper-proof, but any party holding a reference to the object can both read and write its contents. Based on this precedent, and because TypedArray
instances cannot be frozen with Object.isFrozen
, harden
does not freeze
TypedArrays
and instead makes them non-extensible and makes all non-indexed properties non-writable and non-configurable. This is consistent with the treatment of Map
because the indexed properties represent mutable content and non-indexed properties represent the API.
Due to a defect in harden
, properties that have names that parse as numbers but are not the same as the canonical representation of those numbers, as in "+0"
and ""
which are both equivalent to their canonical number "0"
, remain writable after hardening.
Any program treating one of these properties as part of its API and relying on harden
to prevent modifications would be vulnerable to an API pollution attack, affecting only instances shared by mutually suspicious parties.
Unlike a Map
, a hardened TypedArray
can only have numbers for content. Any program that is sharing hardened TypedArrays
between co-tentant programs and relying on harden to only allow these programs to communicate exclusively by changing numbers within the bounds of the TypedArray, may inadvertently have arranged for a mechanism for a pair of third-parties to communicate arbitrary objects on these other properties.
Has the problem been patched? What versions should users upgrade to?
SES version 0.16.0 patches this issue, causing harden
to recognize properties with non-canonical numeric representations and ensuring that these properties are non-configurable.
Is there a way for users to fix or remediate the vulnerability without upgrading?
Users should avoid sharing TypedArrays
between co-tenant programs and instead create wrapper objects that produce a read-only view of the underlying data. We allow harden
to succeed for TypedArrays
because the treatment is in fact consistent with the behavior of collections like Map
, but all collections shared between co-tentant programs should probably be attenuated to either read- or write-only facets and probably close over only part of the content of the collection. However, the motivation for allowing TypedArrays
to be hardened in practice is to allow certain legacy modules to function under Hardened JavaScript with LavaMoat, since they export TypedArrays
, even though they would ideally export read-only facets of these.
Are there any links users can visit to find out more?
Not at this time.
If you have any questions or comments about this advisory: