From 3d59f0eec2d619bc9d1d64a16da7c2d7d2dc7409 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Mon, 20 Jul 2026 12:45:37 +0800 Subject: [PATCH] uaf: Fix potential UAF from js-created CookieChangeEvent Add WebDriver.getNamedCookie to give WPT access to http-only cookie. --- src/browser/tests/cookie_store.html | 13 +++++ src/browser/webapi/WebDriver.zig | 47 +++++++++++++++++++ .../webapi/event/CookieChangeEvent.zig | 25 +++++++++- src/browser/webapi/storage/CookieStore.zig | 32 +++++++++---- 4 files changed, 105 insertions(+), 12 deletions(-) diff --git a/src/browser/tests/cookie_store.html b/src/browser/tests/cookie_store.html index b1420a0d3..c933f67f1 100644 --- a/src/browser/tests/cookie_store.html +++ b/src/browser/tests/cookie_store.html @@ -21,6 +21,7 @@ await state.done(() => { testing.expectEqual('user', item.name); testing.expectEqual('lp', item.value); + // We follow Chrome and expose the full attribute set, not just name/value. testing.expectEqual('/', item.path); testing.expectEqual('strict', item.sameSite); testing.expectEqual(null, item.expires); @@ -162,6 +163,18 @@ testing.expectEqual('change', ev.type); testing.expectEqual(0, ev.changed.length); testing.expectEqual(0, ev.deleted.length); + + // The changed/deleted lists must be copied off the transient call arena; + // reading them after construction must stay valid. + const ev2 = new CookieChangeEvent('change', { + changed: [{ name: 'c1', value: 'v1' }, { name: 'c2', value: 'v2' }], + deleted: [{ name: 'd1', value: 'w1' }], + }); + testing.expectEqual(2, ev2.changed.length); + testing.expectEqual('c1', ev2.changed[0].name); + testing.expectEqual('v2', ev2.changed[1].value); + testing.expectEqual(1, ev2.deleted.length); + testing.expectEqual('d1', ev2.deleted[0].name);