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

bug: SharedPreferences causes exceptions

Open rakesh0689 opened this issue 1 year ago • 5 comments

Describe the bug Freerasp causes error with SharedPreferences at startup and application does not detect root / hook etc.. Even If if the error is not coming sometimes the detection does not work and the user is able to log in to app on rooted device. There is always a delay in triggering the callback after await Talsec.instance.start(config);

To Reproduce Similar to what is described in #112

Expected behavior Freerasp is supposed to detect root / hooks etc. but since the issue is happening the user is able to run the app on rooted device. But the is not coming every time sometimes when app is removed from memory and opened again Freerasp sometimes detects root sometimes this error comes. ALso when app is hot restarted while in debug mode then this issue is not there.

Screenshots W/SharedPreferencesImpl(19382): Cannot read /data/user/0/com.myapp.org/shared_prefs/LPt63jFXmgP2hitXSjTyIScRrUsA7cK8RSCVk26.xml W/SharedPreferencesImpl(19382): org.xmlpull.v1.XmlPullParserException: Unexpected end of document W/SharedPreferencesImpl(19382): at com.android.internal.util.XmlUtils.readValueXml(XmlUtils.java:1550) W/SharedPreferencesImpl(19382): at com.android.internal.util.XmlUtils.readMapXml(XmlUtils.java:971) W/SharedPreferencesImpl(19382): at android.app.SharedPreferencesImpl.loadFromDisk(SharedPreferencesImpl.java:179) W/SharedPreferencesImpl(19382): at android.app.SharedPreferencesImpl.lambda$startLoadFromDisk$0(SharedPreferencesImpl.java:149) W/SharedPreferencesImpl(19382): at android.app.SharedPreferencesImpl.$r8$lambda$gCIQI__z13DI5jNIqnAnYLWLcMc(Unknown Source:0) W/SharedPreferencesImpl(19382): at android.app.SharedPreferencesImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) W/SharedPreferencesImpl(19382): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) W/SharedPreferencesImpl(19382): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) W/SharedPreferencesImpl(19382): at java.lang.Thread.run(Thread.java:1012) W/Sensors (19382): Cannot get virtualdevice_native service D/nativeloader(19382): Load /data/app/~~PdqQLLHtN6sj7pn7zDNTBg==/com.myapp.org-BURVz3QSxsk6rEYBNw8ZkQ==/base.apk!/lib/arm64-v8a/libsecurity.so using ns clns-5 from class loader (caller=): ok

Please complete the following information:

  • Device: Samsung Galaxy S10 on Lineage OS and rooted using Magisk Module + LSPosed installed
  • OS version: Android 14 (Lineage OS)
  • Version of freeRASP: 6.6.0
  • Running in debug mode with isProd value set to true.

Additional context

  1. This error only occurs at the execution of this line "await Talsec.instance.start(config);"
  2. I don't use SharedPreferences in my project
  3. Sample of callback implemented: onAppIntegrity: () { isSecure = false; secureText = 'Tamper detected!!'; },
  4. When i browse this location "/data/user/0/com.myapp.org/shared_prefs/LPt63jFXmgP2hitXSjTyIScRrUsA7cK8RSCVk26.xml" there is no such folder as com.myapp.org and hence no xml file as well.
  5. We are not sure how the callbacks are getting triggered. Sometimes it gets triggered immediately sometimes its not getting triggered at all. I am not sure how to test this anymore. Any help would be greatly helpful. This is happening in Production build as well.

rakesh0689 avatar Jul 17 '24 08:07 rakesh0689

Hello @rakesh0689 ,

thank you for reporting the issue, we will look at it.

Kind regards, Talsec team

msikyna avatar Jul 19 '24 07:07 msikyna

Hi @msikyna , were you able to resolve this issue?

AwaisQazii avatar Jul 25 '24 07:07 AwaisQazii

Hi @msikyna ,

Is there an update or solution for this? We are facing the same issue:

W/SharedPreferencesImpl( 7547): Cannot read /data/user/0/<packageId>/shared_prefs/LpT8W5aFMBRoU0MCvKl3hGlhBEYszkisbY8DLEsylFvG.xml
W/SharedPreferencesImpl( 7547): org.xmlpull.v1.XmlPullParserException: Unexpected end of document
W/SharedPreferencesImpl( 7547): 	at com.android.internal.util.XmlUtils.readValueXml(XmlUtils.java:1550)
W/SharedPreferencesImpl( 7547): 	at com.android.internal.util.XmlUtils.readMapXml(XmlUtils.java:971)
W/SharedPreferencesImpl( 7547): 	at android.app.SharedPreferencesImpl.loadFromDisk(SharedPreferencesImpl.java:179)
W/SharedPreferencesImpl( 7547): 	at android.app.SharedPreferencesImpl.lambda$startLoadFromDisk$0(SharedPreferencesImpl.java:149)
W/SharedPreferencesImpl( 7547): 	at android.app.SharedPreferencesImpl.$r8$lambda$gCIQI__z13DI5jNIqnAnYLWLcMc(Unknown Source:0)
W/SharedPreferencesImpl( 7547): 	at android.app.SharedPreferencesImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
W/SharedPreferencesImpl( 7547): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
W/SharedPreferencesImpl( 7547): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
W/SharedPreferencesImpl( 7547): 	at java.lang.Thread.run(Thread.java:1012)

And this is not rooted or simulator device

urvesh-sm avatar Jul 31 '24 11:07 urvesh-sm

Hello.

We are aware of this issue - it is caused by an internal component. It does not affect detection or performance. We have plans in place to resolve it.

Jaroslav from Talsec

yardexx avatar Aug 01 '24 10:08 yardexx

Any Updates? Facing this issue in latest version : freerasp: ^6.7.2

AwaisQazii avatar Oct 22 '24 08:10 AwaisQazii

https://github.com/talsec/Free-RASP-Flutter/issues/147

msikyna avatar Nov 15 '24 05:11 msikyna

Hello.

We are aware of this issue - it is caused by an internal component. It does not affect detection or performance. We have plans in place to resolve it.

Jaroslav from Talsec

hey, any update on this? im still facing this issue on the latest version freerasp: ^6.10.0

vallerydelexy avatar Jan 21 '25 06:01 vallerydelexy

Hello @vallerydelexy,

How does the certificate hash look like? Is it in correct format?

Regards, Tomas

tompsota avatar Jun 03 '25 18:06 tompsota

Hello @vallerydelexy,

How does the certificate hash look like? Is it in correct format?

Regards, Tomas

Hi @tompsota,

is it related to hashed certificate? I used the correct format, base64, as mentioned in the documentation and error still occurred.

fajarainul avatar Oct 23 '25 22:10 fajarainul