firebase / firebase/firebase-ios-sdk

AppCheck error on iCloud Restore

Open
#15,161 4 comments 0 reactions 0 assignees View on GitHub
api: appcheck
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description

Hi All,
We are experiencing an AppCheck error for some users, our best guess is that its occurring when an existing user gets a new device and runs the app after an iCloud restore.
The initial call to Auth signIn fails with `internalError = 17999`. We previously found a forum that suggested in this case to attempt `AppCheck.appCheck().token(forcingRefresh: true)` which we do but it returns with the following error: `The operation couldn’t be completed. Failed to attest the validity of the generated cryptographic key (`attestKey:clientDataHash:completionHandler:`); keyId.length = 44, clientDataHash = cJKEhtFXhVI1hEP2XFYZz6P0V2MelcU `
It seems like maybe the issue is that the keychain isnt restored on iCloud restore but maybe the reference to it in userDefaults (or elsewhere) still remains. Looking at the code it seems like an error in this process would trigger resetAttestation, but users experiencing this error continue to experience it repeatedly, blocked from using the app.
Any guidance or fix on this issue would be greatly appreciated.

### Reproducing the issue

_No response_

### Firebase SDK Version

11.15.0

### Xcode Version

16.4

### Installation Method

Swift Package Manager

### Firebase Product(s)

App Check

### Targeted Platforms

iOS

### Relevant Log Output

```shell

```

### If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

```json

Replace this line with the contents of your Package.resolved.

```

### If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

```yml

Replace this line with the contents of your Podfile.lock!

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.