Proposal: Curtailing the power of "Thenables"
Matthew Gaudet, Mozilla
Reminder: What are Thenables
What’s the problem here?
Basically: It is easy for implementers of web-specifications, engines and specification writers to forget that this behaviour exists, and accidentally introduce user-controlled execution in places it wasn’t expected:
For example: calling Promise.resolve on a newly created WebIDL dictionary type?
Seems safe?
Oops. Dictionaries convert to objects with [[Prototype]] set to Object.prototype – accidental user code execution
What’s the problem here?
Result: CVE after CVE
Stage 0 to 1 Ask: Can we do anything here?
CVE-2024-43357 Fixes
During remediation of CVE-2024-43357 (The Spec CVE) a couple fixes were proposed that helped here:
A Possible Third Path
I would propose a third solution:
Some Advantages
Does this solve everything?
Nope. This is a mitigation, an attempt to make easy-to-make errors safer. It does not address the whole class of “thenable” problems.
Compatibility
In preparation for this proposal I added some telemetry to Firefox to see what roughly we could expect as far as problems go.
Date | Thenable % | Thenable on Proto % | Thenable on Standard Proto % |
2025-02-04 | 2.27 | 2.00 | 0.13 |
2025-02-03 | 2.31 | 2.04 | 0.12 |
2025-02-02 | 2.39 | 2.12 | 0.11 |
2025-02-01 | 2.25 | 2.00 | 0.12 |
(If this goes to Stage 1 I would likely add telemetry for “Holder is Object.prototype”)
Other solutions welcome!
Stage 0 to 1 isn’t about “I have a solution”, it’s about problem identification.
I’m interested in more discussion, other solutions etc.
Stage 1?