Skip to content

Commit bc91259

Browse files
authored
browser(webkit): use random ephemeral session ids on Mac (#881)
1 parent 06a7d7e commit bc91259

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1136
1+
1137

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,35 @@ index a256d2f8a42548c42ae3c955d9502cc0ad893d91..7e30dfcec151304b21b39286a841e38e
13151315
return false;
13161316
}
13171317

1318+
diff --git a/Source/WebCore/PAL/pal/SessionID.cpp b/Source/WebCore/PAL/pal/SessionID.cpp
1319+
index 6b30b4a06bab48ca69e4955e52cb4162bb20780f..ea94293a0bb15b4dd1aa85706f97030f4fe50de1 100644
1320+
--- a/Source/WebCore/PAL/pal/SessionID.cpp
1321+
+++ b/Source/WebCore/PAL/pal/SessionID.cpp
1322+
@@ -27,11 +27,11 @@
1323+
#include "SessionID.h"
1324+
1325+
#include <wtf/MainThread.h>
1326+
+#include <wtf/CryptographicallyRandomNumber.h>
1327+
1328+
namespace PAL {
1329+
1330+
static uint64_t currentPersistentID = SessionID::DefaultSessionID;
1331+
-static uint64_t currentEphemeralID = SessionID::LegacyPrivateSessionID;
1332+
static bool generationProtectionEnabled;
1333+
1334+
SessionID SessionID::generatePersistentSessionID()
1335+
@@ -47,7 +47,10 @@ SessionID SessionID::generateEphemeralSessionID()
1336+
ASSERT(isMainThread());
1337+
RELEASE_ASSERT(!generationProtectionEnabled);
1338+
1339+
- return SessionID(++currentEphemeralID);
1340+
+ uint64_t sessionId;
1341+
+ cryptographicallyRandomValues(&sessionId, sizeof(sessionId));
1342+
+ sessionId = sessionId | SessionConstants::EphemeralSessionMask;
1343+
+ return SessionID(sessionId);
1344+
}
1345+
1346+
void SessionID::enableGenerationProtection()
13181347
diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt
13191348
index 4de75df8df0b8f90e5b258157eada4a69d3b5916..51dc93bc25fdba7a971b3fdd4f1f380f5d6b48c5 100644
13201349
--- a/Source/WebCore/SourcesCocoa.txt
@@ -5681,7 +5710,7 @@ index 0000000000000000000000000000000000000000..b64d1a6d54ec15a99164294706543cee
56815710
+
56825711
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.mm
56835712
new file mode 100644
5684-
index 0000000000000000000000000000000000000000..2db4356a7b26d91e50a8bb73b5b0d9d2b231c1cb
5713+
index 0000000000000000000000000000000000000000..f31834b80328fc5c182c64de53ff51e4065c62a9
56855714
--- /dev/null
56865715
+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.mm
56875716
@@ -0,0 +1,52 @@
@@ -5716,7 +5745,7 @@ index 0000000000000000000000000000000000000000..2db4356a7b26d91e50a8bb73b5b0d9d2
57165745
+#include "BrowserInspectorPipe.h"
57175746
+#include "InspectorBrowserAgentClientMac.h"
57185747
+#include "PageClientImplMac.h"
5719-
+#include "WebsiteDataStore.h"
5748+
+#include "WebKit2Initialize.h"
57205749
+
57215750
+#import "WKWebView.h"
57225751
+
@@ -5727,7 +5756,7 @@ index 0000000000000000000000000000000000000000..2db4356a7b26d91e50a8bb73b5b0d9d2
57275756
++ (void)initializeRemoteInspectorPipe:(id<_WKBrowserInspectorDelegate>)delegate headless:(BOOL)headless
57285757
+{
57295758
+#if ENABLE(REMOTE_INSPECTOR)
5730-
+ WebsiteDataStore::defaultDataStore();
5759+
+ InitializeWebKit2();
57315760
+ PageClientImpl::setHeadless(headless);
57325761
+ initializeBrowserInspectorPipe(makeUnique<InspectorBrowserAgentClientMac>(delegate));
57335762
+#endif

0 commit comments

Comments
 (0)