android-intent-security

Harden Android components against Intent redirection and unauthorized access vulnerabilities.

3|Updated Aug 4, 2024
One-click install
npx skills add https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform --skill android-intent-security-kabindra-shrestha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-intent-security
Source: https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform/tree/main/.agents/skills/security/android-intent-security
Command: npx skills add https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform --skill android-intent-security-kabindra-shrestha

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Android apps that handle incoming Intents, PendingIntents, or expose components like Activities, Services, and ContentProviders are vulnerable to Intent redirection, component hijacking, and privilege escalation. This Skill provides concrete patterns and decision logic to audit and secure these attack surfaces. ## Core Features & Use Cases - Safe Intent Redirection: Validate nested Intents using AndroidX IntentSanitizer or manual package/exported checks before launching. - PendingIntent Hardening: Enforce FLAG_IMMUTABLE by default and require explicit components for mutable PendingIntents. - Component Protection: Configure signature-level permissions, exported flags, and ContentProvider read/write permissions in AndroidManifest.xml. - Use Case: While auditing an app's AndroidManifest.xml, you find an exported Activity that launches a nested Intent from extras. Use this Skill to replace the unsafe launch with an IntentSanitizer allowlist and generate a structured security alignment report. ## Quick Start Audit my AndroidManifest.xml and all Intent handling code for Intent redirection vulnerabilities and apply the recommended security fixes.

Frequently Asked Questions about android-intent-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent Intent redirection vulnerabilities in Android?

Validate any nested Intent before launching it by checking the target package matches your app and the target component is exported. With AndroidX Core 1.9.0+, use IntentSanitizer with an explicit allowlist of components, actions, and extras, calling sanitizeByThrowing or sanitizeByFiltering.

Should I use FLAG_IMMUTABLE or FLAG_MUTABLE for PendingIntent?

Use PendingIntent.FLAG_IMMUTABLE by default for alarms and notifications so receivers cannot alter the Intent. Use FLAG_MUTABLE only for cases like inline notification replies, and always set an explicit target component on the base Intent to prevent hijacking.

How do I secure an exported Android Service from untrusted callers?

Retrieve the calling UID with Binder.getCallingUid, resolve it via PackageManager.getPackagesForUid, and verify the caller's signing certificate with hasSigningCertificate. Perform this check inside each Binder transaction method, not in onBind, since binder connections are cached.

What permissions should protect an exported ContentProvider?

Set android:readPermission and android:writePermission on the provider, keep grantUriPermissions false unless temporary access is required, and use signature-level permissions for family apps. Parameterize all query selections and enable strict SQLiteQueryBuilder validation to block SQL injection.

Why is handling Intents in onNewIntent a security risk?

Activities using singleTop launch mode receive new Intents via onNewIntent, which attackers can exploit through warm boot paths. Apply the same validation used in onCreate, call setIntent to update the active reference, and reject payloads failing security checks.

What are the limitations of this Android Intent security guidance?

It covers only local inter-component and inter-app communication security on Android. It does not address network security, web integration, or host-to-server communication, and it requires minimum API level 23 with AndroidX Core 1.9.0 or higher.