跳到正文
Skillpedia
安全10k · #11933

android-permissions-security

它能做什么

这个技能审计 Android 权限,以及其他应用可以访问的组件的安全性。它还涵盖运行时权限请求。适合希望对应用实行最小权限原则的 Android 开发者。

适用场景

  • ✓当你想审查 AndroidManifest 中的权限并移除应用不需要的权限时。
  • ✓当你想定义自定义权限,以保护应用导出的组件时。
  • ✓当你需要在服务或提供程序中验证调用方应用身份的时候。

技能链接

https://github.com/android/skills/blob/main/security/android-permissions-security/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/android/skills/blob/main/security/android-permissions-security/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请审查我 AndroidManifest 中的权限,并保护其他应用可以调用的服务和接收器。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能会检查清单中有风险的权限设置和导出组件。然后它会推荐修复方案,例如自定义权限、调用方签名检查以及正确的运行时权限流程。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

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 grantUriPermissions and intent flags.

Prerequisites

  • Add androidx.core:core-ktx and androidx.activity:activity-ktx (or androidx.fragment:fragment-ktx) dependencies to the app-level build.gradle file for ContextCompat and ActivityResultContracts.
  • For knownSigner partner permissions (android:knownCerts), ensure the project compileSdk and targetSdk are at least 31 (Android 12).
  • For broadcast identity sharing (BroadcastOptions.setShareIdentityEnabled), ensure compileSdk and targetSdk are 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 with knownSigner and 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 with 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_BACKGROUN
常见问题

什么是签名权限?

它是只授予使用相同开发者密钥签名的应用的权限,该技能可以用它来限制访问。

它会处理运行时权限弹窗吗?

会。它涵盖 Android 6.0 及更高版本上危险权限的运行时权限流程。

它需要额外的库吗?

需要。它说明,它所添加的代码需要一些 AndroidX 库。

详情

作者的原始描述

Audits, detects gaps, and remediates Android permissions and IPC component security vulnerabilities. Use when reviewing AndroidManifest.xml, defining custom permissions, securing Services, Receivers, and Providers, verifying caller signatures and UID using Binder, or implementing runtime permission flows.

repo: android/skills

热度

GitHub 星标
10k
排名
#11933
许可证
Apache-2.0
更新时间
2026/10/29

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能