Remitente de intents pendientes
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Categoría de OWASP: MASVS-CODE: Calidad de código
Descripción general
Usar PendingIntent.getCreator*()
o PendingIntent.getTarget*()
para determinar si se debe confiar en el remitente de un PendingIntent crea un riesgo de explotación.
PendingIntent.getCreator*()
o PendingIntent.getTarget*()
devuelven el creador del PendingIntent, que no siempre coincide con su remitente. Se puede confiar en el creador, pero nunca se debe confiar en el remitente, ya que podría ser una app maliciosa que adquirió el PendingIntent de otra app con diversos mecanismos, por ejemplo:
Un ejemplo de uso legítimo de PendingIntent.getCreator*()
o PendingIntent.getTarget*()
sería mostrar el ícono de la app que iniciará el PendingIntent.
Impacto
Confiar en el remitente de un PendingIntent porque consultaste (y confías en) el creador puede generar vulnerabilidades. Si una app confía en el remitente del PendingIntent según su creador y, luego, comparte su lógica de autenticación o autorización, cada vez que el remitente del PendingIntent sea una app maliciosa, esto generará una omisión de la autenticación o, incluso, una posible ejecución de código remoto basada en una entrada no válida y no confiable, según la implementación del código de la aplicación vulnerable.
Mitigaciones
Distingue entre el remitente y el creador
Cualquier tipo de lógica de autenticación o autorización que se realice cuando se recibe un PendingIntent no debe basarse en suposiciones sobre el creador del PendingIntent identificado con PendingIntent.getCreator*()
o PendingIntent.getTarget*()
.
Usa formas alternativas de validar a los llamadores
Si necesitas autenticar al llamador, en lugar de usar PendingIntent, debes usar un Service o ContentProvider. Ambos permiten recuperar el UID del llamador con Binder.getCallingUid() cuando estás en el contexto de enviar un IPC entrante. El UID se puede consultar más adelante con PackageManager.getPackagesForUid().
Otro enfoque, disponible desde el nivel de API 34, sería usar BroadcastReceiver.getSentFromUid() o BroadcastReceiver.getSentFromPackage() si el emisor habilitó el uso compartido de la identidad durante la transmisión con BroadcastOptions.isShareIdentityEnabled().
Siempre debes verificar si el paquete de llamada tiene la firma esperada, ya que los paquetes transferidos de forma local pueden tener nombres de paquete que se superponen con los de Play Store.
Recursos
El contenido y las muestras de código que aparecen en esta página están sujetas a las licencias que se describen en la Licencia de Contenido. Java y OpenJDK son marcas registradas de Oracle o sus afiliados.
Última actualización: 2025-07-27 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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)"]]