๐Ÿ” Android Security and Privacy

Common Android Security Vulnerabilities

Security reviews of Android apps keep finding the same classes of bugs. Knowing them, and seeing what vulnerable code looks like next to the fix, is the fastest way to stop shipping them.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 3 min read ๐ŸŽฏ Intermediate
On this page
  1. 1. Hard-coded secrets
  2. 2. Accidentally exported components
  3. 3. Intent redirection
  4. 4. Mutable PendingIntents
  5. 5. Insecure WebViews
  6. 6. Insecure storage and backups
  7. 7. Weak network security
  8. 8. Sensitive data in logs and screenshots
  9. 9. Trusting the client
  10. 10. Path traversal with file names from outside
  11. Building it into your process
  12. Quick triage
  13. Frequently asked questions
  14. Conclusion

Most real-world Android vulnerabilities aren't exotic exploits. They're configuration and design mistakes: a component exported by accident, a token in logs, a WebView that loads anything. Here are the most common ones, how attackers use them, and how to fix them.

Attack surface of an Android app An app's attack surface includes the APK contents such as secrets, exported components reachable by other apps, intents and deep links carrying untrusted data, WebViews loading content, network traffic, local storage and backups, and logs. Your app APK: secrets exported components intents / deep links WebViews network traffic storage, backups, logs
Every arrow is an input you must treat as untrusted, or an output that may leak.

1. Hard-coded secrets

Risk: keys extracted from the APK and abused. Fix: keep secrets server-side, and restrict any client keys. See Secure API Keys.

2. Accidentally exported components

Vulnerable vs fixedXML
<!-- โŒ Any app can start this and reach internal functionality -->
<activity android:name=".admin.ResetDataActivity" android:exported="true" />

<!-- โœ… Internal-only -->
<activity android:name=".admin.ResetDataActivity" android:exported="false" />

Audit every exported="true". Exported components must validate all input and should not perform sensitive actions without authentication.

3. Intent redirection

Vulnerable: forwarding an untrusted IntentKotlin
// โŒ An external app passes an Intent extra that points to a private component; we launch it with our privileges
val next = intent.getParcelableExtra<Intent>("next")
startActivity(next)

// โœ… Don't forward intents; use your own allow-listed destinations
when (intent.getStringExtra("destination")) {
    "orders" -> startActivity(Intent(this, OrdersActivity::class.java))
    else -> finish()
}

4. Mutable PendingIntents

PendingIntent flagsKotlin
// โœ… Immutable unless you truly need fill-in
PendingIntent.getActivity(context, requestCode, Intent(context, MainActivity::class.java),
    PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)

A mutable PendingIntent with an implicit base intent can be hijacked by another app to act with your app's identity.

5. Insecure WebViews

Safer WebView defaultsKotlin
webView.settings.apply {
    javaScriptEnabled = false              // enable only if required by your own trusted content
    allowFileAccess = false
    allowContentAccess = false
}
webView.webViewClient = object : WebViewClient() {
    override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
        val host = request.url.host ?: return true
        return host != "help.example.com"   // block navigation to anything else (true = we handle/block)
    }
}

Never combine addJavascriptInterface with untrusted content.

6. Insecure storage and backups

Risk: tokens or personal data in plain files, on external storage, or in backups. Fix: app-private storage, Keystore-backed encryption, and backup exclusions. See Encrypted Storage.

7. Weak network security

Never do thisKotlin
// โŒ Trust-all TrustManager: disables TLS protection entirely
object : X509TrustManager {
    override fun checkServerTrusted(chain: Array<X509Certificate>, authType: String) {}  // accepts anything
    override fun checkClientTrusted(chain: Array<X509Certificate>, authType: String) {}
    override fun getAcceptedIssuers(): Array<X509Certificate> = emptyArray()
}

Use the platform defaults, Network Security Config, and no cleartext traffic.

8. Sensitive data in logs and screenshots

Fix: remove debug logging of tokens and personal data from release builds, and use FLAG_SECURE on screens showing sensitive data.

9. Trusting the client

Risk: prices, feature unlocks or user IDs accepted from the app. Fix: the server computes and authorises everything, using verified identity tokens and Play Integrity for high-value actions.

10. Path traversal with file names from outside

Validate file pathsKotlin
fun safeFile(dir: File, untrustedName: String): File {
    val file = File(dir, untrustedName).canonicalFile
    require(file.path.startsWith(dir.canonicalPath + File.separator)) { "Invalid path" }   // blocks ../../
    return file
}

Building it into your process

  • Enable lint security checks and treat them as errors.
  • Add a security section to your PR template (exports, intents, storage, logging).
  • Run periodic reviews against OWASP MASVS for sensitive apps.
  • Keep dependencies updated, and watch for security advisories.

Quick triage

Before every release

Grep the manifest for exported components, check logging, and confirm no secrets in the build.

New WebView feature

Host allow-list, JavaScript only if needed, no file access.

New deep link

Validate parameters, and authorise on the server.

Frequently asked questions

Does Google Play scan for these issues?

Play performs some automated checks and may warn about known vulnerable patterns, but you remain responsible for your app's security.

Is Kotlin safer than Java here?

Kotlin prevents some bugs (null safety), but these vulnerabilities are about design and configuration, which apply in any language.

Where should a small team start?

Secrets, exported components, logging and TLS. They're quick to check and cover many real incidents.

Conclusion

Most Android vulnerabilities come from untrusted input reaching privileged code or sensitive data leaking out. Minimise exports, never forward intents, use immutable PendingIntents, lock down WebViews and TLS, protect storage and logs, and keep the server as the source of truth.

Next step: ship your secure app with How to Publish an Android App on Google Play.

Official references

๐Ÿ“ฑ Apps built by Yunok Tech

Real Android apps on Google Play, free to download.

See all our apps โ†’

Ready to build real Android applications?

Security is easiest to get right when it is part of how you build from the first screen. Strengthen the Android fundamentals that secure, privacy-respecting apps are built on.

Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.

Explore the Android course and take your next step as an Android developer.

Share: LinkedIn X / Twitter WhatsApp