Crashlytics plugin writes build ID lists in directory listing order, so APKs can differ between machines
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- build-system, mobile
Research direction
Start in BuildIdInfoCollector.collect() in firebase-crashlytics-buildtools, where the loop over FileUtils.listFiles() adds BuildIdInfo rows, and check how the library name, arch and build ID lists are derived from that one list. Add a deterministic sort at the end of collect() using the fields the issue proposes, then check the output with a unit test that feeds files in shuffled order. Done means the same inputs always give the same row order and the three lists stay paired.
Written by the indexing model from the issue text.
Description
[REQUIRED] Step 2: Describe your environment
- Android Studio version: not used; command-line build with Gradle 9.3.1, AGP 9.1.1 and JDK 21
- Firebase Component: Crashlytics Gradle plugin
- Component version: 3.0.8
[REQUIRED] Step 3: Describe the problem
When nativeSymbolUploadEnabled is on, the plugin writes three lists into the app's resources:
com.google.firebase.crashlytics.build_ids_lib, _arch and _build_id.
The rows follow directory listing order and are not sorted. So the same source can produce a different
resources.arsc, which breaks reproducible builds. We verify open source Bitcoin wallets at WalletScrutiny,
and this is how we found it.
BuildIdInfoCollector.collect() loops over FileUtils.listFiles()
and adds rows in that order. That helper
does not sort either.
Steps to reproduce:
- Use an app with native libraries, and set
nativeSymbolUploadEnabled true. - Build it normally, and keep
com_google_firebase_crashlytics_build_ids.xml. - Mount the source with
disorderfs --shuffle-dirents=yes --reverse-dirents=no --sort-dirents=no <source> <mount>. - Build the same commit inside the mount.
- Compare the two files. The rows match, but their order differs.
We ran these builds with P.CASH 0.60.1, commit ab67f8e649, on one host:
| Build | List order |
|---|---|
| Normal, first | same as second |
| Normal, second | same as first |
Under disorderfs shuffle |
different |
The shuffled build still had the same 80 rows. After sorting them, the only decoded difference left was the
random mapping_file_id (#2570). Two of the three APK splits stayed byte-identical.
We also compared the developer's official builds with ours:
| Release | Official file | Commit | Rows | Changed list lines |
|---|---|---|---|---|
| 0.60.1 | Google Play base.apk |
ab67f8e649 |
80 | 262 |
| 1.0.260 | GitHub -google APK |
596bf08522 |
74 | 246 |
Each pair has the same rows once sorted.
Limits of our testing:
- We ran one shuffled build.
- We did not build on two machines of our own.
- We have no minimal sample project.
Expected: the same source gives the same list order, whatever the directory listing order is.
Relevant Code:
Part of the 0.60.1 diff (official <, ours >):
< <item>libjnidispatch.so</item>
< <item>libgojni.so</item>
< <item>libcrashlytics-common.so</item>
> <item>libc++_shared.so</item>
> <item>libimage_processing_util_jni.so</item>
> <item>libsecp256k1-jni.so</item>
A possible fix, at the end of collect(), which we have not compiled or tested:
buildIdInfoList.sort(
Comparator.comparing(BuildIdInfo::getLibraryName)
.thenComparing(BuildIdInfo::getArch)
.thenComparing(BuildIdInfo::getBuildId));
All three lists come from this one list, so the rows should stay paired.
Related: #2570 covers the random mapping_file_id. This issue is only about list order.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 733
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 72
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-android-sdk
-
api: remoteconfig
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/firebase-android-sdk#8827 · 1 comment ·
Maintainers usually reply within 1 day
-
api: auth
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
firebase/firebase-android-sdk#8505 · 1 comment ·
Maintainers usually reply within 1 day
-
api: firebaseai
Difficulty 4/5 3-5 days Newbie friendliness 15/100
firebase/firebase-android-sdk#8835 ·
Maintainers usually reply within 1 day
-
api: auth
Difficulty 4/5 3-5 days Newbie friendliness 25/100
firebase/firebase-android-sdk#8832 ·
Maintainers usually reply within 1 day
-
Firestore: NoSuchElementException in SQLiteIndexManager.encodeValues for a != query with a trailing orderBy when cache index auto-creation is enabledPossibly taken @dconeybe claimed this 5 days ago. Openapi: firestore
firebase/firebase-android-sdk#8831 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in firebase/firebase-android-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
liberation-data/drivine4j#842 ·
Maintainers usually reply within 1 day
-
sanitizeOutput() drops all outputs of a process with only unnamed outputsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
linagora/twake-calendar-side-service#1578 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
moneymanagerex/android-money-manager-ex#3122 ·
Maintainers usually reply within 1 day