firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.73k stars 3.98k forks source link

[firebase_app_check]: Failed to create a block of data that demonstrates the legitimacy of the app instance #13377

Open Tom3652 opened 2 months ago

Tom3652 commented 2 months ago

Is there an existing issue for this?

Which plugins are affected?

App Check

Which platforms are affected?

iOS

Description

I am getting this crashlytics log on my live app since my users have upgraded to iOS 18 :

[firebase_app_check/unknown] The operation couldn’t be completed. Failed to create a block of data that demonstrates the legitimacy of the app instance (`generateAssertion:clientDataHash:completionHandler:`); keyId.length = 44, clientDataHash = aaF0YVycJAh9/UwALfjjlbdTCIfxkIQZ4yqUdsLE9R0=, systemVersion = 18.0; DCErrorInvalidKey - An error caused by a failed attempt to use the App Attest key..

It seems that the code is unable to use the App Attest key to create a block of data.

I have seen some existing issues in the Firebase iOS SDK but it doesn't seem to be exactly the same as mine (per the function name and the iOS 17 users).

For me it working fine until iOS 18 since i monitor my live app more or less every day.

Reproducing the issue

I could not reproduce it locally even on my iOS 18 app in debug mode, but in release mode i have more or less 50 logs in Crashlytics since the iOS 18 release

Firebase Core version

3.4.0

Flutter Version

3.24.3

Relevant Log Output

[firebase_app_check/unknown] The operation couldn’t be completed. Failed to create a block of data that demonstrates the legitimacy of the app instance (`generateAssertion:clientDataHash:completionHandler:`); keyId.length = 44, clientDataHash = aaF0YVycJAh9/UwALfjjlbdTCIfxkIQZ4yqUdsLE9R0=, systemVersion = 18.0; DCErrorInvalidKey - An error caused by a failed attempt to use the App Attest key..

### Flutter dependencies

<!--- Look below for instructions on how to share your Flutter Dependencies. --->

<details>
<summary>Expand <code>Flutter dependencies</code> snippet</summary>
<br>

```yaml
flutter pub deps -- --style=compact
Dart SDK 3.5.3
Flutter SDK 3.24.3
myappname 1.2.1+2

dependencies:
- apple_maps_flutter 1.3.0 [flutter]
- auto_size_text 3.0.0 [flutter]
- cached_network_image 3.4.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image]
- cupertino_back_gesture 0.1.0 [flutter]
- cupertino_icons 1.0.8
- extended_image 8.2.4 [extended_image_library flutter meta]
- firebase_analytics 11.3.2 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_app_check 0.3.1+2 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 5.3.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 3.5.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 4.1.2 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_database 11.1.3 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter]
- firebase_in_app_messaging 0.8.0+7 [firebase_core firebase_core_platform_interface firebase_in_app_messaging_platform_interface flutter meta]
- firebase_messaging 15.1.2 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_performance 0.10.0+7 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter]
- firebase_remote_config 5.1.2 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter]
- firebase_storage 12.3.1 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_app_badger 1.3.0 [flutter]
- flutter_email_sender 6.0.3 [flutter]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_secure_storage 9.2.2 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta]
- fluttertoast 8.2.8 [flutter flutter_web_plugins web]
- geocoding 3.0.0 [flutter geocoding_platform_interface geocoding_android geocoding_ios]
- geolocator 12.0.0 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows]
- google_fonts 6.2.1 [flutter http path_provider crypto]
- google_maps_flutter 2.9.0 [flutter google_maps_flutter_android google_maps_flutter_ios google_maps_flutter_platform_interface google_maps_flutter_web]
- http 1.2.2 [async http_parser meta web]
- image_picker 1.1.2 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows]
- in_app_review 2.0.9 [flutter in_app_review_platform_interface]
- login 0.0.1 [flutter firebase_core firebase_auth firebase_app_check connectivity_plus google_sign_in]
- maps_launcher 2.2.1 [flutter flutter_web_plugins url_launcher]
- mime 1.0.6
- package_info_plus 8.0.2 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- provider 6.1.2 [collection flutter nested]
- pull_to_refresh_flutter3 2.0.2 [flutter]
- rive 0.13.13 [collection flutter flutter_web_plugins http meta plugin_platform_interface rive_common]
- share_plus 10.0.2 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi web win32]
- shared_preferences 2.3.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- syncfusion_flutter_datepicker 27.1.48 [flutter intl syncfusion_flutter_core]
- uploader 0.0.1 [flutter firebase_core firebase_storage flutter_image_compress video_thumbnail video_compress]
- url_launcher 6.3.0 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- uuid 4.5.0 [crypto sprintf meta fixnum]
- video_player 2.9.1 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]

dev dependencies:
- flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml]
- flutter_lints 4.0.0 [lints]
- flutter_native_splash 2.4.1 [args flutter flutter_web_plugins html image meta path universal_io xml yaml ansicolor]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]

transitive dependencies:
- _flutterfire_internals 1.3.43 [collection firebase_core firebase_core_platform_interface flutter meta]
- ansicolor 2.0.3
- archive 3.6.1 [crypto path]
- args 2.5.0
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- cached_network_image_platform_interface 4.1.1 [flutter flutter_cache_manager]
- cached_network_image_web 1.3.1 [cached_network_image_platform_interface flutter flutter_cache_manager web]
- characters 1.3.0
- checked_yaml 2.0.3 [json_annotation source_span yaml]
- cli_util 0.4.1 [meta path]
- clock 1.1.1
- collection 1.18.0
- connectivity_plus 6.0.5 [flutter flutter_web_plugins connectivity_plus_platform_interface web meta nm collection]
- connectivity_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- cross_file 0.3.4+2 [meta web]
- crypto 3.0.5 [typed_data]
- csslib 1.0.0 [source_span]
- dbus 0.7.10 [args ffi meta xml]
- extended_image_library 4.0.5 [crypto flutter http_client_helper js path path_provider web]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.0 [meta path]
- file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.4 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+2 [cross_file file_selector_platform_interface flutter]
- firebase_analytics_platform_interface 4.2.4 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.5.10+1 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_app_check_platform_interface 0.1.0+37 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_app_check_web 0.1.3+1 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins web]
- firebase_auth_platform_interface 7.4.6 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.13.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core_platform_interface 5.3.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.18.1 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics_platform_interface 3.6.43 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_database_platform_interface 0.2.5+43 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_database_web 0.2.6+1 [collection firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins]
- firebase_in_app_messaging_platform_interface 0.2.4+43 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 4.5.45 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.9.1 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- firebase_performance_platform_interface 0.1.4+43 [_flutterfire_internals firebase_core flutter plugin_platform_interface]
- firebase_performance_web 0.1.7+1 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins]
- firebase_remote_config_platform_interface 1.4.43 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_web 1.7.1 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins]
- firebase_storage_platform_interface 5.1.30 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 3.10.1 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http meta web]
- fixnum 1.1.0
- flutter_cache_manager 3.4.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_image_compress 2.3.0 [flutter flutter_image_compress_platform_interface flutter_image_compress_common flutter_image_compress_web flutter_image_compress_macos flutter_image_compress_ohos]
- flutter_image_compress_common 1.0.5 [flutter flutter_image_compress_platform_interface]
- flutter_image_compress_macos 1.0.2 [flutter flutter_image_compress_platform_interface]
- flutter_image_compress_ohos 0.0.3 [flutter flutter_image_compress_platform_interface]
- flutter_image_compress_platform_interface 1.0.5 [flutter plugin_platform_interface cross_file]
- flutter_image_compress_web 0.1.4+1 [flutter flutter_web_plugins flutter_image_compress_platform_interface js]
- flutter_plugin_android_lifecycle 2.0.22 [flutter]
- flutter_secure_storage_linux 1.2.1 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_macos 3.1.2 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_platform_interface 1.1.2 [flutter plugin_platform_interface]
- flutter_secure_storage_web 1.2.1 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js]
- flutter_secure_storage_windows 3.1.2 [ffi flutter flutter_secure_storage_platform_interface path path_provider win32]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- geocoding_android 3.3.1 [flutter geocoding_platform_interface]
- geocoding_ios 3.0.1 [flutter geocoding_platform_interface]
- geocoding_platform_interface 3.2.0 [flutter meta plugin_platform_interface]
- geolocator_android 4.6.1 [flutter geolocator_platform_interface meta uuid]
- geolocator_apple 2.3.7 [flutter geolocator_platform_interface]
- geolocator_platform_interface 4.2.4 [flutter plugin_platform_interface vector_math meta]
- geolocator_web 4.1.1 [flutter flutter_web_plugins geolocator_platform_interface web]
- geolocator_windows 0.2.3 [flutter geolocator_platform_interface]
- google_identity_services_web 0.3.1+4 [meta web]
- google_maps 8.0.0 [meta web]
- google_maps_flutter_android 2.14.6 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface stream_transform]
- google_maps_flutter_ios 2.13.0 [flutter google_maps_flutter_platform_interface stream_transform]
- google_maps_flutter_platform_interface 2.9.2 [collection flutter plugin_platform_interface stream_transform]
- google_maps_flutter_web 0.5.10 [collection flutter flutter_web_plugins google_maps google_maps_flutter_platform_interface sanitize_html stream_transform web]
- google_sign_in 6.2.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- google_sign_in_android 6.1.30 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.7.7 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.4.5 [flutter plugin_platform_interface]
- google_sign_in_web 0.12.4+2 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web]
- graphs 2.3.2 [collection]
- html 0.15.4 [csslib source_span]
- http_client_helper 3.0.0 [http]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 4.2.0 [archive meta xml]
- image_picker_android 0.8.12+13 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.5 [flutter flutter_web_plugins image_picker_platform_interface mime web]
- image_picker_ios 0.8.12 [flutter image_picker_platform_interface]
- image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_platform_interface 2.10.0 [cross_file flutter http plugin_platform_interface]
- image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface]
- in_app_review_platform_interface 2.0.5 [flutter url_launcher plugin_platform_interface platform]
- intl 0.19.0 [clock meta path]
- js 0.6.7 [meta]
- json_annotation 4.9.0 [meta]
- leak_tracker 10.0.5 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.5 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 4.0.0
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.15.0
- nested 1.0.0 [flutter]
- nm 0.5.0 [dbus]
- octo_image 2.1.0 [flutter]
- package_info_plus_platform_interface 3.0.1 [flutter meta plugin_platform_interface]
- path 1.9.0
- path_provider 2.1.4 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.2.10 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.0 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- petitparser 6.0.2 [meta]
- platform 3.1.5
- plugin_platform_interface 2.1.8 [meta]
- rive_common 0.4.11 [collection ffi flutter flutter_web_plugins graphs http meta plugin_platform_interface web]
- rxdart 0.28.0
- sanitize_html 2.1.0 [html meta]
- share_plus_platform_interface 5.0.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid]
- shared_preferences_android 2.3.2 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.2 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.2 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- sqflite 2.3.3+1 [flutter sqflite_common path]
- sqflite_common 2.5.4+3 [synchronized path meta]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- stream_transform 2.1.0
- string_scanner 1.2.0 [source_span]
- syncfusion_flutter_core 27.1.48 [vector_math flutter]
- synchronized 3.3.0+2
- term_glyph 1.2.1
- test_api 0.7.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.3.2 [collection]
- universal_io 2.2.2 [collection meta typed_data]
- url_launcher_android 6.3.10 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.3 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.2 [flutter url_launcher_platform_interface]
- vector_math 2.1.4
- video_compress 3.1.1 [flutter]
- video_player_android 2.7.3 [flutter video_player_platform_interface]
- video_player_avfoundation 2.6.1 [flutter video_player_platform_interface]
- video_player_platform_interface 6.2.2 [flutter plugin_platform_interface]
- video_player_web 2.3.2 [flutter flutter_web_plugins video_player_platform_interface web]
- video_thumbnail 0.5.3 [flutter]
- vm_service 14.2.5
- web 1.0.0
- win32 5.5.4 [ffi]
- xdg_directories 1.0.4 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.2 [collection source_span string_scanner]

Additional context and comments

I also see that i am using the 3.4.0 instead of 3.5.0 but i am not sure if this change includes the solution for App Check... In any case i will upgrade for my next release today and see if it's still happening

SelaseKay commented 2 months ago

Hi @Tom3652 , Did the upgrade resolve this issue?

Tom3652 commented 2 months ago

Hi ! Unfortunately not i am afraid :/

SelaseKay commented 2 months ago

Can you provide a sample code and steps to reproduce this issue?

Tom3652 commented 1 month ago

Well in my production app i only have this code :

  FirebaseAppCheck.instance.activate(
      appleProvider:
          !kReleaseMode ? AppleProvider.debug : AppleProvider.appAttest,
      androidProvider: !kReleaseMode
          ? AndroidProvider.debug
          : AndroidProvider.playIntegrity);

in main.dart after initializing firebase app, and i am calling :

  try {
      appCheckToken = await FirebaseAppCheck.instance.getToken() ?? "";
    } catch (error) {
      AnalyticsAPI.logError(error, reason: "Could not fetch app check token");
    }

Where AnalyticsAPI.logError is my function that records the error in Crashlytics.

Note : i have no swift code or any custom native classes.

Foxsterc commented 1 month ago

Getting the same issues here, not all users but enough.

firebase_app_check: ^0.3.1+2

Tom3652 commented 1 month ago

Hey @Foxsterc is it also only on iOS 18 for your users ?