Lesson 1 of 13 · 12m
Inside the Package
An APK is a zip with DEX, a binary manifest, and a signature scheme whose v1 design let Janus prepend hostile DEX code — an IPA is the same archive shape under Apple's per-byte code signature.
It starts with unzip
An APK is a zip file. Run unzip -l base.apk and the contents are mundane: classes.dex (plus classes2.dex, classes3.dex on multidex apps), AndroidManifest.xml in binary XML form, resources.arsc holding the compiled string and resource tables, lib/arm64-v8a/*.so native libraries, and a META-INF/ directory containing CERT.RSA, CERT.SF, and MANIFEST.MF — the JAR-style v1 signature. If the app was signed with v2 or later, there's also an APK Signing Block record inserted between the file entries and the zip central directory.
apktool d app.apk decodes the binary manifest back to readable XML and disassembles the DEX to smali with baksmali. jadx gives you a Java-ish view across every DEX at once. aapt dump badging app.apk prints the package name, min/target SDK, and requested permissions in three lines. None of this needs root. None of it needs source.
The IPA is the same shape: a zip whose Payload/<App>.app/ contains a Mach-O executable, Info.plist, embedded.mobileprovision, and _CodeSignature/CodeResources — a per-file hash manifest. One difference that matters for analysis: binaries downloaded from the App Store arrive FairPlay-encrypted. otool -l shows an LC_ENCRYPTION_INFO load command with cryptid 1; every __TEXT section reads as ciphertext until the kernel decrypts it at exec. To get a binary Ghidra can read you need a decrypted dump — frida-ios-dump or Bagbak on a palera1n-jailbroken checkm8 device (A7 through A11), which is why a used iPhone 8 is standard lab equipment.
The signature is not what you think
The wrong mental model: "the signing certificate covers the file." v1 signing doesn't sign a file. It signs named entries. MANIFEST.MF lists each entry name with a digest; CERT.SF digests the manifest; CERT.RSA signs that. Anything not listed as an entry — or anything that exists before the zip structure begins — is outside the signature entirely.
Janus, CVE-2017-13156, patched in the December 2017 Android bulletin, ran exactly that seam. A zip is parsed from the end: the reader seeks to the end-of-central-directory record and works backward. A DEX file is parsed from the start, at offset zero. Concatenate evil.dex + legit.apk and you have a single file that is a valid APK to PackageManager — v1 verifies the original signed entries just fine — and a valid DEX to the runtime, which loads evil.dex when the app starts. Signature checks out. Payload hostile. Affected every v1-signed app on Android 5.0 through 8.0.
APK Signature Scheme v2, shipped with Android 7.0 in 2016, inserts a signing block covering the entire byte stream — entry order, padding, everything. Change one byte and verification fails. v3 (API 28) added key rotation; v4 (API 30) adds incremental .idsig signatures for streaming installs. Play has required v2 or better for new apps targeting API 30+ since late 2020. Check what you actually shipped:
apksigner verify --print-certs --min-sdk-version 24 app.apkIf Verified using v1 scheme (JAR signing): true and v2 says false, your minimum-SDK range still has the Janus seam on unpatched devices.
Where the bytes live
On a device the install lands at /data/app/<pkg>-<hash>/base.apk, with ART's ahead-of-time output beside it in oat/arm64/base.odex and base.vdex. pm list packages and dumpsys package <pkg> show install state, granted permissions, and which signature hash the system recorded. Split APKs from an App Bundle install via adb install-multiple — you can't adb install a single split.
On iOS, codesign covers every byte of the bundle, and the kernel refuses to launch a modified binary. That is exactly why sideloading means re-signing the whole bundle with a development certificate, a $99 paid account, or an enterprise certificate — and why enterprise cert abuse keeps getting certs revoked by Apple. There is no v1 seam here; the integrity model is stronger and older.
Practice
Audit your own artifact the way a pentester will: apktool d, jadx --deobf, aapt dump badging, apksigner verify. Confirm the scheme set is v2+ and minSdk 24+ (anything below can't verify v2). Read the decoded manifest before the Java — the manifest is where the attack surface is declared. For iOS targets, lipo -info for slices, otool -l | grep -A4 ENCRYPTION for cryptid, and decrypt on a jailbroken test device before you touch Ghidra.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
They Got Root on a Fully Patched Ivanti VPN and the Integrity Checker Said Everything Was Fine
Volexity caught an attacker chaining zero-days into unauthenticated root on an Ivanti Connect Secure appliance running the latest build. The payload never touched disk, commands rode in over the same HTTPS requests as the exploit, and Ivanti's Integrity Checker reported no modifications.
Gitea Shipped 21 CVEs in One Release and Eleven of Them Are the Same Bug
Gitea 28.3.0 landed November 1 with twenty-one CVE fixes. Read the list and a pattern jumps out: more than half are the same failure repeated across different route handlers, where a token scoped to public data gets handed private data anyway. That's not twenty-one mistakes.
php2shell: The PHP Bug That Fires Before Your Code Runs
Two critical PHP flaws landed October 21 and were in CISA's exploited-vulnerabilities catalog five days later. The 9.2 score isn't the part that should bother you. It's where the bug lives — it goes off while PHP is still assembling $_POST, before a single line of your application has run.
A Certificate Authority's Private Keys Were the Numbers 4, 56 and 66
Eight eMudhra intermediate CA keys turned out to be recoverable from their own public certificates. Not stolen — computable, because the key generation produced almost no entropy. A researcher pulled all eight in under a second and signed a message with each one to prove it.