android / android/security-samples

I face the crash in xiaomi10

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
1k
Forks
450
PR merge metrics
No merged PRs in 30d

Description

```
java.lang.RuntimeException:java.lang.reflect.InvocationTargetException
--
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
 ......
 com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException:Protocol message contained an invalid tag (zero).
 com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite.com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite parsePartialFrom(com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite,byte[],int,int,com.google.crypto.tink.shaded.protobuf.ExtensionRegistryLite)(GeneratedMessageLite.java:10)
 com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite.com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite parseFrom(com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite,byte[],com.google.crypto.tink.shaded.protobuf.ExtensionRegistryLite)(GeneratedMessageLite.java:2)
com.google.crypto.tink.proto.Keyset.com.google.crypto.tink.proto.Keyset parseFrom(byte[],com.google.crypto.tink.shaded.protobuf.ExtensionRegistryLite)(Keyset.java:1)
8 com.google.crypto.tink.integration.android.SharedPrefKeysetReader.com.google.crypto.tink.proto.Keyset read()(SharedPrefKeysetReader.java:1)
com.google.crypto.tink.CleartextKeysetHandle.com.google.crypto.tink.KeysetHandle read(com.google.crypto.tink.KeysetReader)(CleartextKeysetHandle.java:1)
com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.com.google.crypto.tink.KeysetManager read()(AndroidKeysetManager.java:4)
com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.com.google.crypto.tink.KeysetManager readOrGenerateNewKeyset()(AndroidKeysetManager.java:1)
 com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.com.google.crypto.tink.integration.android.AndroidKeysetManager build()(AndroidKeysetManager.java:3)
androidx.security.crypto.EncryptedSharedPreferences.android.content.SharedPreferences create(java.lang.String,java.lang.String,android.content.Context,androidx.security.crypto.EncryptedSharedPreferences$PrefKeyEncryptionScheme,androidx.security.crypto.EncryptedSharedPreferences$PrefValueEncryptionScheme)(EncryptedSharedPreferences.java:7)
SharedPreferencesUtils$preferences$2.android.content.SharedPreferences invoke()(SharedPreferencesUtils.kt:6)
SharedPreferencesUtils$preferences$2.java.lang.Object invoke()(SharedPreferencesUtils.kt:1)
kotlin.SynchronizedLazyImpl.java.lang.Object getValue()(LazyJVM.kt:6)
SharedPreferencesUtils.android.content.SharedPreferences getPreferences()(Unknown Source:2)
SharedPreferencesUtils.android.content.SharedPreferences access$getPreferences$p(SharedPreferencesUtils)(SharedPreferencesUtils.kt:1)

```

Contributor guide

Open the contributing guide

Research direction

Start with SharedPreferencesUtils.kt and reproduce the stack trace on a Xiaomi 10, focusing on the EncryptedSharedPreferences and AndroidKeysetManager initialization path shown. Inspect how the keyset is read and determine what state triggers the invalid protobuf tag. Done means the sample no longer crashes at this path and the affected preferences behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.