Quick context: mobile security has been a recurrin...
# random
j
Quick context: mobile security has been a recurring focus for me, a few articles and codelabs along the way. PoisonStack is the latest, and the most specific I've gotten about the Android side. Tl,DR: Don' t trust in any Plugin or fancy library you found, without read ALL the code. (same for AI skills) A research artifact some of you might find interesting: three deliberately malicious Android components written in Kotlin, demonstrating that supply chain attacks against Android don't need to be sophisticated. - speedbuild-plugin: a Gradle plugin (afterEvaluate + Android Transform with ASM) that scans local.properties, gradle.properties, env and signing configs, and registers a Transform that identifies Application.onCreate() as a bytecode-injection target. - kryptokit: a KMP library whose kryptokit-core/build.gradle.kts runs executeAttack() at top level — fires during dependency resolution, before any task. Plus four independent crypto defects in the runtime API: deterministic IV from hash(password), a hardcoded BACKDOOR_KEY blended into every derived key, PBKDF2 iterations clamped to 1000, and "random" derived from currentTimeMillis() % 10000. - androidlens-plugin: an IntelliJ plugin (StartupActivity, no permission system) that walks the project, probes ~/.aws/credentials / ~/.ssh/config / ~/.m2/settings.xml, and builds an attacker briefing from Retrofit endpoint annotations. None uses anything outside documented APIs. The thesis is that the composition of "Gradle + dependency resolver + IntelliJ" doesn't have an owner, and the unsophisticated version of each attack already works. Repo: github.com/jacksonfdam/poisonstack Four-part writeup: https://www.linkedin.com/pulse/trust-stack-four-part-series-jackson-f-de-a-mafra-ghryf Research only. Everything that should exfiltrate writes to a local log file instead. Do not ship any of it.
💯 4
r
Interesting stuff but backdoorDecrypt does not work as stated (gives BadPaddingException same as for an incorrect key)
Not clear how it’s supposed to work because it’s using SHA-256(realPassword:masterKey) as the KDF so you’re always going to need the realPassword to recover it
j
Hi @Robert Williams, fuck, you're absolutely right, and thanks for actually running it. The code as published was broken:
encrypt()
keyed AES from
SHA-256(password:BACKDOOR_KEY)
, but
backdoorDecrypt()
keyed it from
SHA-256(BACKDOOR_KEY)
alone, two different keys, so it always threw
BadPaddingException
. As you noted, you'd need the real password to recover, which makes it not a backdoor at all.
I've pushed a fix that uses the pattern a real malicious maintainer would actually ship: envelope encryption. Each message gets a random data-encryption key (DEK); the payload is encrypted under the DEK; the DEK is then wrapped twice inside the ciphertext, once under the user's password, once under the master key. The user's
decrypt()
unwraps the first slot,
backdoorDecrypt()
unwraps the second.
👌 1
The user's password genuinely protects against outsiders; the maintainer still owns every payload without ever seeing the password.
This is actually a better illustration of the article's point than the original that's how real "key escrow"/"recovery" backdoors are designed in the wild.
The "BACKDOOR_KEY" naming is still on the nose for didactic reasons; in a real attack it would be called
_recoveryHint
or
complianceMetadata
. Article, docs, and the KryptoKit.kt source are all updated. Really appreciated the catch.👊