Skip to content

Safe Promise capabilities #6

@mhofman

Description

@mhofman

Given the feedback of #4, the discussion in #3 and in plenary led towards a potential "explicit" solution where a safe promise capability could be used selectively for places that must guarantee no reentrancy when handling a resolution value (and potentially this safe promise to be the default for spec operations).

From reading https://bugzilla.mozilla.org/show_bug.cgi?id=1923344, it is also my understanding it would be the only approach that would have protected against CVE-2024-9680 since the value there (an Animation) was expected to be thenable.

The precise behavior of the resolution functions of such a safe promise capability can be debated, but basically they must guarantee that no user code can be synchronously called. I am of the opinion that the sane approach is to delay by a tick in those cases, and to not introduce promises that fulfill to thenables (#5).

How such a safe promise capability is created is also up to debate. One option would be a new %SafePromise% constructor which reveals these safe resolution functions. Such a safe promise instance could maintain the appearance of being a regular %Promise% by having %SafePromise%.prototype = %PromisePrototype%, but that might interact negatively with the PromiseResolve mitigation also in scope (see tc39/ecma262#3662 (comment)) if we ever expose this %SafePromise% constructor to users (or expect spec code to call PromiseResolve with it)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions