Skip to content

fix: recover MLS conversations after key-package exhaustion - WPB-27395 🍒 - #5119

Open
johnxnguyen wants to merge 2 commits into
release/cycle-4.16from
chore/cherry-pick-wpb-27395
Open

fix: recover MLS conversations after key-package exhaustion - WPB-27395 🍒#5119
johnxnguyen wants to merge 2 commits into
release/cycle-4.16from
chore/cherry-pick-wpb-27395

Conversation

@johnxnguyen

@johnxnguyen johnxnguyen commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator
BugWPB-27395 [iOS] Recover MLS conversations after key-package exhaustion

Issue

Cherrypick of #5074

Testing

See original PR.


Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

…95 (#5074)

# Conflicts:
#	wire-ios-data-model/Source/Model/Conversation/ZMConversation+Messaging.swift
let conversation = ZMConversation.insertNewObject(in: uiMOC)
conversation.remoteIdentifier = UUID()
conversation.domain = self.localDomain
conversation.mlsGroupID = .random()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep identified an issue, but thinks it may be safe to ignore.
The App uses an insecure Random Number Generator.

Why this might be safe to ignore:

This match is in a unit test, where .random() is only used to create test data for a conversation group ID. The rule is intended to catch insecure randomness in security-sensitive production code, and this usage does not affect real application security.

To resolve this comment:

🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by ios_insecure_random_no_generator.

You can view more details about this finding in the Semgrep AppSec Platform.

@semgrep-code-wireapp

Copy link
Copy Markdown

Semgrep found 1 ios_insecure_random_no_generator finding:

  • wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift

The App uses an insecure Random Number Generator.

@johnxnguyen
johnxnguyen marked this pull request as ready for review August 17, 2026 07:28
Copilot AI lite review requested due to automatic review settings August 17, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an automatic recovery path for pending MLS (and mixed-protocol) conversations after quick sync, targeting scenarios where offline clients miss Welcome messages due to key-package exhaustion. It integrates recovery into the sync lifecycle and updates the MLS data layer and tests to support the new behavior.

Changes:

  • Trigger pending-conversation recovery after incremental sync completes (foreground/active only), alongside key-package refills.
  • Add recoverPendingConversationBatchIfNeeded() to MLSServiceInterface and implement a batched recovery mechanism in MLSService.
  • Update Core Data fetch predicates to support filtering by message protocol (MLS + mixed) and exclude remotely-deleted conversations; update mocks/tests accordingly.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTests.swift Updates quick-sync test to assert pending-conversation recovery behavior while active vs background.
wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift Runs pending-conversation recovery in a loop after quick sync when app is active.
wire-ios-data-model/Tests/MLS/MLSServiceTests.swift Adds/adjusts tests for batched pending recovery and key-package backend-count gating.
wire-ios-data-model/Support/Sourcery/generated/AutoMockable.generated.swift Adds mock support for recoverPendingConversationBatchIfNeeded().
wire-ios-data-model/Source/Model/Conversation/ZMConversation+Messaging.swift Extends MLS-status fetch to filter by protocol(s), require MLS group ID, and exclude deleted conversations.
wire-ios-data-model/Source/MLS/MLSServiceInterface.swift Adds the new recovery API to the MLS service protocol.
wire-ios-data-model/Source/MLS/MLSService.swift Implements batched pending recovery + adjusts key-package upload behavior when pending recovery exists.
wire-ios-data-model/Source/MLS/MLSClientManager.swift Removes performPendingJoins() call from MLS client update path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}

// Return whether another batch should be processed immediately.
return recovered == batch.count && pendingConversations.count > batch.count
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Test Results

    7 files    988 suites   10m 26s ⏱️
7 147 tests 7 119 ✅ 28 💤 0 ❌
7 148 runs  7 120 ✅ 28 💤 0 ❌

Results for commit 70d30ef.

Summary: workflow run #32005999502
Allure report (download zip): html-report-32853-chore_cherry-pick-wpb-27395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants