Beklemedeki Intent'lerin Göndereni
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
OWASP kategorisi: MASVS-CODE: Kod Kalitesi
Genel Bakış
Bir PendingIntent'in gönderenine güvenilip güvenilmeyeceğini belirlemek için PendingIntent.getCreator*()
veya PendingIntent.getTarget*()
kullanmak, kötüye kullanım riski oluşturur.
PendingIntent.getCreator*()
veya
PendingIntent.getTarget*()
, PendingIntent'in oluşturucusunu döndürür. Bu, her zaman göndereniyle eşleşmez. Oluşturucuya güvenilebilir ancak gönderene asla güvenilmemelidir. Çünkü gönderen, çeşitli mekanizmalar kullanarak başka bir uygulamanın PendingIntent'ini elde etmiş kötü amaçlı bir uygulama olabilir. Örneğin:
PendingIntent.getCreator*()
veya PendingIntent.getTarget*()
için meşru kullanım örneği, PendingIntent tarafından başlatılacak uygulamanın simgesini göstermektir.
Etki
Oluşturucuya sorgu gönderdiğiniz (ve güvendiğiniz) için PendingIntent'in gönderenine güvenmek güvenlik açıklarına yol açabilir. Bir uygulama, PendingIntent'in gönderenine oluşturucusuna göre güveniyorsa ve ardından kimlik doğrulama veya yetkilendirme mantığını paylaşıyorsa PendingIntent'in göndereni kötü amaçlı bir uygulama olduğunda, bu durum kimlik doğrulama atlamasına veya savunmasız uygulamanın kodunun uygulanmasına bağlı olarak geçersiz kılınmış, güvenilmeyen girişe dayalı olarak uzaktan kod yürütmeye yol açabilir.
Risk azaltma önlemleri
Gönderen ve içerik üretici arasındaki farkı açıklama
Bir PendingIntent alınırken gerçekleştirilen herhangi bir kimlik doğrulama veya yetkilendirme mantığı, PendingIntent'in PendingIntent.getCreator*()
veya PendingIntent.getTarget*()
kullanılarak tanımlanan oluşturucusuyla ilgili varsayımlara dayanmamalıdır.
Arayanları doğrulamak için alternatif yöntemler kullanma
Arayanı doğrulamanız gerekiyorsa PendingIntent yerine bir Service veya ContentProvider kullanmanız gerekir. Her ikisi de gelen bir IPC'yi gönderirken Binder.getCallingUid() ile arayanın UID'sini getirmenize olanak tanır. UID, daha sonra PackageManager.getPackagesForUid() kullanılarak sorgulanabilir.
API düzeyi 34'ten itibaren kullanılabilen başka bir yaklaşım da gönderenin BroadcastOptions.isShareIdentityEnabled() kullanarak yayın sırasında kimlik paylaşmayı etkinleştirmesi durumunda BroadcastReceiver.getSentFromUid() veya BroadcastReceiver.getSentFromPackage()'i kullanmaktır.
Yan yüklenen paketlerin, Play Store'daki paketlerle çakışan paket adları olabileceğinden, arayan paketin beklenen imzaya sahip olup olmadığını her zaman kontrol etmeniz gerekir.
Kaynaklar
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-27 UTC."],[],[],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)"]]