Closed pkrawczykObj closed 1 year ago
The bug is probably in EncryptedSharedPreferences
from androidx.security:security-crypto
. See more:
https://issuetracker.google.com/issues/164901843?pli=1
However it would be nice if you can think about some workaround for it, because otherwise we risk a crash on startup in our app, after implementing OKTA Push SDK in the way how do you suggest it in the sample.
Hi @pkrawczykObj For testing you can disable encryption by using shared preference.
private val sharedPreferences: SharedPreferences = app.getSharedPreferences(passphraseSharedPref, Context.MODE_PRIVATE)
Replace encrypted shared preference with shared pref in https://github.com/okta/okta-devices-kotlin/blob/bb9d6a7e21f4ead195b09ab9a3dec48663f1db9a/push-sample-app/src/main/java/example/okta/android/sample/client/AuthenticatorClient.kt#L64
Hi @FeiChen-okta
Ok and what are your recommendations for production version of the app to avoid this issue?
Hi @FeiChen-okta
Ok and what are your recommendations for production version of the app to avoid this issue?
The android encryption library uses tink and it looks like it has issues https://issuetracker.google.com/issues/158234058
My recommendation is try 1.1.0-alpha06 which was released yesterday. This updated tink to 1.8.0. If that doesn't fix the issue then writing own encryption is another option.
Your recommendation does not fixed the issue and I switched to my own encryption. Maybe it would be worth to mention about it in Readme or change the sample implementation, because it caused the app crash on startup, which can be really painfull.
Describe the bug?
I was experimenting with different values in local.properties and after several install/uninstall actions it got stuck with following crash.
I tried to uninstall the app and clear app data, clear cache, but it is still crashing on the fresh install. Stack trace: FATAL EXCEPTION: main Process: example.okta.android.push_sample_app, PID: 11809 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:581) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) Caused by: com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero). at com.google.crypto.tink.shaded.protobuf.ArrayDecoders.decodeUnknownField(ArrayDecoders.java:1036) at com.google.crypto.tink.shaded.protobuf.ArrayDecoders.decodeUnknownField(ArrayDecoders.java:1028) at com.google.crypto.tink.shaded.protobuf.MessageSchema.parseProto3Message(MessageSchema.java:5426) at com.google.crypto.tink.shaded.protobuf.MessageSchema.mergeFrom(MessageSchema.java:5442) at com.google.crypto.tink.shaded.protobuf.ArrayDecoders.decodeMessageField(ArrayDecoders.java:246) at com.google.crypto.tink.shaded.protobuf.ArrayDecoders.decodeMessageList(ArrayDecoders.java:704) at com.google.crypto.tink.shaded.protobuf.MessageSchema.parseProto3Message(MessageSchema.java:5373) at com.google.crypto.tink.shaded.protobuf.MessageSchema.mergeFrom(MessageSchema.java:5442) at com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite.parsePartialFrom(GeneratedMessageLite.java:1567) at com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite.parseFrom(GeneratedMessageLite.java:1680) at com.google.crypto.tink.proto.Keyset.parseFrom(Keyset.java:958) at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.read(SharedPrefKeysetReader.java:84) at com.google.crypto.tink.CleartextKeysetHandle.read(CleartextKeysetHandle.java:61) at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.read(AndroidKeysetManager.java:332) at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readOrGenerateNewKeyset(AndroidKeysetManager.java:288) at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:239) at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169) at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130) at example.okta.android.sample.client.AuthenticatorClient.(AuthenticatorClient.kt:64)
at example.okta.android.sample.MyBankApplication$authenticatorClient$2.invoke(MyBankApplication.kt:24)
at example.okta.android.sample.MyBankApplication$authenticatorClient$2.invoke(MyBankApplication.kt:24)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at example.okta.android.sample.MyBankApplication.getAuthenticatorClient(MyBankApplication.kt:24)
at example.okta.android.sample.app.MainActivity$onCreate$1$1.invoke(MainActivity.kt:31)
at example.okta.android.sample.app.MainActivity$onCreate$1$1.invoke(MainActivity.kt:30)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.material.MaterialTheme_androidKt.PlatformMaterialTheme(MaterialTheme.android.kt:23)
at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:82)
at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:81)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:363)
at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
2023-04-19 13:03:04.338 11809-11809 AndroidRuntime exa....okta.android.push_sample_app E at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:72)
at example.okta.android.sample.app.MainActivity$onCreate$1.invoke(MainActivity.kt:30)
at example.okta.android.sample.app.MainActivity$onCreate$1.invoke(MainActivity.kt:29)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:177)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:157)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:156)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:156)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3352)
at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3342)
at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3342)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3277)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:966)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
2023-04-19 13:03:04.339 11809-11809 AndroidRuntime exa....okta.android.push_sample_app E at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1072)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:182)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1159)
at android.view.View.dispatchAttachedToWindow(View.java:21976)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4293)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3474)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2924)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10513)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1108)
at android.view.Choreographer.doCallbacks(Choreographer.java:866)
at android.view.Choreographer.doFrame(Choreographer.java:797)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8751)
... 3 more
What is expected to happen?
Application starts without a crash.
What is the actual behavior?
Sample app crashes on startup.
Reproduction Steps?
Additional Information?
n/a
SDK Version and Artifact(s) used.
Okta Push SDK 1.0.0
Build Information
n/a