Cross-Platform Binary Transparency Proof System for Mobile Apps
Overview
This design introduces Mobile Binary Transparency (MBT) , a system ensuring that distributed mobile app binaries (APKs/IPAs) match exactly what was built in a verified CI/CD pipeline. It prevents supply chain attacks, unauthorized modifications, and post-build tampering by:
Generating cryptographic attestations during builds.
Logging them to a public append-only transparency log (using Trillian for scalability and gossip-proof consistency).
Hooking into distribution channels (App Stores, sideloading) to publish verifiable references.
Enabling client-side verification on devices.
Supporting incident response for revocations and audits.
Key Principles :
Reproducible Builds : Binaries built from source must be deterministic.
Zero-Trust Distribution : No trust in app stores or CDNs; verify against public logs.
Cross-Platform : iOS (Swift/Xcode), Android (Kotlin/Java/Gradle), with extensibility to Flutter/React Native.
Lightweight : Client verification <100ms, no persistent server dependency.
Open Standards : DSSE (Document Signing with Envelopes) via Sigstore, SLSA Provenance v0.2, Merkle Tree Proofs.
Architecture Diagram (text-based):
code Copy code
[Developer CI/CD] --> Build Attestation (SLSA + Binary Hash) --> [MBT Transparency Log (Trillian)]
|
| Log Entry ID (SCT-like)
v
[App Store Hooks / Sideloading] <-- Publish/Release ------------> [Audit Tools / Monitors]
|
v
[Mobile Client SDK] <-- Install/Launch --> Verify (Hash + Log Proof + Sig)
|
v
[Incident DB] <-- Revocations --> Client Blacklist Check
Tech Stack :
Log: Trillian (Google's open-source Merkle Tree log).
Signing: Sigstore (Fulcio CA, Rekor transparency).
Formats: JSON Web Signature (JWS) for attestations, CBOR for efficiency.
SDKs: Native (iOS: Swift Package Manager; Android: Gradle plugin).
1. Build Attestations
Attestations prove: "This binary was built from commit X in env Y by actor Z."
Process
Pre-Build : Enforce reproducible builds.
iOS: Use xcodebuild with fixed SDK/toolchain versions; Bazel for hermeticity.
Android: Gradle with --reproducible flag; fixed AGP.
Tools: diffoscope in CI to verify reproducibility.
Build Metadata Collection :
Git commit SHA, tag/version.
Build env: Docker image hash, runner ID (GitHub Actions/Jenkins).
Dependencies: SBOM (CycloneDX via syft or trivy).
Binary hash: BLAKE3 (fast, collision-resistant) of final IPA/APK.
Attestation Generation :
Use cosign or sigstore-go to create a DSSE envelope.
Payload (SLSA Provenance):
json Copy code
{
"predicateType": "https://slsa.dev/provenance/v0.2",
"predicate": {
"buildType": "https://example.com/ci/mobile-build",
"invocation": { "configSource": { "git": "https://repo/commit.sha" } },
"materials": [...], // SBOM refs
"metadata": {
"reproducible": true,
"binaryHash": "blake3:abc123...", // Matches distributed binary
"appId": "com.example.app",
"version": "1.2.3"
}
}
}
Sign with OIDC (GitHub Actions token) via Fulcio → Rekor logs it automatically.
Integration :
CI Plugins :
Platform Tool iOS Fastlane plugin: fastlane-plugin-mbt-attest (runs post-xcodebuild). Android Gradle plugin: mbt-attest (task after bundleRelease). Cross (Flutter) flutter_mbt pub package.
Output: Attestation JWS + Log Entry ID (SCT).
2. Distribution Hooks
Link releases to log entries without trusting distributors.
App Store Integrations
Google Play :
Use Play Console API (OAuth) in CI: Post-release, upload Log ID to track/release notes metadata.
Hook: supply tool (Fastlane equivalent) + custom script queries log for proof.
Apple App Store :
App Store Connect API: Webhook on "release" event triggers log append if not done.
Fastlane deliver + mbt-hook plugin embeds Log ID in Info.plist (custom MBTLogID key).
Sideloading/Enterprise :
Manual: CI publishes APK/IPA to CDN (e.g., Firebase) with manifest.json including { "logId": "sct-123", "binaryHash": "blake3:..." }.
TestFlight/Internal: Same as App Store.
Log Append
CI submits attestation to Trillian log via gRPC API.
Log returns Signed Certificate Timestamp (SCT): { logId: "mbt-log-1", sct: "base64...", merkleProof: [...] }.
Embed SCT in app metadata (Android: apk.json; iOS: embedded.mobileprovision extension).
Verifier Guarantee : App stores can't fake SCTs (proof verifiable against log root).
3. Verification Clients
SDKs for runtime/install-time checks. Runs on first launch or via OS hooks (e.g., Android Verified Boot).
SDK Features
iOS (Swift) : SPM package MBTVerify.
swift Copy code
import MBTVerify
func verifyApp() async throws {
let verifier = MBTVerifier(logUrl: "https://mbt-log.example.com")
try await verifier.verify(binaryHash: getBinaryHash(), sct: getEmbeddedSCT())
}
Android (Kotlin) : Gradle implementation 'com.mbt:verify:1.0'.
kotlin Copy code
MBTVerifier(logUrl = "https://mbt-log.example.com")
.verify(getApkHash(), getSctFromAssets())
Verification Steps (idempotent, offline-capable with cache):
Extract binary hash (self-hash via syscall or SDK).
Load SCT from bundle/assets/Info.plist.
Fetch log root (pinned via certificate).
Validate Merkle inclusion proof: Hash(SCT) ∈ log root.
Verify Sigstore signature (Rekor/Fulcio public roots).
Check attestation: binaryHash matches, version ≥ expected.
Query incident DB (Redis/Cache) for revocations.
Fallbacks : Offline mode caches root (update weekly); network fail → warn user.
UI : Alert on failure: "App modified! Reinstall from official source."
Automation : Integrate with MAU (Mobile App Usage) metrics; block launch if invalid.
Performance : <50ms on 4G; uses CDNs for log roots.
4. Incident Response
Handle compromises (e.g., CI key leak, malicious build).
Mechanisms
Revocation :
Incident DB: Bloom filter or Merkle set of revoked SCTs (query via gRPC).
Clients check: isRevoked(sctHash).
Threshold signatures for log operators to avoid single-point failure.
Auditor Dashboard :
Web UI: Query log by appId/version; visualize forks (tampered builds).
Gossip protocol: Monitors submit roots; detect inconsistencies (CT-style).
Workflow :
Incident Response Build compromise Emit revocation SCT; notify via push (FCM/APNs). Log attack Switch to mirror log; clients pin multiple roots. App Store tampering Auditor detects hash mismatch → public alert. Mass recall Batch revoke via v2 log inclusion.
Monitoring :
Passive: RSSAC-like root monitors.
Active: Bots download apps from stores, verify against log.
Deployment & Adoption
Open Source : GitHub repo with log (self-hostable).
Pilot : Start with 5 apps; scale to log 1M entries/day.
Costs : Trillian ~$0.01/entry; free tier via sponsors.
Security Model : Qubes-like; audits by Trailblazer Labs.
This system achieves end-to-end transparency with minimal developer overhead (~5min/build). For implementation code/repos, provide specifics!