Skip to main content

Threema

Deliberately a version behind

We use 974 or 5.4.1(l) specifically, so that the functioning of the internal application check for updates can be validated end-to-end.

Attempt 20240821.D6

  • fdroid apk
  • sha256sum: ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5
$ keytool -printcert -jarfile ch.threema.app.libre_974.apk
Signer #1:

Certificate #1:
Owner: CN=Unknown, OU=Unknown, O=Threema GmbH, L=Pfäffikon, ST=SZ, C=CH
Issuer: CN=Unknown, OU=Unknown, O=Threema GmbH, L=Pfäffikon, ST=SZ, C=CH

Android.mk

$ cat Android.mk
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := ThreemaLibre
LOCAL_MODULE_CLASS := APPS
LOCAL_MULTILIB := both
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_SRC_FILES := ch.threema.app.libre_974.apk
LOCAL_PRODUCT_MODULE := true
LOCAL_DEX_PREOPT := false
LOCAL_ENFORCE_USES_LIBRARIES := false

include $(BUILD_PREBUILT)

Will fail:

$ sha256sum git-T0MP1/external/Threema/ch.threema.app.libre_974.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 git-T0MP1/external/Threema/ch.threema.app.libre_974.apk
b9f6ebd114145383691c165222175446df035c251fdbb653de9e1d2f3fadc807 userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
b9f6ebd114145383691c165222175446df035c251fdbb653de9e1d2f3fadc807 userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk

and

$ apksigner verify -v userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
DOES NOT VERIFY
ERROR: JAR signer ANDROID_.RSA: JAR signature META-INF/ANDROID_.SF indicates the APK is signed using APK Signature Scheme v2 but no such signature was found. Signature stripped?
ERROR: JAR signer ANDROID_.RSA: JAR signature META-INF/ANDROID_.SF indicates the APK is signed using APK Signature Scheme v3 but no such signature was found. Signature stripped?

and indeed fails:

$ adb logcat -d | grep -i threema
01-01 01:00:26.191 1102 1102 I PackageManager: /product/app/ThreemaLibre changed; collecting certs
01-01 01:00:26.192 1102 1102 W PackageManager: Failed to scan /product/app/ThreemaLibre: No APK Signature Scheme v2 signature in package /product/app/ThreemaLibre/ThreemaLibre.apk

and:

$ adb shell
MC02:/ $ su
MC02:/ # sha256sum /product/app/ThreemaLibre/ThreemaLibre.apk
b9f6ebd114145383691c165222175446df035c251fdbb653de9e1d2f3fadc807 /product/app/ThreemaLibre/ThreemaLibre.apk
MC02:/ #

Attempt 20240821.D7

  • fdroid apk
  • sha256sum: ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5

Add to Android.mk:

 LOCAL_PRODUCT_MODULE := true
LOCAL_DEX_PREOPT := false
LOCAL_ENFORCE_USES_LIBRARIES := false
+LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)

Not yet failing:

$ sha256sum git-T0MP1/external/Threema/ch.threema.app.libre_974.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 git-T0MP1/external/Threema/ch.threema.app.libre_974.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk
$ apksigner verify -v userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
Verifies
Verified using v1 scheme (JAR signing): true
Verified using v2 scheme (APK Signature Scheme v2): true
Verified using v3 scheme (APK Signature Scheme v3): true
Verified using v3.1 scheme (APK Signature Scheme v3.1): false
Verified using v4 scheme (APK Signature Scheme v4): false
Verified for SourceStamp: false
Number of signers: 1
(...)

fails unable to find libsqlcipher.so;

$ adb logcat -d | grep -i threema
* daemon not running; starting now at tcp:5037
* daemon started successfully
01-01 01:00:26.521 1123 1123 I PackageManager: /product/app/ThreemaLibre changed; collecting certs
08-21 00:00:14.247 1123 1123 V StorageManagerService: Package ch.threema.app.libre does not have legacy storage
08-21 00:00:21.121 1123 1150 D AppWidgetServiceImpl: Provider info from ComponentInfo{ch.threema.app.libre/ch.threema.app.receivers.WidgetProvider} won't be persisted.
08-21 00:00:22.627 1123 1152 I ActivityManager: Start proc 4748:ch.threema.app.libre/u0a91 for broadcast {ch.threema.app.libre/ch.threema.app.receivers.AutoStartNotifyReceiver}
08-21 00:00:22.722 4748 4748 W ch.threema.app.libre: ART APEX data files are untrusted.
08-21 00:00:22.722 4748 4748 I ch.threema.app.libre: Core platform API reporting enabled, enforcing=false
08-21 00:00:22.800 4748 4748 D ch.threema.app.libre: Time zone APEX ICU file found: /apex/com.android.tzdata/etc/icu/icu_tzdata.dat
08-21 00:00:22.800 4748 4748 D ch.threema.app.libre: I18n APEX ICU file found: /apex/com.android.i18n/etc/icu/icudt70l.dat
08-21 00:00:22.890 4748 4748 D libMEOW : applied 1 plugins for [ch.threema.app.libre]:
08-21 00:00:22.910 4748 4748 E ch.threema.app.libre: Unable to find pattern file or unable to map it for am
08-21 00:00:23.051 4748 4748 D nativeloader: classloader namespace configured for unbundled product apk. library_path=/product/app/ThreemaLibre/lib/arm64:/product/app/ThreemaLibre/ThreemaLibre.apk!/lib/arm64-v8a:/product/lib64:/system/product/lib64
08-21 00:00:23.096 4748 4748 V GraphicsEnvironment: ANGLE Developer option for 'ch.threema.app.libre' set to: 'default'
08-21 00:00:23.097 4748 4748 V GraphicsEnvironment: ANGLE GameManagerService for ch.threema.app.libre: false
08-21 00:00:23.204 4748 4748 W reema.app.libre: type=1400 audit(0.0:1534): avc: denied { read } for name="u:object_r:incremental_prop:s0" dev="tmpfs" ino=20496 scontext=u:r:untrusted_app:s0:c91,c256,c512,c768 tcontext=u:object_r:incremental_prop:s0 tclass=file permissive=0 app=ch.threema.app.libre
08-21 00:00:23.204 4748 4748 W reema.app.libre: type=1400 audit(0.0:1535): avc: denied { read } for name="filesystems" dev="proc" ino=4026532399 scontext=u:r:untrusted_app:s0:c91,c256,c512,c768 tcontext=u:object_r:proc_filesystems:s0 tclass=file permissive=0 app=ch.threema.app.libre
(...)

and:

08-21 00:00:23.396  4748  4748 D AndroidRuntime: Shutting down VM
--------- beginning of crash
08-21 00:00:23.397 4748 4748 E AndroidRuntime: FATAL EXCEPTION: main
08-21 00:00:23.397 4748 4748 E AndroidRuntime: Process: ch.threema.app.libre, PID: 4748
08-21 00:00:23.397 4748 4748 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlcipher.so" not found
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:998)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1661)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at ch.threema.app.ThreemaApplication.reset(ThreemaApplication.java:847)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at ch.threema.app.ThreemaApplication.onCreate(ThreemaApplication.java:473)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1282)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6827)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2139)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7940)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at com.android.internal.os.ExecInit.main(ExecInit.java:49)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
08-21 00:00:23.397 4748 4748 E AndroidRuntime: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
08-21 00:00:23.401 1123 4808 I DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2
08-21 00:00:23.404 1123 1151 D OomAdjuster: Not killing cached processes
08-21 00:00:23.405 4748 4748 I Process : Sending signal. PID: 4748 SIG: 9

but also:

$ adb shell
MC02:/ $ su
MC02:/ # sha256sum /product/app/ThreemaLibre/ThreemaLibre.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 /product/app/ThreemaLibre/ThreemaLibre.apk
MC02:/ #

Attempt 20240821.D9

Reset, just to show that it can work.

  • fdroid apk
  • sha256sum: ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5

Remove LOCAL_REPLACE_PREBUILT_APK_INSTALLED and replace LOCAL_CERTIFICATE with platform as opposed to PRESIGNED:

$ cat Android.mk
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := ThreemaLibre
LOCAL_MODULE_CLASS := APPS
LOCAL_MULTILIB := both
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := ch.threema.app.libre_974.apk
LOCAL_PRODUCT_MODULE := true
LOCAL_DEX_PREOPT := false
LOCAL_ENFORCE_USES_LIBRARIES := false

include $(BUILD_PREBUILT)

This should cause the APK to be resigned with the platform release key

Intermediate result:

$ sha256sum git-T0MP1/external/Threema/ch.threema.app.libre_974.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 git-T0MP1/external/Threema/ch.threema.app.libre_974.apk
b39d9f3a0f9f383962f6eaba1360a0cb8ed76090587cb92a96ec057e2b1f02e3 userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
b39d9f3a0f9f383962f6eaba1360a0cb8ed76090587cb92a96ec057e2b1f02e3 userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk

Works!

Attempt 20240821.D10

  • fdroid apk
  • sha256sum: ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5
  • revert to PRESIGNED
  • omit LOCAL_REPLACE_PREBUILT_APK_INSTALLED for the moment
  • use LOCAL_SDK_VERSION := 30

Build failure:

[ 99% 5433/5458] target Prebuilt: ThreemaLibre (userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk)
FAILED: userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
/bin/bash -c "(rm -f userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk ) && (cp \"external/Threema/ch.threema.app.libre_974.apk\" \"userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk\" ) && (if (zipinfo userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk 'lib/*.so' '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then echo -e \"\\033[1muserdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk: \\033[31merror:\\033[0m\\033[1m\" 'Contains compressed JNI libraries and/or dex files' \"\\033[0m\" >&2; exit 1; fi ) && (if ! userdebug/out_sys/host/linux-x86/bin/zipalign -c -p 4 userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk >/dev/null ; then echo -e \"\\033[1muserdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk: \\033[31merror:\\033[0m\\033[1m\" 'Improper package alignment' \"\\033[0m\" >&2; exit 1; fi )"
userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk: error: Contains compressed JNI libraries and/or dex files
$ sha256sum git-T0MP1/external/Threema/ch.threema.app.libre_974.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 git-T0MP1/external/Threema/ch.threema.app.libre_974.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk

Attempt 20240821.D11

  • fdroid apk
  • sha256sum: ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5
  • add back LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)

Intermediate result:

$ sha256sum git-T0MP1/external/Threema/ch.threema.app.libre_974.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 git-T0MP1/external/Threema/ch.threema.app.libre_974.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 userdebug/out_sys/target/product/mssi_64_cn_armv82/obj/APPS/ThreemaLibre_intermediates/package.apk
ebdbc3647ff901f7ecafe5601bdabf28f95b4d97068fe77e92758393ac48eec5 userdebug/out_sys/target/product/mssi_64_cn_armv82/product/app/ThreemaLibre/ThreemaLibre.apk

Same result as Attempt 20240821.D7

08-21 00:00:22.908  4634  4634 D nativeloader: classloader namespace configured for unbundled product apk. library_path=/product/app/ThreemaLibre/lib/arm64:/product/app/ThreemaLibre/ThreemaLibre.apk!/lib/arm64-v8a:/product/lib64:/system/product/lib64
(...)
08-21 00:00:23.167 4634 4634 D AndroidRuntime: Shutting down VM
--------- beginning of crash
08-21 00:00:23.167 4634 4634 E AndroidRuntime: FATAL EXCEPTION: main
08-21 00:00:23.167 4634 4634 E AndroidRuntime: Process: ch.threema.app.libre, PID: 4634
08-21 00:00:23.167 4634 4634 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlcipher.so" not found
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:998)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1661)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at ch.threema.app.ThreemaApplication.reset(ThreemaApplication.java:847)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at ch.threema.app.ThreemaApplication.onCreate(ThreemaApplication.java:473)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1282)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6827)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2139)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7940)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at com.android.internal.os.ExecInit.main(ExecInit.java:49)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
08-21 00:00:23.167 4634 4634 E AndroidRuntime: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
08-21 00:00:23.172 1123 4680 I DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2
08-21 00:00:23.175 4634 4634 I Process : Sending signal. PID: 4634 SIG: 9
$ adb shell
MC02:/ $ su
MC02:/ # setenforce 0
MC02:/ # find / -type f -name "*sqlcipher*" 2>/dev/null
1|MC02:/ # ^D
1|MC02:/ $ ^D

Extract from working build Attempt 20240821.D9:

$ adb shell
MC02:/ $ su
MC02:/ # setenforce 0
MC02:/product/app/ThreemaLibre # cd /data/data/
MC02:/data/data # mkdir tmp
MC02:/data/data # cd tmp/
MC02:/data/data/tmp # unzip /product/app/ThreemaLibre/ThreemaLibre.apk
(...)
MC02:/data/data/tmp # find lib/
lib/
lib/x86
lib/x86/libsqlcipher.so
lib/x86/libmaplibre.so
lib/x86/libjingle_peerconnection_so.so
lib/x86/libnacl-jni.so
lib/x86/libimage_processing_util_jni.so
lib/arm64-v8a
lib/arm64-v8a/libnacl-jni.so
lib/arm64-v8a/libjingle_peerconnection_so.so
lib/arm64-v8a/libmaplibre.so
lib/arm64-v8a/libimage_processing_util_jni.so
lib/arm64-v8a/libsqlcipher.so
lib/x86_64
lib/x86_64/libjingle_peerconnection_so.so
lib/x86_64/libnacl-jni.so
lib/x86_64/libimage_processing_util_jni.so
lib/x86_64/libmaplibre.so
lib/x86_64/libsqlcipher.so
lib/armeabi-v7a
lib/armeabi-v7a/libnacl-jni.so
lib/armeabi-v7a/libsqlcipher.so
lib/armeabi-v7a/libjingle_peerconnection_so.so
lib/armeabi-v7a/libimage_processing_util_jni.so
lib/armeabi-v7a/libmaplibre.so

Attempt 20240821.D12

  • apostrophy build
  • same Android.mk

also noticed, not verified in other builds:

08-21 00:12:14.697  3057  3057 W ch.threema.app.libre: ART APEX data files are untrusted.
(...)
08-21 00:12:14.776 3057 3057 D ch.threema.app.libre: Time zone APEX ICU file found: /apex/com.android.tzdata/etc/icu/icu_tzdata.dat

Attempt D14??

  • modify the bionic linker

Note that this is only the current diff (it has evolved)

diff --git a/linker/linker.cpp b/linker/linker.cpp
index abc00a8f9..2229d6235 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -922,21 +922,34 @@ static int open_library_in_zipfile(ZipArchiveCache* zip_archive_cache,

ZipArchiveHandle handle;
if (!zip_archive_cache->get_or_open(zip_path, fd, &handle)) {
+ PRINT("THREEMA: Invalid zip file? %s", zip_path);
// invalid zip-file (?)
close(fd);
return -1;
}

+ PRINT("THREEMA: Valid zip file. %s", zip_path);
+
ZipEntry entry;

if (FindEntry(handle, file_path, &entry) != 0) {
+ PRINT("THREEMA: Entry not found? %s", file_path);
// Entry was not found.
close(fd);
return -1;
}

+ PRINT("THREEMA: Entry found. %s", file_path);
+
// Check if it is properly stored
if (entry.method != kCompressStored || (entry.offset % PAGE_SIZE) != 0) {
+ if (entry.method != kCompressStored) {
+ PRINT("THREEMA: entry.method != kCompressStored?");
+ }
+ if ((entry.offset % PAGE_SIZE) != 0) {
+ PRINT("THREEMA: (entry.offset modulo PAGE_SIZE) != 0?");
+ }
+
close(fd);
return -1;
}

Attempt 15

  • add additional zip_path and file_path to the aforementioned linker outputs
08-21 00:00:23.185  4702  4702 E linker  : THREEMA: Valid zip file. /product/app/ThreemaLibre/ThreemaLibre.apk
08-21 00:00:23.185 4702 4702 E linker : THREEMA: Entry found. lib/arm64-v8a/libsqlcipher.so
08-21 00:00:23.185 4702 4702 E linker : THREEMA: entry.method != kCompressStored?
08-21 00:00:23.186 4702 4702 D AndroidRuntime: Shutting down VM
--------- beginning of crash
08-21 00:00:23.187 4702 4702 E AndroidRuntime: FATAL EXCEPTION: main
08-21 00:00:23.187 4702 4702 E AndroidRuntime: Process: ch.threema.app.libre, PID: 4702
08-21 00:00:23.187 4702 4702 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlcipher.so" not found
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:998)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1661)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at ch.threema.app.ThreemaApplication.reset(ThreemaApplication.java:847)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at ch.threema.app.ThreemaApplication.onCreate(ThreemaApplication.java:473)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1282)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6827)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2139)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7940)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at com.android.internal.os.ExecInit.main(ExecInit.java:49)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
08-21 00:00:23.187 4702 4702 E AndroidRuntime: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
08-21 00:00:23.191 1090 4744 I DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2

Attempt 17

  • same, but with the fdroid apk
  • split the failure conditions matched above to both trigger, if so inclined
(...)
08-21 00:00:23.013 4654 4654 E linker : THREEMA: Valid zip file. /product/app/ThreemaLibre/ThreemaLibre.apk
08-21 00:00:23.013 4654 4654 E linker : THREEMA: Entry found. lib/arm64-v8a/libsqlcipher.so
08-21 00:00:23.013 4654 4654 E linker : THREEMA: entry.method != kCompressStored?
08-21 00:00:23.013 4654 4654 E linker : THREEMA: (entry.offset modulo PAGE_SIZE) != 0?
08-21 00:00:23.013 4654 4654 D AndroidRuntime: Shutting down VM
--------- beginning of crash
08-21 00:00:23.014 4654 4654 E AndroidRuntime: FATAL EXCEPTION: main
08-21 00:00:23.014 4654 4654 E AndroidRuntime: Process: ch.threema.app.libre, PID: 4654
08-21 00:00:23.014 4654 4654 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlcipher.so" not found
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:998)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1661)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at ch.threema.app.ThreemaApplication.reset(ThreemaApplication.java:847)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at ch.threema.app.ThreemaApplication.onCreate(ThreemaApplication.java:473)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1282)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6827)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2139)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7940)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at com.android.internal.os.ExecInit.main(ExecInit.java:49)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
08-21 00:00:23.014 4654 4654 E AndroidRuntime: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
08-21 00:00:23.018 1125 4699 I DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2
$ zipalign -c -v 4 ch.threema.app.libre_974.apk | grep -v OK
Verifying alignment of ch.threema.app.libre_974.apk (4)...
Verification succesful