fix(app-check, ios): do not default to the debug provider in release builds - #9117
fix(app-check, ios): do not default to the debug provider in release builds#9117kolezka wants to merge 1 commit into
Conversation
…builds The Expo config plugin emits `RNFBAppCheckModule.sharedInstance()` before `FirebaseApp.configure()` in AppDelegate. `sharedInstance()` registers the provider factory with a nil `providers` dictionary, and `configure()` then instantiates FIRAppCheckInterop eagerly (FIRInstantiationTimingAlwaysEager), which calls `createProviderWithApp:` while `providers[app.name]` is still nil. That pre-configure branch defaulted to `@"debug"`, so release builds installed FIRAppCheckDebugProvider and exchanged an unregistered debug token against firebaseappcheck.googleapis.com — 403 "App attestation failed", and 429 once the per-project debug-token quota saturated. Default to `appAttestWithDeviceCheckFallback` outside DEBUG builds, matching what the JS layer configures moments later. DEBUG builds keep the debug default, which local development with debug tokens relies on. Reported without a root cause in discussion invertase#7518 since 2023-12-19.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
|
|
Just acknowledging this is on our radar 👋 We are just finishing up with some massive internal refactors and that will give us space to fix things like this up For anyone else affected, and fo you @kolezka I can say this an obviously okay temporary fix - if you set the default provider to whatever you intend to configure anyway, it can't possibly be wrong, can it? So doing this while waiting for a real fix is absolutely a fine temporary fix to carry locally via patch-package or yarn patches |
Description
On iOS, release builds using the Expo config plugin exchange App Check debug tokens against
firebaseappcheck.googleapis.com, getting403 App attestation failedand then429once the per-project debug-token quota (60/min, not adjustable) saturates.The config plugin emits
RNFBAppCheckModule.sharedInstance()beforeFirebaseApp.configure()inAppDelegate.sharedInstance()registers the provider factory with a nilprovidersdictionary;configure()then instantiatesFIRAppCheckInteropeagerly (FIRInstantiationTimingAlwaysEager), which callscreateProviderWithApp:whileproviders[app.name]is still nil. The factory defaults that case to@"debug", so release builds getFIRAppCheckDebugProviderand exchange an unregistered token.This changes the pre-configure default to
appAttestWithDeviceCheckFallbackoutsideDEBUGbuilds, matching what the JS layer configures moments later anyway.DEBUGbuilds keep the debug default, which local development with debug tokens relies on.RNFBAppCheckProvideralready handles the iOS 14 / tvOS 15 availability fallback for that provider name.Fixing the factory rather than the plugin's line order means the outcome holds regardless of who calls the factory or in what sequence, so it survives future plugin and SDK changes. The ordering is arguably the deeper fix, but changing the emitted
AppDelegateaffects every consumer, and I can't test that blast radius across Objective-C and Swift AppDelegates and older plugin versions — so I've left it alone and described it in the issue instead. Happy to follow up if you'd prefer that direction, or a different non-debug default.Android is unaffected —
ReactNativeFirebaseAppCheckProviderFactory.create()throws rather than defaulting to debug.The debug default dates to
ee7df855("feat(app-check): add custom factory/provider", 2023-01-19) and is unchanged onmain.On tests: there is no existing jest or e2e coverage for
RNFBAppCheckProviderFactory— it is native Objective-C with no test target in this package, and the behaviour needs a release-configuration build to observe. I have left the test checkboxes unticked rather than claim coverage that does not exist; happy to add one if you can point me at where it should live.Related issues
Fixes #9116
Previously reported, uncaused, in discussion #7518 (open since 2023-12-19) and StackOverflow 77673428. Both threads assume a race condition; the misconfiguration is deterministic — only the exchange timing varies, which is why it presents as intermittent.
Release Summary
iOS: App Check no longer installs the debug provider in release builds, which caused
exchangeDebugToken403/429 traffic and could saturate the project's debug-token quota.Checklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/**/e2ejesttests added or updated inpackages/**/__tests__