مُرسِل الأهداف في انتظار المراجعة
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
فئة OWASP: MASVS-CODE: جودة الرمز
نظرة عامة
يؤدي استخدام PendingIntent.getCreator*()
أو PendingIntent.getTarget*()
لتحديد ما إذا كان سيتم الوثوق بمرسِل PendingIntent إلى إنشاء خطر استغلال.
تعرض الدالة PendingIntent.getCreator*()
أو
PendingIntent.getTarget*()
معلومات عن منشئ PendingIntent،
وهو ليس بالضرورة المرسِل. قد يكون صانع المحتوى موثوقًا به، ولكن لا يجب الوثوق بالمرسِل أبدًا، لأنّه قد يكون تطبيقًا ضارًا حصل على PendingIntent لتطبيق آخر باستخدام آليات متنوعة، مثل:
من الأمثلة على الاستخدام المشروع PendingIntent.getCreator*()
أو PendingIntent.getTarget*()
عرض رمز التطبيق الذي سيتم تشغيله بواسطة PendingIntent.
التأثير
قد يؤدي الوثوق بمُرسِل PendingIntent لأنّك طلبت معلومات من المنشئ (وتثق به) إلى حدوث ثغرات أمنية. إذا كان أحد التطبيقات يثق في مُرسِل PendingIntent استنادًا إلى منشئه، ثم يشارك منطق المصادقة أو التفويض، سيؤدي ذلك إلى تجاوز المصادقة أو حتى تنفيذ الرمز عن بُعد استنادًا إلى إدخال غير صالح وغير موثوق به، وذلك حسب تنفيذ رمز التطبيق المعرَّض للخطر، وذلك عندما يكون مُرسِل PendingIntent تطبيقًا ضارًا.
إجراءات التخفيف
التمييز بين المرسِل وصانع المحتوى
يجب ألا يستند أي نوع من منطق المصادقة أو التفويض الذي يتم تنفيذه عند تلقّي PendingIntent إلى افتراضات بشأن منشئ PendingIntent الذي يتم تحديده باستخدام PendingIntent.getCreator*()
أو PendingIntent.getTarget*()
.
استخدام طرق بديلة للتحقّق من هوية المتصلين
إذا كنت بحاجة إلى مصادقة المتصل، عليك استخدام خدمة أو ContentProvider بدلاً من PendingIntent، إذ يتيح كلاهما جلب معرّف المستخدم (UID) للمتصل باستخدام Binder.getCallingUid() عندما تكون في سياق إرسال عملية اتصال بين العمليات (IPC) واردة. يمكن طلب البحث عن المعرّف UID لاحقًا باستخدام
PackageManager.getPackagesForUid().
هناك طريقة أخرى متاحة من المستوى 34 لواجهة برمجة التطبيقات، وهي استخدام BroadcastReceiver.getSentFromUid() أو BroadcastReceiver.getSentFromPackage() إذا وافق المرسِل على مشاركة الهوية أثناء البث باستخدام BroadcastOptions.isShareIdentityEnabled().
عليك دائمًا التحقّق مما إذا كانت حزمة الاتصال تتضمّن التوقيع المتوقّع، لأنّ الحِزم التي يتم تحميلها من مصادر غير معروفة يمكن أن تتضمّن أسماء حِزم تتداخل مع تلك الموجودة في "متجر Play".
المراجع
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Sender of Pending Intents\n\n\u003cbr /\u003e\n\n**OWASP category:** [MASVS-CODE: Code Quality](https://mas.owasp.org/MASVS/10-MASVS-CODE)\n\nOverview\n--------\n\nUsing [`PendingIntent.getCreator*()`](/reference/android/app/PendingIntent#public-methods_1) or [`PendingIntent.getTarget*()`](/reference/android/app/PendingIntent#public-methods_1) to determine whether to trust a PendingIntent's sender creates an\nexploitation risk.\n\n[`PendingIntent.getCreator*()`](/reference/android/app/PendingIntent#public-methods_1) or\n[`PendingIntent.getTarget*()`](/reference/android/app/PendingIntent#public-methods_1) returns the PendingIntent's\ncreator, which does not always match its sender. The creator may be trusted, but\nthe sender should **never** be trusted, as the sender might be a malicious app\nthat acquired another app's PendingIntent using a variety of mechanisms, for\nexample:\n\n- from [`NotificationListenerService`](/reference/android/service/notification/NotificationListenerService)\n- legitimate use cases that are part of the vulnerable app.\n\nAn example of a legitimate use of [`PendingIntent.getCreator*()`](/reference/android/app/PendingIntent#public-methods_1) or [`PendingIntent.getTarget*()`](/reference/android/app/PendingIntent#public-methods_1) would be to show\nthe icon of the app that will be started by the PendingIntent.\n\nImpact\n------\n\nTrusting a PendingIntent's sender because you queried (and trust) the creator\ncan lead to vulnerabilities. If an app trusts the PendingIntent's sender based\non its creator, and then shares its authentication or authorization logic, then\nwhenever the PendingIntent's sender is a malicious app, this would lead to an\nauthentication bypass or potentially even remote code execution based on\ninvalidated, untrusted input, depending on the implementation of the vulnerable\napplication's code.\n\nMitigations\n-----------\n\n### Distinguish between sender and creator\n\nAny type of authentication or authorization logic performed when receiving a\nPendingIntent must not be based on assumptions regarding the PendingIntent's\ncreator identified using either [`PendingIntent.getCreator*()`](/reference/android/app/PendingIntent#public-methods_1)\nor [`PendingIntent.getTarget*()`](/reference/android/app/PendingIntent#public-methods_1).\n\n### Use alternative ways to validate callers\n\nIf you need to authenticate the caller, instead of using PendingIntent, you\nshould use a Service or ContentProvider -- both allow fetching the caller UID\nwith [Binder.getCallingUid()](/reference/android/os/Binder#getCallingUid()) when you are in the context of dispatching an\nincoming IPC. The UID can be queried later by using\n[PackageManager.getPackagesForUid()](/reference/android/content/pm/PackageManager#getPackagesForUid(int)).\n\nAnother approach, available from API level 34, would be to use\n[BroadcastReceiver.getSentFromUid()](/reference/android/content/BroadcastReceiver#getSentFromUid()) or\n[BroadcastReceiver.getSentFromPackage()](/reference/android/content/BroadcastReceiver#getSentFromPackage()) if the sender opted in to sharing\nidentity during broadcast using [BroadcastOptions.isShareIdentityEnabled()](/reference/android/app/BroadcastOptions#isShareIdentityEnabled()).\n\nYou should always check if the calling package has the expected signature, as\nsideloaded packages can have package names overlapping with ones from the Play\nStore.\n\nResources\n---------\n\n- [Pending Intent](/reference/android/app/PendingIntent)"]]