CVE-2021-43849: Reachable Assertion (CWE-617)
value: cordova-plugin-fingerprint-aio is a plugin provides a single and simple interface for accessing fingerprint APIs on both Android 6+ and iOS. In versions prior to 5.0.1 The exported activity `de.niklasmerz.cordova.biometric.BiometricActivity` can cause the app to crash. This vulnerability occurred because the activity didn't handle the case where it is requested with invalid or empty data which results in a crash. Any third party app can constantly call this activity with no permission. A 3rd party app/attacker using event listener can continually stop the app from working and make the victim unable to open it. Version 5.0.1 of the cordova-plugin-fingerprint-aio doesn't export the activity anymore and is no longer vulnerable. If you want to fix older versions change the attribute android:exported in plugin.xml to false. Please upgrade to version 5.0.1 as soon as possible.
CWE description: The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.
CVSS v3 base score: 5.5
Published: 2021-12-23T17:15Z
Repository: https://github.com/NiklasMerz/cordova-plugin-fingerprint-aio
Language: Swift
Files changed: src/ios/Fingerprint.swift
Commit date: 2021-12-21 15:25:21 +0100
Commit message: Update Fingerprint.swift

fix crash issue on device
Diff: diff --git a/src/ios/Fingerprint.swift b/src/ios/Fingerprint.swift
index a207db1..6ca81a9 100644
--- a/src/ios/Fingerprint.swift
+++ b/src/ios/Fingerprint.swift
@@ -1,5 +1,6 @@
+import Cordova
 import Foundation
 import LocalAuthentication
 
 enum PluginError:Int {
     case BIOMETRIC_UNKNOWN_ERROR = -100
@@ -50,10 +51,12 @@ enum PluginError:Int {
                     biometryType = "none";
                 case .touchID:
                     biometryType = "finger";
                 case .faceID:
                     biometryType = "face"
+                @unknown default:
+                    fatalError()
                 }
             }
 
             pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: biometryType);
         }else{
@@ -141,11 +144,11 @@ enum PluginError:Int {
         let data  = command.arguments[0] as AnyObject?;
         var pluginResult: CDVPluginResult
         do {
             let secret = Secret()
             try? secret.delete()
-            let invalidateOnEnrollment = (data?["invalidateOnEnrollment"] as? Bool) ?? false
+            let invalidateOnEnrollment = (data?.object(forKey: "invalidateOnEnrollment") as? Bool) ?? false
             try secret.save(secretStr, invalidateOnEnrollment: invalidateOnEnrollment)
             pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "Success");
         } catch {
             let errorResult = ["code": PluginError.BIOMETRIC_UNKNOWN_ERROR.rawValue, "message": error.localizedDescription] as [String : Any];
             pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: errorResult);
@@ -156,11 +159,11 @@ enum PluginError:Int {
 
 
     func loadSecret(_ command: CDVInvokedUrlCommand) {
         let data  = command.arguments[0] as AnyObject?;
         var prompt = "Authentication"
-        if let description = data?["description"] as! String? {
+        if let description = data?.object(forKey: "description") as! String? {
             prompt = description;
         }
         var pluginResult: CDVPluginResult
         do {
             let result = try Secret().load(prompt)
@@ -184,11 +187,11 @@ enum PluginError:Int {
     }
 
     @objc(registerBiometricSecret:)
     func registerBiometricSecret(_ command: CDVInvokedUrlCommand){
         let data  = command.arguments[0] as AnyObject?;
-        if let secret = data?["secret"] as? String {
+        if let secret = data?.object(forKey: "secret") as? String {
             self.saveSecret(secret, command: command)
             return
         }
     }
 

Vulnerable code:             let invalidateOnEnrollment = (data?["invalidateOnEnrollment"] as? Bool) ?? false
        if let description = data?["description"] as! String? {
        if let secret = data?["secret"] as? String {
Fixed code: import Cordova
                @unknown default:
                    fatalError()
            let invalidateOnEnrollment = (data?.object(forKey: "invalidateOnEnrollment") as? Bool) ?? false
        if let description = data?.object(forKey: "description") as! String? {
        if let secret = data?.object(forKey: "secret") as? String {