rosuh/easywatermark/android-permissions-security
Claude Code and agent skill by rosuh/easywatermark
- community
Checking that the SKILL.md file is still in the repository.
Audits, detects gaps, and remediates Android permissions and IPC component
Install
npx vskill@latest install rosuh/easywatermark/android-permissions-securitySKILL.md
The same SKILL.md was published earlier as android/skills/android-permissions-security.
Guidelines for auditing permission vulnerabilities, enforcing least privilege, securing IPC boundaries, and handling runtime permissions across the Android ecosystem.
Glossary
- Runtime Permission: Dangerous permission (e.g., Camera, Location) that must be granted by the user at runtime on Android 6.0+ (API 23+).
- Custom Permission: A permission defined by an app (
<permission>) to restrict access to its exported components. - Protection Level: Attribute defining how the OS grants the permission (
normal,dangerous,signature,knownSigner). - knownSigner: Protection flag (API 31+) granting signature-level access to partner apps matching trusted certificate digests.
- SigningInfo: Object (API 28+) providing signing history and multiple signer certificates for an application.
- Binder Calling Identity: Reliable UID representing the calling process obtained using
Binder.getCallingUid(). - URI Permission: Temporary, granular access granted to a content URI using
grantUriPermissionsand intent flags.
Prerequisites
- Add
androidx.core:core-ktxandandroidx.activity:activity-ktx(orandroidx.fragment:fragment-ktx) dependencies to the app-levelbuild.gradlefile forContextCompatandActivityResultContracts. - For
knownSignerpartner permissions (android:knownCerts), ensure the projectcompileSdkandtargetSdkare at least 31 (Android 12). - For broadcast identity sharing (
BroadcastOptions.setShareIdentityEnabled), ensurecompileSdkandtargetSdkare at least 34 (Android 14).
* * *
1. Security audit and permission gap detection playbook
When auditing an Android project for permission and IPC security vulnerabilities, systematically inspect each area:
| Vulnerability Area | Search In / Pattern | Risk | Remediation Action | ||
|---|---|---|---|---|---|
| Weak Custom Permission Protection | AndroidManifest.xml with android:protectionLevel="normal", "dangerous", or "signatureOrSystem" | Unauthorized apps request or claim permission without restriction | Upgrade to signature or `signature | knownSigner with android:knownCerts`. | |
| Overly Broad URI Permission Grants | <grant-uri-permission android:pathPrefix="/" /> or pathPrefix="" in <provider> | Leaks all provider data to third parties | Replace with explicit scoped subpath (e.g. android:pathPrefix="/shared/"). Retain android:grantUriPermissions="true". Remove any wildcard pathPrefix="/". | ||
| Missing ContentProvider Split Permissions | <provider> with only generic android:permission or missing android:readPermission and android:writePermission | Read-only callers execute write operations or write-only callers access read operations | Configure granular android:readPermission="...READ_DATA" and android:writePermission="...WRITE_DATA", AND declare the custom <permission> tags with android:protectionLevel="signature" (or `signature | knownSigner) at the <manifest>` root. | |
| Spoofable Caller Identity Checks | intent.getStringExtra("calling_package"), intent.getStringExtra("sender"), callingPackage == "..." in Services | Malicious callers forge intent extras or strings | Remove string checks; authenticate caller UID cryptographically using Binder.getCallingUid() and pm.hasSigningCertificate(). | ||
| Bound Service Permission Bypass | checkCallingOrSelfPermission() or enforceCallingOrSelfPermission() in Binder AIDL stubs | Falls back to host app UID outside IPC or when identity is cleared, causing Confused Deputy bypass | Replace with enforceCallingPermission("...WRITE_DATA", ...) or checkCallingPermission("...WRITE_DATA"). | ||
| Missing Method-Level Checks in Bound Services | Bound Service AIDL methods mutating state without enforcing write permissions | Callers with read-only binding access invoke mutating write operations | Add enforceCallingPermission("...WRITE_DATA", "Caller lacks WRITE_DATA permission") inside mutating AIDL methods. | ||
| Flawed Runtime Permission Flow | Missing shouldShowRequestPermissionRationale(), missing permanent denial handling, or re-requesting in loops | Poor user experience, infinite loops, or inability to recover permissions | Implement 3-state flow: check grant -\> check rationale dialog -\> launch contract. On permanent denial, redirect to Settings.ACTION_APPLICATION_DETAILS_SETTINGS. | ||
| Simultaneous Location Requests | arrayOf(ACCESS_FINE_LOCATION, ACCESS_BACKGROUND_LOCATION) in one request | Rejected by Android 11+ (API 30+) | Request foreground location (ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION) first. Request ACCESS_BACKGROUND_LOCATION only after foreground is granted in a separate user step. | ||
| Broad Storage Permissions for Media | Requesting READ_EXTERNAL_STORAGE or READ_MEDIA_IMAGES for user image selection | Over-privilege, user privacy violation | Migrate to zero-permission Photo Picker (ActivityResultContracts.PickVisualMedia). | ||
| Cached Permission State | Storing permission status in var cachedLocationPermissionGranted = ... | Fails when permission is revoked or expires | Query ContextCompat.checkSelfPermission() dynamically at invocation time and wrap protected calls in try-catch blocks catching SecurityException. | ||
| Insecure Broadcasts | sendBroadcast(intent) without package target or receiver permission; receiver without sender authentication | Data interception or command spoofing | Set explicit package (intent.setPackage(...)), pass receiver permission, and enable BroadcastOptions.setShareIdentityEnabled(true) (API 34+) to verify sentFromPackage. |
* * *
2. Custom permissions and protection levels
When declaring custom permissions or partner certificates in the manifest, you must follow the instructions in the `<permission>` element guide.
- `signature`: Restricts access to apps signed with the same developer key.
- `signature|knownSigner` (API 31+): Restricts access to partner apps whose signing certificate digests match declared hashes in
android:knownCerts. - `normal` or `dangerous` : Do not use for private inter-app IPC.
- `signatureOrSystem` : Deprecated (API 23). Upgrade deprecated
signatureOrSystempermissions tosignature. Avoid in non-system apps.
Manifest snippets
Signature-level custom permission
Use signature permissions when restricting component access exclusively to apps signed with the same developer certificate by declaring the <permission> in the manifest and applying android:permission to the target component.
<br />
KnownSigner partner permission (API 31+)
Use signature|knownSigner permissions when granting access to specific external partner apps by declaring the <permission> in the manifest with android:knownCerts referencing a resource array of trusted SHA-256 certificate digests.
<br />
<br />
* * *
3. Exported component protection and URI permissions
- Private components : Always set
android:exported="false". - Exported components : Require permissions (
android:permission,android:readPermission,android:writePermission). - Granular URI Grants : Retain
android:grantUriPermissions="true"for secure sharing, but scope grants to specific sub-paths. Never use wildcardpathPrefix="/". - Custom Permission Declarations : When splitting read and write permissions on a provider, you MUST declare the
<permission>tags withandroid:protectionLevel="signature"(orsignature|knownSigner) at the<manifest>root level. - Remediating Existing Wildcard Grants : You MUST find and remove any existing
<grant-uri-permission android:pathPrefix="/" />orpathPrefix=""and replace it with an explicit scoped subpath (e.g.android:pathPrefix="/shared/"). - Granular `UriPermission` Management : Instead of broad manifest grants, use runtime
android.content.UriPermissiontokens for least-privilege per-URI sharing: - Grant temporary access : `context.grantUriPermission(targetPackage,
uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) or attach Intent.FLAG_GRANT_READ_URI_PERMISSION` to outgoing intents.
- Persist access : The receiving app calls
contentResolver.takePersistableUriPermission(uri, modeFlags)for durable access across reboots. - Audit active grants : Inspect
contentResolver.persistedUriPermissions(List<UriPermission>) to verify granted URIs (uriPermission.uri,uriPermission.isReadPermission(),uriPermission.isWritePermission()). - Revoke access : Call
context.revokeUriPermission(uri, modeFlags)orcontentResolver.releasePersistableUriPermission(uri, modeFlags)as soon as operations conclude.
Manifest snippet: Complete secure ContentProvider declaration
Declare the split read and write permissions at the <manifest> root:
<br />
Then configure the provider with those permissions and a scoped URI grant:
<br />
Runtime granular UriPermission management snippet
<br />
* * *
4. Cryptographic caller identity verification
Never trust caller package names provided in Intents or string arguments (getCallingPackage(), intent.getStringExtra("calling_package"), intent.getStringExtra("sender"), intent.getStringExtra("package")). Intent extras and string package names are forged by malicious applications.
Critical vulnerability: Package name spoofing using intent extras
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-permissions-security/SKILL.md
Popularity
- Repository stars
- 1,894
- Repository forks
- 155
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rosuh/easywatermark/android-permissions-security)