You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason this particular issue is fingered for causing security vulnerabities is
40
+
The reason this particular issue is fingered for causing security vulnerabilities is
41
41
that it adds many paths for user code execution which otherwise don't exist, and
42
-
is not always obviously a possbility.
42
+
is not always obviously a possibility.
43
43
44
44
Of particular danger is where specification authors think of newborn objects of known
45
45
types as known quantities, only to call `Promise.resolve` on them. At this point
@@ -51,22 +51,23 @@ exist purely to work out the expected behaviour [for someone breaking `then`](ht
51
51
52
52
## How do I propose we fix this?
53
53
54
-
I'd like to propose we add a "Safe Resolve" resolve operation. It is functionally identical to
55
-
[`PromiseResolve`](https://tc39.es/ecma262/#sec-promise-resolve) except there is a pre-step where
56
-
we check for the conditions under which we could run user-code. If we cannot run any user code, we simply
57
-
tail-call into `PromiseResolve`. If we *could* run user-code, we instead enqueue a new job whose
58
-
responsibility is to call into `PromiseResolve`, while also putting the promise into a 'parked' state
59
-
such that any future resolutions are ignored (Thank you very much to Mark Miller for catching this
60
-
requirement in TG3 review discussion).
54
+
I'd like to propose we add a "SafeResolve" resolve operation, which resolves a promise after
55
+
checking for the possibility of running user code. If we cannot run any user code, we simply
56
+
tail-call into the promise capability's `[[Resolve]]` operation. If we *could* run user-code,
57
+
we instead enqueue a new job whose responsibility is to resolve the promise while also latching
58
+
the promise in the same way the regular resolve functions do, such that any future resolutions
59
+
are ignored (Thank you very much to Mark Miller for catching this requirement in TG3 review discussion).
61
60
62
61
The next step is to decide how to consume this. There is interest from the Mozilla DOM to explore
63
62
using this to replace [the steps for resolving a promise in WebIDL](https://webidl.spec.whatwg.org/#resolve)
64
63
and more generally powering all the promise resolution code in Mozilla's DOM. This would help make
65
64
C++ code safer by making promise resolution into an operation that never runs script, which
66
65
simplifies the reasoning required when implementing code.
67
66
68
-
Exposing this to user-code is a non-goal of this specific proposal, but can be done as a followup
69
-
proposal eventually
67
+
Specification discussion about WebIDL consumption is happening at [whatwg/webidl #1584](https://github.com/whatwg/webidl/issues/1584)
68
+
69
+
**Exposing this to user-code is a non-goal of this specific proposal**, but can be done as a followup
70
+
proposal eventually.
70
71
71
72
## Is this a bulletproof fix?
72
73
@@ -108,7 +109,7 @@ The vast majority of tests (as expected) pass.
108
109
109
110
#### Unexpected Pass:
110
111
111
-
1.[/fetch/api/response/response-body-read-task-handling.html](https://searchfox.org/firefox-main/source/testing/web-platform/tests/fetch/api/response/response-body-read-task-handling.html)\- This test is using `then` to get insight into execution order. The test no longer tests what it thinks it is testing anymore; however the test \-also- was created to address [this kind of thennable issue](https://bugzilla.mozilla.org/show_bug.cgi?id=1612308).
112
+
1.[/fetch/api/response/response-body-read-task-handling.html](https://searchfox.org/firefox-main/source/testing/web-platform/tests/fetch/api/response/response-body-read-task-handling.html)\- This test is using `then` to get insight into execution order. The test no longer tests what it thinks it is testing anymore; however the test \-also- was created to address [this kind of thenable issue](https://bugzilla.mozilla.org/show_bug.cgi?id=1612308).
_then_: a JobCallback Record or a function object,
150
-
): either a normal completion containing *undefined* or a throw completion
147
+
): either a normal completion containing an ECMAScript language value or a throw completion
151
148
</h1>
152
149
<dl class="header">
153
150
</dl>
@@ -175,7 +172,7 @@ contributors: Matthew Gaudet
175
172
</dl>
176
173
<emu-alg>
177
174
1. Let _promiseOrEmpty_ be the Record { [[Value]]: _toResolve_ }.
178
-
1. Let _resolveSteps_ be a new Abstract Closure with parameters (_resolution_<ins>, _doSafeResolve_</ins>) that captures _promiseOrEmpty_ and performs the following steps when called:
175
+
1. Let _resolveSteps_ be a new Abstract Closure with parameters (_resolution_) that captures _promiseOrEmpty_ and performs the following steps when called:
179
176
1. If _promiseOrEmpty_.[[Value]] is ~empty~, return *undefined*.
0 commit comments