Free-RASP-Flutter icon indicating copy to clipboard operation
Free-RASP-Flutter copied to clipboard

ANR in production on init

Open kreativityapps opened this issue 2 years ago • 1 comments

Hi, several ANR's in production shown in Play Console and Crashlytics for Flutter Android. Android versions: 9, 10, 11, 12. Can't reproduce it locally, I hope the logs help.

  #00  pc 0x000000000009aec4  /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+4)
  #01  pc 0x0000000000057ca0  /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
  #02  pc 0x000000000008808c  /system/lib64/libhidlbase.so (android::hardware::IPCThreadState::transact(int, unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int)+564)
  #03  pc 0x000000000008353c  /system/lib64/libhidlbase.so (android::hardware::BpHwBinder::transact(unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int, std::__1::function<void (android::hardware::Parcel&)>)+76)
  #04  pc 0x000000000007caa0  /system/lib64/libhidlbase.so (android::hidl::base::V1_0::BpHwBase::_hidl_interfaceChain(android::hardware::IInterface*, android::hardware::details::HidlInstrumentor*, std::__1::function<void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>)+248)
  #05  pc 0x000000000007db0c  /system/lib64/libhidlbase.so (android::hidl::base::V1_0::BpHwBase::interfaceChain(std::__1::function<void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>)+144)
  #06  pc 0x000000000004b590  /system/lib64/libhidlbase.so (android::hardware::details::canCastInterface(android::hidl::base::V1_0::IBase*, char const*, bool)+292)
  #07  pc 0x000000000004e5f0  /system/lib64/libhidlbase.so (android::hardware::details::getRawServiceInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool)+1088)
  #08  pc 0x000000000003b61c  /system/lib64/<EMAIL_ADDRESS> (android::sp<android::hardware::drm::V1_0::IDrmFactory> android::hardware::details::getServiceInternal<android::hardware::drm::V1_0::BpHwDrmFactory, android::hardware::drm::V1_0::IDrmFactory, void, void>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool)+96)
  #09  pc 0x0000000000022730  /system/lib64/libmediadrm.so (android::hardware::drm::V1_0::IDrmFactory::getService(android::hardware::hidl_string const&, bool)+176)
  #10  pc 0x000000000002256c  /system/lib64/libmediadrm.so (std::__1::__function::__func<void android::DrmUtils::(anonymous namespace)::MakeHidlFactories<android::hardware::drm::V1_0::IDrmFactory, std::__1::vector<android::sp<android::hardware::drm::V1_0::IDrmFactory>, std::__1::allocator<android::sp<android::hardware::drm::V1_0::IDrmFactory> > > >(unsigned char const*, std::__1::vector<android::sp<android::hardware::drm::V1_0::IDrmFactory>, std::__1::allocator<android::sp<android::hardware::drm::V1_0::IDrmFactory> > >&)::'lambda'(android::hardware::hidl_vec<android::hardware::hidl_string> const&), std::__1::allocator<void android::DrmUtils::(anonymous namespace)::MakeHidlFactories<android::hardware::drm::V1_0::IDrmFactory, std::__1::vector<android::sp<android::hardware::drm::V1_0::IDrmFactory>, std::__1::allocator<android::sp<android::hardware::drm::V1_0::IDrmFactory> > > >(unsigned char const*, std::__1::vector<android::sp<android::hardware::drm::V1_0::IDrmFactory>, std::__1::allocator<android::sp<android::hardware::drm::V1_0::IDrmFactory> > >&)::'lambda'(android::hardware::hidl_vec<android::hardware::hidl_string> const&)>, void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>::operator()(android::hardware::hidl_vec<android::hardware::hidl_string> const&)+116)
  #11  pc 0x000000000006749c  /system/lib64/libhidlbase.so (std::__1::__function::__func<android::hidl::manager::V1_0::BpHwServiceManager::_hidl_list(android::hardware::IInterface*, android::hardware::details::HidlInstrumentor*, std::__1::function<void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>)::$_5, std::__1::allocator<android::hidl::manager::V1_0::BpHwServiceManager::_hidl_list(android::hardware::IInterface*, android::hardware::details::HidlInstrumentor*, std::__1::function<void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>)::$_5>, void (android::hardware::Parcel&)>::operator()(android::hardware::Parcel&)+300)
  #12  pc 0x0000000000083558  /system/lib64/libhidlbase.so (android::hardware::BpHwBinder::transact(unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int, std::__1::function<void (android::hardware::Parcel&)>)+104)
  #13  pc 0x0000000000076c6c  /system/lib64/libhidlbase.so (android::hidl::manager::V1_2::BpHwServiceManager::_hidl_listManifestByInterface(android::hardware::IInterface*, android::hardware::details::HidlInstrumentor*, android::hardware::hidl_string const&, std::__1::function<void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>)+312)
  #14  pc 0x00000000000775c8  /system/lib64/libhidlbase.so (android::hidl::manager::V1_2::BpHwServiceManager::listManifestByInterface(android::hardware::hidl_string const&, std::__1::function<void (android::hardware::hidl_vec<android::hardware::hidl_string> const&)>)+156)
  #15  pc 0x0000000000021648  /system/lib64/libmediadrm.so (android::DrmUtils::MakeDrmFactories(unsigned char const*)+208)
  #16  pc 0x00000000000154f4  /system/lib64/libmediadrm.so (android::DrmHal::makeDrmFactories()+48)
  #17  pc 0x0000000000015674  /system/lib64/libmediadrm.so (android::DrmHal::DrmHal()+84)
  #18  pc 0x0000000000021478  /system/lib64/libmediadrm.so (android::DrmUtils::MakeDrm(int*)+48)
  #19  pc 0x00000000000503bc  /system/lib64/libmedia_jni.so (android::JDrm::JDrm(_JNIEnv*, _jobject*, unsigned char const*, android::String8 const&)+164)
  #20  pc 0x0000000000052344  /system/lib64/libmedia_jni.so (android_media_MediaDrm_native_setup(_JNIEnv*, _jobject*, _jobject*, _jbyteArray*, _jstring*)+344)
  at android.media.MediaDrm.native_setup (MediaDrm.java)
  at android.media.MediaDrm.<init> (MediaDrm.java:282)
  at com.aheaditec.talsec.security.t2.b (SourceFile:4)
  at com.aheaditec.talsec.security.t2.a (SourceFile:1)
  at com.aheaditec.talsec.security.t2$a.a (SourceFile:1)
  at com.aheaditec.talsec.security.t2$a.invoke (SourceFile:1)
  at com.aheaditec.talsec.security.d5.a (SourceFile:1)
  at com.aheaditec.talsec.security.t2.a (SourceFile:2)
  at com.aheaditec.talsec.security.p4.<init> (SourceFile:6)
  at com.aheaditec.talsec.security.r.c (SourceFile:6)
  at com.aheaditec.talsec.security.r.b (SourceFile:7)
  at com.aheaditec.talsec.security.r.a (SourceFile:8)
  at com.aheaditec.talsec.security.j.<init> (SourceFile:3)
  at com.aheaditec.talsec.security.y1.a (SourceFile:5)
  at com.aheaditec.talsec.security.r1.<init> (SourceFile:4)
  at com.aheaditec.talsec.security.r1.a (SourceFile:4)
  at com.aheaditec.talsec_security.security.api.Talsec.start (SourceFile:1)
  at com.aheaditec.freerasp.TalsecApp.init (TalsecApp.kt:27)
  at com.aheaditec.freerasp.MethodCallHandlerImpl.init (MethodCallHandlerImpl.kt:54)
  at com.aheaditec.freerasp.MethodCallHandlerImpl.onMethodCall (MethodCallHandlerImpl.kt:21)
  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage (MethodChannel.java:262)
  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler (DartMessenger.java:295)
  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0 (DartMessenger.java:319)
  at io.flutter.embedding.engine.dart.DartMessenger.$r8$lambda$TsixYUB5E6FpKhMtCSQVHKE89gQ (DartMessenger.java)
  at io.flutter.embedding.engine.dart.DartMessenger$$InternalSyntheticLambda$0$ceffc6bae7d364cb48afaf1aaebd60bf9050360d0efb9035ebc54f0851df0a05$0.run (DartMessenger.java)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:250)
  at android.app.ActivityThread.main (ActivityThread.java:7803)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:592)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958)

kreativityapps avatar Oct 20 '22 19:10 kreativityapps

Hi @kreativityapps kreativityapps Thank you for your report. We will take a closer look at this issue. We will post an update here when the investigation will be over. Kind regards, Talec Team

talsec-app avatar Oct 21 '22 11:10 talsec-app

Hi @kreativityapps , We’ve found the bug causing this issue. Although the checks are executed in a separate thread, freeRASP still needs to do a little work to set up the library. Library uses device identifiers such as Android ID, Media DRM, etc ..., which are set up when the library is initialized. In the majority of cases, this setup takes just a few milliseconds to complete. There is a possibility that it can take some time to retrieve the identifier (system allocations), and that causes the ANR issues.

We will try to fix this issue in a future release.

In the meantime, you can solve the issue by wrapping the SDK into a separate thread. During the wrapping, keep in mind that you should wait until the initialization process finishes before launching the business flow of the application. Hope this helps.

Best regards, Talsec Team

talsec-app avatar Nov 04 '22 17:11 talsec-app

Dear @talsec-app, Do you have any estimate of when the fixed version be released? Thanks!

olexale avatar Dec 13 '22 14:12 olexale

Dear @olexale , we plan to fix it in nearest version, which will come in early 2023, as it is holiday season now. It will come with some of the bugs fixed and a new emulator detection. Stay tuned!

Kind regards, Talsec team

talsec-app avatar Dec 16 '22 12:12 talsec-app

Hello everyone!

New version of freeRASP have been released. New version fixes this issue.

Jaroslav from Talsec Team

yardexx avatar Jan 31 '23 08:01 yardexx