CVE-2021-21301 (published 2021-02-11T18:15Z)

Wire is an open-source collaboration platform. In Wire for iOS (iPhone and iPad) before version 3.75 there is a vulnerability where the video capture isn't stopped in a scenario where a user first has their camera enabled and then disables it. It's a privacy issue because video is streamed to the call when the user believes it is disabled. It impacts all users in video calls. This is fixed in version 3.75.

Severity: MEDIUM
CVSS v2 base score: 4.3 (AV:N/AC:M/Au:N/C:P/I:N/A:N)
CVSS v3 base score: 4.3, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N)

Weakness information:
cwe_id: CWE-200
cwe_name: Exposure of Sensitive Information to an Unauthorized Actor
description: The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
extended_description: 
	   There are many different kinds of mistakes that introduce information exposures. The severity of the error can range widely, depending on the context in which the product operates, the type of sensitive information that is revealed, and the benefits it may provide to an attacker.  Some kinds of sensitive information include:
       
         private, personal information, such as personal messages, financial data, health records, geographic location, or contact details
         system status and environment, such as the operating system and installed packages
		 business secrets and intellectual property
		 network status and configuration
		 the product's own code or internal state
         metadata, e.g. logging of connections or message headers
		 indirect information, such as a discrepancy between two internal operations that can be observed by an outsider
       
	    Information might be sensitive to different parties, each of which may have their own expectations for whether the information should be protected.  These parties include:
               
                  the product's own users
                  people or organizations whose information is created or used by the product, even if they are not direct product users
		  the product's administrators, including the admins of the system(s) and/or networks on which the product operates
                  the developer
               
	    Information exposures can occur in different ways:
               
                  the code explicitly inserts sensitive information into resources or messages that are intentionally made accessible to unauthorized actors, but should not contain the information - i.e., the information should have been "scrubbed" or "sanitized"
                  a different weakness or mistake indirectly inserts the sensitive information into resources, such as a web script error revealing the full system path of the program.
                  the code manages resources that intentionally contain sensitive information, but the resources are unintentionally made accessible to unauthorized actors. In this case, the information exposure is resultant - i.e., a different weakness enabled the access to the information in the first place.
               
	    It is common practice to describe any loss of confidentiality as an "information exposure," but this can lead to overuse of CWE-200 in CWE mapping. From the CWE perspective, loss of confidentiality is a technical impact that can arise from dozens of different weaknesses, such as insecure file permissions or out-of-bounds read.  CWE-200 and its lower-level descendants are intended to cover the mistakes that occur in behaviors that explicitly manage, store, transfer, or cleanse sensitive information.
         
         

Fix information:
repo_url: https://github.com/wireapp/wire-ios
commit_details: repo_url: https://github.com/wireapp/wire-ios
author: David-Henner
author_date: 2021-02-02 09:15:56+01:00
msg: [Fix] video capture state (#4879)

* stop capture when there is no self video stream

* update capture state when needed

* update capture state on didMoveToWindow

* add tests
repository: repo_url: https://github.com/wireapp/wire-ios
repo_name: wireapp/wire-ios
description: 📱 Wire for iOS (iPhone and iPad)
repo_language: Swift
owner: wireapp
file_changes: filename: SelfVideoPreviewViewTests.swift
change_type: ModificationType.ADD
diff: @@ -0,0 +1,109 @@
+//
+// Wire
+// Copyright (C) 2021 Wire Swiss GmbH
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see http://www.gnu.org/licenses/.
+//
+
+import Foundation
+import XCTest
+import avs
+
+@testable import Wire
+
+class MockAVSVideoPreview: AVSVideoPreview {
+    var isCapturing: Bool = false
+    
+    override func startVideoCapture() {
+        isCapturing = true
+    }
+    
+    override func stopVideoCapture() {
+        isCapturing = false
+    }
+}
+
+class SelfVideoPreviewViewTests: XCTestCase {
+    var sut: SelfVideoPreviewView!
+    var stubProvider = VideoStreamStubProvider()
+    var previewViewMock = MockAVSVideoPreview()
+    
+    override func setUp() {
+        super.setUp()
+        
+        let stream = stubProvider.videoStream().stream
+        sut = SelfVideoPreviewView(stream: stream, isCovered: false, shouldShowActiveSpeakerFrame: false)
+        sut.previewView = previewViewMock
+    }
+    
+    override func tearDown() {
+        sut = nil
+        super.tearDown()
+    }
+    
+    func testCapturerState_ForVideoState_Started() {
+        // Given
+        previewViewMock.isCapturing = false
+
+        // When
+        sut.stream = stubProvider.videoStream(videoState: .started).stream
+
+        // Then
+        XCTAssertTrue(previewViewMock.isCapturing)
+    }
+    
+    func testCapturerState_ForVideoState_Stopped() {
+        // Given
+        previewViewMock.isCapturing = false
+        
+        // When
+        sut.stream = stubProvider.videoStream(videoState: .stopped).stream
+        
+        // Then
+        XCTAssertFalse(previewViewMock.isCapturing)
+    }
+    
+    func testCapturerState_ForVideoState_Paused() {
+        // Given
+        previewViewMock.isCapturing = false
+        
+        // When
+        sut.stream = stubProvider.videoStream(videoState: .paused).stream
+        
+        // Then
+        XCTAssertFalse(previewViewMock.isCapturing)
+    }
+    
+    func testCapturerState_ForVideoState_BadConnection() {
+        // Given
+        previewViewMock.isCapturing = false
+        
+        // When
+        sut.stream = stubProvider.videoStream(videoState: .badConnection).stream
+        
+        // Then
+        XCTAssertFalse(previewViewMock.isCapturing)
+    }
+    
+    func testCapturerState_ForVideoState_ScreenSharing() {
+        // Given
+        previewViewMock.isCapturing = false
+        
+        // When
+        sut.stream = stubProvider.videoStream(videoState: .screenSharing).stream
+        
+        // Then
+        XCTAssertFalse(previewViewMock.isCapturing)
+    }
+}

programming_language: Swift
filename: project.pbxproj
change_type: ModificationType.MODIFY
diff: @@ -453,6 +453,7 @@
 		636B716C23C39D6700B624D6 /* AppLockViewControllerSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 636B716923C39D0600B624D6 /* AppLockViewControllerSnapshotTests.swift */; };
 		636E57BD2386BFD9005B4FD8 /* AvailabilityStringBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 636E57BC2386BFD9005B4FD8 /* AvailabilityStringBuilderTests.swift */; };
 		6370DA212577934C00B5C8F1 /* PulsingIconImageViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6370DA202577934C00B5C8F1 /* PulsingIconImageViewTests.swift */; };
+		6372A0F225C8438B000CCB2D /* SelfVideoPreviewViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6372A0F125C8438A000CCB2D /* SelfVideoPreviewViewTests.swift */; };
 		6372AAA72492719100C5F307 /* GridCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6372AAA62492719100C5F307 /* GridCell.swift */; };
 		6372AAAA249A4F2600C5F307 /* Int+Even.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6372AAA9249A4F2600C5F307 /* Int+Even.swift */; };
 		638332EA250282D200D18F42 /* OrientationDelta.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638332E9250282D200D18F42 /* OrientationDelta.swift */; };
@@ -2072,6 +2073,7 @@
 		636B716923C39D0600B624D6 /* AppLockViewControllerSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockViewControllerSnapshotTests.swift; sourceTree = "<group>"; };
 		636E57BC2386BFD9005B4FD8 /* AvailabilityStringBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailabilityStringBuilderTests.swift; sourceTree = "<group>"; };
 		6370DA202577934C00B5C8F1 /* PulsingIconImageViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PulsingIconImageViewTests.swift; sourceTree = "<group>"; };
+		6372A0F125C8438A000CCB2D /* SelfVideoPreviewViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfVideoPreviewViewTests.swift; sourceTree = "<group>"; };
 		6372AAA62492719100C5F307 /* GridCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridCell.swift; sourceTree = "<group>"; };
 		6372AAA9249A4F2600C5F307 /* Int+Even.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+Even.swift"; sourceTree = "<group>"; };
 		638332E9250282D200D18F42 /* OrientationDelta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrientationDelta.swift; sourceTree = "<group>"; };
@@ -4243,6 +4245,7 @@
 				6340EF95237AE93500EF8506 /* VoiceChannelVideoStreamArrangmentTests.swift */,
 				6340660825B204B100C0B4BA /* VideoStreamStubProvider.swift */,
 				6391628B24F6A39D0054962E /* VideoPreviewViewTests.swift */,
+				6372A0F125C8438A000CCB2D /* SelfVideoPreviewViewTests.swift */,
 				16A94AF5209B04A5008A5718 /* GridViewTests.swift */,
 				164B533B20A0A5E800EC8265 /* CallInfoConfigurationTests.swift */,
 				D58192042091F34E003BA7EC /* CallActionsViewTests.swift */,
@@ -8524,6 +8527,7 @@
 				EFB23D0B1FC853CF0055B866 /* AccessoryTextFieldValidationTests.swift in Sources */,
 				EEAC654C206BD64700365C0C /* LinkInteractionTextViewTests.swift in Sources */,
 				5501FFAB22B28F330050D8FC /* MockSelfLegalHoldSubject.swift in Sources */,
+				6372A0F225C8438B000CCB2D /* SelfVideoPreviewViewTests.swift in Sources */,
 				5E8FFC0621ECCC7C0052DF03 /* AuthenticationInterfaceBuilderTests.swift in Sources */,
 				5EE115E1204EEC7D002AD6C2 /* CallQualityControllerTests.swift in Sources */,
 				EFE043992149CE8D00BC3079 /* ContactsViewControllerSnapshotTests.swift in Sources */,

programming_language: Swift
filename: SelfVideoPreviewView.swift
change_type: ModificationType.MODIFY
diff: @@ -22,8 +22,15 @@ import avs
 
 final class SelfVideoPreviewView: BaseVideoPreviewView {
     
-    private let previewView = AVSVideoPreview()
+    var previewView = AVSVideoPreview()
         
+    override var stream: Stream {
+        didSet {
+            guard stream != oldValue else { return }
+            updateCaptureState()
+        }
+    }
+    
     deinit {
         stopCapture()
     }
@@ -54,10 +61,14 @@ final class SelfVideoPreviewView: BaseVideoPreviewView {
         super.didMoveToWindow()
         
         if window != nil {
-            startCapture()
+            updateCaptureState()
         }
     }
     
+    private func updateCaptureState() {
+        stream.videoState == .some(.started) ? startCapture() : stopCapture()
+    }
+    
     func startCapture() {
         previewView.startVideoCapture()
     }

programming_language: Swift
filename: VideoGridViewController.swift
change_type: ModificationType.MODIFY
diff: @@ -184,10 +184,10 @@ final class VideoGridViewController: UIViewController {
     }
 
     private func updateSelfPreview() {
-        guard
-            let selfStreamId = ZMUser.selfUser()?.selfStreamId,
-            let selfStream = stream(with: selfStreamId)
-        else {
+        guard let selfStreamId = ZMUser.selfUser()?.selfStreamId else { return }
+
+        guard let selfStream = stream(with: selfStreamId) else {
+            (viewCache[selfStreamId] as? SelfVideoPreviewView)?.stopCapture()
             return
         }
 

programming_language: Swift