1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2026-01-12 22:41:00 +00:00
serenity/Userland
Luke Wilde 7e701f6256 LibWeb: Keep unhandledrejection event promises alive when task is queued
This is fixed by making the "about to be notified rejected promises
list" use JS::Handle instead of JS::NonnullGCPtr. This UAF happens
because notify_about_rejected_promises makes a local copy of this list,
empties the member variable list and then moves the local copy into a
JS::SafeFunction lambda. JS::SafeFunction can only see GC pointers that
are in its storage, not external storage.

Example exploit (requires fixed microtask timing by removing the dummy
execution context):
```html
<script>
Promise.reject(new Error);

// Exit the script block, causing a microtask checkpoint and thus
// queuing of a task to fire the unhandled rejection event for the
// above promise.
// During the time after being queued but before being ran, these
// promises are not kept alive. This is because JS::SafeFunction cannot
// see into a Vector, meaning it can't visit the stored NonnullGCPtrs.
</script>

<script defer>
// Cause a garbage collection, destroying the above promise.
const b = [];
for (var i = 0; i < 200000; i++)
    b.push({});

// Some time after this script block, the queued unhandled rejection
// event task will fire, with the event object containing the dead
// promise.
window.onunhandledrejection = (event) => {
    let value = event.promise;
    console.log(value);
}
</script>
```
2022-12-25 15:32:51 +01:00
..
Applets LibCore: Rename Stream::read_all to read_until_eof 2022-12-12 14:16:42 +01:00
Applications TextEditor: Add option to open the current file in File Manager 2022-12-23 19:20:53 -05:00
BuggieBox Userland: Add the BuggieBox program 2022-11-26 12:41:47 -07:00
Demos CatDog: Simplify animation frame logic and fix minor bugs 2022-12-16 08:50:35 -07:00
DevTools HackStudio: Make a new ProjectBuilder object when opening a project 2022-12-23 23:27:45 +01:00
DynamicLoader AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
Games Snake: Use a statusbar to display the current and high score 2022-12-23 23:26:21 +01:00
Libraries LibWeb: Keep unhandledrejection event promises alive when task is queued 2022-12-25 15:32:51 +01:00
Services LibConfig+LibCore+ConfigServer: Support u32 configuration entries 2022-12-23 23:26:21 +01:00
Shell Shell: Disable interactive mode on '-c' 2022-12-12 13:57:06 +00:00
Utilities pro: Add ability to log request/response metadata for HTTP URLs 2022-12-23 23:29:57 +01:00
CMakeLists.txt Userland: Add the BuggieBox program 2022-11-26 12:41:47 -07:00