android-intent-security
Skill này làm gì
Skill này cung cấp hướng dẫn bảo vệ các activity, service, receiver và provider của Android, cũng như xử lý an toàn các intent đến. Nó dành cho lập trình viên Android muốn ngăn các ứng dụng khác lạm dụng thành phần của mình.
Khi nào nên dùng
- ✓Khi bạn muốn rà soát các activity, service hoặc receiver được export trong manifest Android.
- ✓Khi ứng dụng của bạn đọc dữ liệu intent đến và bạn muốn ngăn chuyển hướng intent.
- ✓Khi bạn muốn kiểm tra việc dùng PendingIntent và các content provider về truy cập trái phép.
Liên kết skill
https://github.com/android/skills/blob/main/security/android-intent-security/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Kiểm toán AndroidManifest của tôi và đoạn mã đọc các intent đến xem có vấn đề bảo mật nào không.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill giải thích các mẫu rủi ro, chẳng hạn thành phần được export và PendingIntent có thể thay đổi, rồi chỉ ra các mẫu an toàn để thay thế. Nó áp dụng những điều này vào manifest và đoạn mã xử lý intent đến.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
This skill provides guidelines and patterns to secure Android components (Activities, Services, Broadcast Receivers, Content Providers) and handle Intents safely, preventing privilege escalation and unauthorized access.
Glossary
- Intent: An asynchronous messaging object used to request an action from another app component.
- Exported component: A component (
android:exported="true") that can be launched by other apps on the device. - Sticky intent: A broadcast intent that remains in the system cache after it's sent, allowing any app to retrieve its contents.
- Signature permission: A permission whose protection level is set to
signature, granted only to apps signed with the same developer key. - onNewIntent: An activity lifecycle callback invoked when an activity is launched with
FLAG_ACTIVITY_SINGLE_TOPand is already running at the top of the history stack. - PendingIntent: A token granted to a foreign application (for example, system services) allowing it to execute a predefined Intent with the creator's permissions.
- Mutable PendingIntent: A PendingIntent whose underlying Intent parameters can be modified by the receiving application.
- ContentProvider: A component that encapsulates data and provides it to other applications via standard query/insert interfaces.
- IntentSanitizer: A utility class in AndroidX Core used to build a safe, sanitized copy of an incoming Intent by filtering out unauthorized components, actions, or extras.
- Intent redirection (forwarding): A vulnerability where an application receives an intent from an untrusted source and uses it to launch a private, non-exported component.
Prerequisites
- The agent MUST be able to describe the function and security implications of
onCreate,onNewIntent, and thesingleToplaunch mode. - The agent MUST be able to declare
<activity>,<service>,<receiver>, and<provider>tags inAndroidManifest.xmland define theirandroid:exportedandandroid:permissionattributes. - The agent MUST be able to implement signature verification checks using
PackageManager.
Limitations
- This skill focuses on local inter-component and inter-app communication security on the Android platform.
- This skill doesn't cover network security, web integration, or host-to-server security.
Setup and dependencies
- Android SDK: Minimum API Level 23 (Android 6.0) is required for standard hardware-backed keystore operations and component validation.
- AndroidX Core Library:
androidx.core:core:1.9.0or higher is mandatory to leverageIntentSanitizer. - Standard API access: Standard Android
PackageManagerAPIs are required for runtime component verification.
Intent security logic and decisions
1. Intent routing comparison
Evaluate the security features of different intent delivery methods:
| Intent Delivery Method | Scope | Recommended Use Case |
|---|---|---|
| Explicit Intent (Internal) | App Private | Launching internal activities/services |
| Implicit Intent | System Wide | Launching system camera, dialer, or sharing |
| Local Broadcasts (LocalBroadcastManager) (DEPRECATED) | App Private | Internal asynchronous event routing. Deprecated: Use in-app observers like Kotlin Flows/SharedFlow, LiveData, or reactive patterns instead. |
| System Broadcasts | System Wide | Receiving system events (NFC, Bluetooth) |
2. PendingIntent mutability flag options
Evaluate the security implications of PendingIntent mutability flags:
| Flag Name | Mutability | Recommended Use Case |
|---|---|---|
PendingIntent.FLAG_IMMUTABLE |
Immutable | Default for almost all PendingIntents, such as alarms and notifications |
PendingIntent.FLAG_MUTABLE |
Mutable | Inline notifications replies, slice actions (requires explicit target intent) |
3. Intent handling and redirection logic
IF (the component receives a nested Intent as an extra) {
IF (AndroidX Core 1.9.0+ and higher is available) {
MUST construct an IntentSanitizer to explicitly allowlist components, actions, data, and extras.
MUST call sanitizeByThrowing() or sanitizeByFiltering() before launching.
} ELSE {
MUST reject or strip URI permission grant flags (FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION).
MUST resolve the target component using resolveActivity() and verify that b
Câu hỏi thường gặp
Thành phần được export là gì?
Đó là thành phần mà các ứng dụng khác có thể khởi chạy trên thiết bị, nên cần được bảo vệ cẩn thận.
PendingIntent có thể thay đổi là gì?
Đó là PendingIntent mà ứng dụng nhận có thể thay đổi nội dung, và skill cảnh báo về điều này.
Nó có bao quát quyền hạn không?
Quyền hạn do một skill liên quan đảm nhiệm, còn skill này tập trung vào intent và thành phần.
Chi tiết
Mô tả gốc của tác giả
Best practices for Android Intent security. Use this skill when auditing component configurations in AndroidManifest.xml activities, services, receivers) or source code handling incoming Intents (getIntent, getParcelableExtra) to prevent Intent Redirection and unauthorized access.
repo: android/skills
Độ phổ biến
- Sao GitHub
- 10k
- Vị trí xếp hạng
- #11932
- Giấy phép
- Apache-2.0
- Cập nhật
- 29/10/2026
Bình luận
- …
Thêm skill từ kho mã này
agp-9-upgrade
10kGiúp agent của bạn nâng cấp ứng dụng Android lên Android Gradle Plugin 9 và xử lý các thay đổi gây lỗi. Không dành cho dự án đa nền tảng.
camerax
10kGiúp agent của bạn xây dựng các tính năng camera Android bằng CameraX, gồm quay video, điều khiển phần cứng, ML Kit và hiệu ứng Media3.
android-for-cars-parked-apps
10kĐiều chỉnh một ứng dụng video, trò chơi hoặc trình duyệt Android để chạy như ứng dụng khi xe đỗ trên Android Auto và Android Automotive.
appfunctions
10kTìm các luồng công việc chính trong ứng dụng Android và công khai chúng dưới dạng AppFunctions để agent AI và lệnh giọng nói có thể chạy.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.