مقاصد معلق
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
دسته OWASP: MASVS-PLATFORM: پلتفرم تعامل
نمای کلی
PendingIntent
اشاره ای به توکنی است که توسط سیستم نگهداری می شود. برنامه A می تواند یک PendingIntent را به برنامه B ارسال کند تا به برنامه B اجازه دهد تا اقدامات از پیش تعریف شده را از طرف برنامه A انجام دهد. صرف نظر از اینکه برنامه A هنوز زنده است یا خیر.
ریسک: اهداف معلق قابل تغییر
یک PendingIntent میتواند تغییرپذیر باشد، به این معنی که هدف داخلی که عمل را مشخص میکند، میتواند توسط برنامه B به دنبال منطق توضیح داده شده در مستندات fillIn()
بهروزرسانی شود. به عبارت دیگر، فیلدهای پر نشده یک PendingIntent را می توان توسط یک برنامه مخرب تغییر داد و اجازه دسترسی به اجزای غیرصادرات نشده برنامه آسیب پذیر را می دهد.
تاثیر
تأثیر این آسیب پذیری بسته به اجرای عملکرد هدفمند صادر نشده برنامه متفاوت است.
اقدامات کاهشی
ژنرال
مطمئن شوید که عملکرد، مؤلفه و بسته برای جلوگیری از بدترین آسیبپذیریها تنظیم شدهاند:
کاتلین
val intent = Intent(intentAction)
// Or other component setting APIs e.g. setComponent, setClass
intent.setClassName(packageName, className)
PendingIntent pendingIntent =
PendingIntent.getActivity(
context,
/* requestCode = */ 0,
intent, /* flags = */ PendingIntent.FLAG_IMMUTABLE
)
جاوا
Intent intent = new Intent(intentAction);
// Or other component setting APIs e.g. setComponent, setClass
intent.setClassName(packageName, className);
PendingIntent pendingIntent =
PendingIntent.getActivity(
getContext(),
/* requestCode= */ 0,
intent, /* flags= */ 0);
پرچم تغییرناپذیر
اگر برنامه شما Android 6 (سطح API 23) یا بالاتر را هدف قرار میدهد، قابلیت تغییرپذیری را مشخص کنید . به عنوان مثال، این کار را می توان با استفاده از FLAG_IMMUTABLE
برای جلوگیری از پر شدن فیلدهای پر نشده توسط یک برنامه مخرب انجام داد:
کاتلین
val pendingIntent =
PendingIntent.getActivity(
context,
/* requestCode = */ 0,
Intent(intentAction),
PendingIntent.FLAG_IMMUTABLE)
جاوا
PendingIntent pendingIntent =
PendingIntent.getActivity(
getContext(),
/* requestCode= */ 0,
new Intent(intentAction),
PendingIntent.FLAG_IMMUTABLE);
در اندروید 11 (سطح API 30) و بالاتر، باید مشخص کنید که کدام فیلدها را تغییر دهید، که آسیبپذیریهای تصادفی از این نوع را کاهش میدهد.
منابع
ریسک: بازپخش اهداف معلق
یک PendingIntent میتواند دوباره پخش شود مگر اینکه پرچم FLAG_ONE_SHOT تنظیم شده باشد. استفاده از FLAG_ONE_SHOT برای جلوگیری از حملات مجدد (انجام اقداماتی که نباید تکرار شوند) مهم است.
تاثیر
تاثیر این آسیب پذیری بسته به اجرای انتهای دریافت کننده intent متفاوت است. یک برنامه مخرب که از یک PendingIntent که بدون تنظیم پرچم FLAG_ONE_SHOT ایجاد شده است سوء استفاده میکند، میتواند این قصد را برای تکرار اقداماتی که فقط یک بار میتوان انجام داد، ضبط کرده و دوباره استفاده کرد.
اقدامات کاهشی
اهداف معلق که قرار نیست چندین بار اجرا شوند باید از پرچم FLAG_ONE_SHOT استفاده کنند تا از حملات مجدد جلوگیری شود.
کاتلین
val pendingIntent =
PendingIntent.getActivity(
context,
/* requestCode = */ 0,
Intent(intentAction),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_ONE_SHOT)
جاوا
PendingIntent pendingIntent =
PendingIntent.getActivity(
getContext(),
/* requestCode= */ 0,
new Intent(intentAction),
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT);
منابع
منابع
{% کلمه به کلمه %}
{% آخر کلمه %} برای شما توصیه می شود
- توجه: وقتی جاوا اسکریپت خاموش است، متن پیوند نمایش داده می شود
- تغییر مسیر قصد
{% کلمه به کلمه %} {% آخر کلمه %}
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Pending intents\n\n\u003cbr /\u003e\n\n**OWASP category:** [MASVS-PLATFORM: Platform Interaction](https://mas.owasp.org/MASVS/09-MASVS-PLATFORM)\n\n\nOverview\n--------\n\nA [`PendingIntent`](/reference/android/app/PendingIntent) is a reference to a token maintained by the system. Application A can pass a PendingIntent to application B in order to allow application B to execute predefined actions on behalf of application A; regardless of whether application A is still alive.\n\nRisk: Mutable Pending Intents\n-----------------------------\n\nA PendingIntent can be mutable, which means that the inner intent that specifies the action can be updated by application B following the logic described in the [`fillIn()`](/reference/android/content/Intent#fillIn(android.content.Intent,%20int)) documentation. In other words, the unfilled fields of a PendingIntent can be modified by a malicious app and allow access to otherwise non-exported components of the vulnerable application.\n\n### Impact\n\nThe impact of this vulnerability varies depending on the implementation of the targeted unexported functionality of the app.\n\n### Mitigations\n\n#### General\n\nMake sure action, component, and package are set to avoid the worst vulnerabilities: \n\n### Kotlin\n\n val intent = Intent(intentAction)\n\n // Or other component setting APIs e.g. setComponent, setClass\n intent.setClassName(packageName, className)\n\n PendingIntent pendingIntent =\n PendingIntent.getActivity(\n context,\n /* requestCode = */ 0,\n intent, /* flags = */ PendingIntent.FLAG_IMMUTABLE\n )\n\n### Java\n\n Intent intent = new Intent(intentAction);\n\n // Or other component setting APIs e.g. setComponent, setClass\n intent.setClassName(packageName, className);\n\n PendingIntent pendingIntent =\n PendingIntent.getActivity(\n getContext(),\n /* requestCode= */ 0,\n intent, /* flags= */ 0);\n\n#### Flag IMMUTABLE\n\nIf your app targets Android 6 (API level 23) or higher, [specify mutability](/guide/components/intents-filters#DeclareMutabilityPendingIntent). For example, this can be done by using [`FLAG_IMMUTABLE`](/reference/android/app/PendingIntent#FLAG_IMMUTABLE) to prevent unfilled fields from being filled in by a malicious application: \n\n### Kotlin\n\n val pendingIntent =\n PendingIntent.getActivity(\n context,\n /* requestCode = */ 0,\n Intent(intentAction),\n PendingIntent.FLAG_IMMUTABLE)\n\n### Java\n\n PendingIntent pendingIntent =\n PendingIntent.getActivity(\n getContext(),\n /* requestCode= */ 0,\n new Intent(intentAction),\n PendingIntent.FLAG_IMMUTABLE);\n\nOn Android 11 (API level 30) and higher, you have to specify which fields to make mutable, which mitigates accidental vulnerabilities of this type.\n\n### Resources\n\n- [Remediation of PendingIntent vulnerability](https://support.google.com/faqs/answer/9267555)\n\n- [Blog post about the vulnerability](https://valsamaras.medium.com/pending-intents-a-pentesters-view-92f305960f03)\n\n*** ** * ** ***\n\nRisk: Replaying Pending Intents\n-------------------------------\n\nA PendingIntent can be replayed unless the [FLAG_ONE_SHOT](/reference/android/app/PendingIntent#FLAG_ONE_SHOT) flag is set. It is important to use FLAG_ONE_SHOT to avoid replay attacks (performing actions that should not be repeatable).\n\n### Impact\n\nThe impact of this vulnerability varies depending on the implementation of the receiving end of the intent. A malicious app exploiting a PendingIntent that was created without setting the FLAG_ONE_SHOT flag could capture and re-use the intent to repeat actions that should only be able to be done once.\n\n### Mitigations\n\nPending Intents not intended to be fired multiple times should use the [FLAG_ONE_SHOT](/reference/android/app/PendingIntent#FLAG_ONE_SHOT) flag to avoid replay attacks. \n\n### Kotlin\n\n val pendingIntent =\n PendingIntent.getActivity(\n context,\n /* requestCode = */ 0,\n Intent(intentAction),\n PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_ONE_SHOT)\n\n### Java\n\n PendingIntent pendingIntent =\n PendingIntent.getActivity(\n getContext(),\n /* requestCode= */ 0,\n new Intent(intentAction),\n PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT);\n\n### Resources\n\n- [PendingIntent.FLAG_ONE_SHOT](/reference/android/app/PendingIntent#FLAG_ONE_SHOT)\n\n*** ** * ** ***\n\nResources\n---------\n\n- [PendingIntent documentation](/reference/android/app/PendingIntent)\n\n- [PendingIntent and intent filters](/guide/components/intents-filters#PendingIntent)\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Intent redirection](/topic/security/risks/intent-redirection)"]]