Skip to content

App Attest - Namespace UserDefaults Key by Device for App Attest Key #11853

@benedelstein

Description

@benedelstein

Description

If you get a new phone and transfer your apps from your previous phone, your app attest key id is persisted from the transfer. Attesting with this key id fails, because the key should be limited to 1 device. I've had this happen to countless users who get new phones.

Reinstalling the app fixes it.

This was mentioned here: #10561
see https://developer.apple.com/documentation/devicecheck/establishing_your_app_s_integrity#3579384

I see you're storing app attest key ids using UserDefaults in this file, which will be persisted across phone transfers and iCloud backups. You could either namespace the user defaults key using the device id or use a restricted keychain item.

This might be a bit of a breaking change, so you could migrate users from the old key location to the new one.

Reproducing the issue

Install app on phone with app attest App Check provider set up
Get a new phone, transfer data from old phone
Try to attest with new phone (fails)
Delete and reinstall app on new phone (works)

Firebase SDK Version

10.9

Xcode Version

14.3

Installation Method

Swift Package Manager

Firebase Product(s)

App Check

Targeted Platforms

iOS

Relevant Log Output

DCError.Code.invalidKey https://developer.apple.com/documentation/devicecheck/dcerror/3585177-invalidkey

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

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

If using CocoaPods, the project's Podfile.lock

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions