Title: [277658] trunk/Source/WebKit
- Revision
- 277658
- Author
- [email protected]
- Date
- 2021-05-18 10:04:34 -0700 (Tue, 18 May 2021)
Log Message
Add nil checks for LAContexts before inserting them in the dictionaries.
https://bugs.webkit.org/show_bug.cgi?id=225897
Patch by Garrett Davidson <[email protected]> on 2021-05-18
Reviewed by Tim Horton.
In 225218 we stopped dropping requests that didn't have LAContexts. However, that let us
proceed only until we tried to put the (nil) LAContext in an NSDictionary to make a Sec*
call, which throws an exception. This patch adds proper nil checking before inserting the
contexts into the dictionaries.
Manually tested registration and assertion on macOS with and without LAContexts.
* UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
(WebKit::LocalAuthenticator::continueGetAssertionAfterUserVerification):
* UIProcess/WebAuthentication/Cocoa/LocalConnection.mm:
(WebKit::LocalConnection::createCredentialPrivateKey const):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (277657 => 277658)
--- trunk/Source/WebKit/ChangeLog 2021-05-18 17:03:38 UTC (rev 277657)
+++ trunk/Source/WebKit/ChangeLog 2021-05-18 17:04:34 UTC (rev 277658)
@@ -1,3 +1,22 @@
+2021-05-18 Garrett Davidson <[email protected]>
+
+ Add nil checks for LAContexts before inserting them in the dictionaries.
+ https://bugs.webkit.org/show_bug.cgi?id=225897
+
+ Reviewed by Tim Horton.
+
+ In 225218 we stopped dropping requests that didn't have LAContexts. However, that let us
+ proceed only until we tried to put the (nil) LAContext in an NSDictionary to make a Sec*
+ call, which throws an exception. This patch adds proper nil checking before inserting the
+ contexts into the dictionaries.
+
+ Manually tested registration and assertion on macOS with and without LAContexts.
+
+ * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+ (WebKit::LocalAuthenticator::continueGetAssertionAfterUserVerification):
+ * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm:
+ (WebKit::LocalConnection::createCredentialPrivateKey const):
+
2021-05-18 Chris Dumez <[email protected]>
ReadOnlySharedRingBufferStorage::updateFrameBounds() should validate boundsBufferSize
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (277657 => 277658)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2021-05-18 17:03:38 UTC (rev 277657)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2021-05-18 17:04:34 UTC (rev 277658)
@@ -602,12 +602,10 @@
RetainPtr<CFDataRef> signature;
auto nsCredentialId = toNSData(response->rawId());
{
- auto query = adoptNS([[NSMutableDictionary alloc] init]);
- [query setDictionary:@{
+ NSMutableDictionary *queryDictionary = [@{
(id)kSecClass: (id)kSecClassKey,
(id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
(id)kSecAttrApplicationLabel: nsCredentialId.get(),
- (id)kSecUseAuthenticationContext: context,
(id)kSecReturnRef: @YES,
#if HAVE(DATA_PROTECTION_KEYCHAIN)
(id)kSecUseDataProtectionKeychain: @YES
@@ -614,7 +612,12 @@
#else
(id)kSecAttrNoLegacy: @YES
#endif
- }];
+ } mutableCopy];
+
+ if (context)
+ queryDictionary[(id)kSecUseAuthenticationContext] = context;
+
+ auto query = adoptNS(queryDictionary);
updateQueryIfNecessary(query.get());
CFTypeRef privateKeyRef = nullptr;
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm (277657 => 277658)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm 2021-05-18 17:03:38 UTC (rev 277657)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm 2021-05-18 17:04:34 UTC (rev 277658)
@@ -159,18 +159,26 @@
RetainPtr<SecKeyRef> LocalConnection::createCredentialPrivateKey(LAContext *context, SecAccessControlRef accessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const
{
+ NSDictionary *privateKeyAttributes = @{
+ (id)kSecAttrAccessControl: (id)accessControlRef,
+ (id)kSecAttrIsPermanent: @YES,
+ (id)kSecAttrAccessGroup: (id)String(LocalAuthenticatiorAccessGroup),
+ (id)kSecAttrLabel: secAttrLabel,
+ (id)kSecAttrApplicationTag: secAttrApplicationTag,
+ };
+
+ if (context) {
+ privateKeyAttributes = [privateKeyAttributes mutableCopy];
+ ((NSMutableDictionary *)privateKeyAttributes)[(id)kSecUseAuthenticationContext] = context;
+ }
+
NSDictionary *attributes = @{
(id)kSecAttrTokenID: (id)kSecAttrTokenIDSecureEnclave,
(id)kSecAttrKeyType: (id)kSecAttrKeyTypeECSECPrimeRandom,
(id)kSecAttrKeySizeInBits: @256,
- (id)kSecPrivateKeyAttrs: @{
- (id)kSecUseAuthenticationContext: context,
- (id)kSecAttrAccessControl: (id)accessControlRef,
- (id)kSecAttrIsPermanent: @YES,
- (id)kSecAttrAccessGroup: (id)String(LocalAuthenticatiorAccessGroup),
- (id)kSecAttrLabel: secAttrLabel,
- (id)kSecAttrApplicationTag: secAttrApplicationTag,
- }};
+ (id)kSecPrivateKeyAttrs: privateKeyAttributes,
+ };
+
LOCAL_CONNECTION_ADDITIONS
CFErrorRef errorRef = nullptr;
auto credentialPrivateKey = adoptCF(SecKeyCreateRandomKey((__bridge CFDictionaryRef)attributes, &errorRef));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes