Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e25c1eebf37b2ecd34e67bf4606c33f7bd1d3769
https://github.com/WebKit/WebKit/commit/e25c1eebf37b2ecd34e67bf4606c33f7bd1d3769
Author: Chris Dumez <[email protected]>
Date: 2026-07-27 (Mon, 27 Jul 2026)
Changed paths:
M Source/WebKit/Scripts/IPCTestingHeaders-input.xcfilelist
M Source/WebKit/Scripts/IPCTestingHeaders-output.xcfilelist
M Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp
M Source/WebKit/UIProcess/DeviceIdHashSaltStorage.h
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebKit/DeviceIdHashSaltStorage.cpp
Log Message:
-----------
DeviceIdHashSaltStorage generates hash salts shorter than the validated length
https://bugs.webkit.org/show_bug.cgi?id=320077
Reviewed by Youenn Fablet.
The device-ID hash salt is built by concatenating the hex representation of
`randomDataSize` (hashSaltSize / 16 = 3) random uint64_t values, expecting
3 * 16 = 48 hex characters to match hashSaltSize. However, hex(number) defaults
to minimumDigits = 0, so it emits only the significant hex digits: a value such
as 0x00000000000000AB produces "AB" rather than a zero-padded 16 characters. A
64-bit value yields 16 digits only when its top nibble is non-zero, so all three
values produce a 48-character salt only ~82% of the time. The remaining ~18% of
generated salts are shorter than 48 characters.
Because the salt is also used as the on-disk filename, loadStorageFromDisk()
rejects any file whose salt length != hashSaltSize on the next launch, silently
discarding and regenerating the per-origin salt and defeating its cross-launch
persistence.
Pad each value to a fixed 16 hex digits with `hex(number, 16)` so the salt is
always exactly 48 characters and survives the reload length check. Existing
48-character salts on disk continue to load unchanged.
* Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp:
(WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall):
* Source/WebKit/UIProcess/DeviceIdHashSaltStorage.h:
(WebKit::createDeviceIdHashSaltString):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/DeviceIdHashSaltStorage.cpp: Added.
(TestWebKitAPI::TEST(DeviceIdHashSaltStorage, GeneratedSaltHasExpectedLength)):
(TestWebKitAPI::TEST(DeviceIdHashSaltStorage, SaltStringHasFixedWidth)):
* Source/WebKit/Scripts/IPCTestingHeaders-input.xcfilelist:
* Source/WebKit/Scripts/IPCTestingHeaders-output.xcfilelist:
Canonical link: https://commits.webkit.org/317965@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications