CVE-2022-31009: Reachable Assertion (CWE-617)
value: wire-ios is an iOS client for the Wire secure messaging application. Invalid accent colors of Wire communication partners may render the iOS Wire Client partially unusable by causing it to crash multiple times on launch. These invalid accent colors can be used by and sent between Wire users. The root cause was an unnecessary assert statement when converting an integer value into the corresponding enum value, causing an exception instead of a fallback to a default value. This issue is fixed in [wire-ios](https://github.com/wireapp/wire-ios/commit/caa0e27dbe51f9edfda8c7a9f017d93b8cfddefb) and in Wire for iOS 3.100. There is no workaround available, but users may use other Wire clients (such as the [web app](https://app.wire.com)) to continue using Wire, or upgrade their client.
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: 6.5
Published: 2022-06-23T07:15Z
Repository: https://github.com/wireapp/wire-ios
Language: Swift
Files changed: Wire-iOS/Sources/Helpers/ColorScheme.swift
Commit date: 2022-05-10 15:08:34 +0200
Commit message: chore: remove unnecessary assert SQCORE-1299 (#5660)

* chore: remove unnecessary assert

* empty
Diff: diff --git a/Wire-iOS/Sources/Helpers/ColorScheme.swift b/Wire-iOS/Sources/Helpers/ColorScheme.swift
index 3f24684afb..c925cfa762 100644
--- a/Wire-iOS/Sources/Helpers/ColorScheme.swift
+++ b/Wire-iOS/Sources/Helpers/ColorScheme.swift
@@ -17,10 +17,11 @@
 //
 
 import Foundation
 import UIKit
 import WireUtilities
+import WireCommonComponents
 
 @objc
 enum ColorSchemeVariant: UInt {
     case light, dark
 }
@@ -316,18 +317,15 @@ extension UIColor {
     private static let accentColorNameColorBlendingCoefficientsDark: [CGFloat] = [0.8, 0.8, 0.72, 1.0, 0.8, 0.8, 0.8, 0.64]
     private static let accentColorNameColorBlendingCoefficientsLight: [CGFloat] = [0.8, 0.8, 0.72, 1.0, 0.8, 0.8, 0.64, 1.0]
 
     /// Creates UIColor instance with color corresponding to @p accentColor that can be used to display the name.
     class func nameColor(for accentColor: ZMAccentColor, variant: ColorSchemeVariant) -> UIColor {
-
-        assert(accentColor.rawValue <= ZMAccentColor.max.rawValue)
-
+        let accentColor = AccentColor(ZMAccentColor: accentColor) ?? .strongBlue
         let coefficientsArray = variant == .dark ? accentColorNameColorBlendingCoefficientsDark : accentColorNameColorBlendingCoefficientsLight
         let coefficient = coefficientsArray[Int(accentColor.rawValue)]
-
         let background: UIColor = variant == .dark ? .black : .white
-        return background.mix(UIColor(fromZMAccentColor: accentColor), amount: coefficient)
+        return background.mix(UIColor(for: accentColor), amount: coefficient)
     }
 }
 
 extension ColorSchemeVariant {
     func mainColor(color: UIColor?) -> UIColor {

Vulnerable code: 
        assert(accentColor.rawValue <= ZMAccentColor.max.rawValue)


        return background.mix(UIColor(fromZMAccentColor: accentColor), amount: coefficient)
Fixed code: import WireCommonComponents
        let accentColor = AccentColor(ZMAccentColor: accentColor) ?? .strongBlue
        return background.mix(UIColor(for: accentColor), amount: coefficient)