---
title: Empty Task Affinity Defense | Guardsquare
description: In Android, taskAffinity is used to define the relationship between different activities and tasks. Learn about empty task affinity defense.
---

[![guardsquare-logo](https://insights.guardsquare.com/hs-fs/hubfs/Logos/logo-white.png?length=536&name=logo-white.png "guardsquare-logo") ](https://23593082.hs-sites.com/)

- pricing

[Request Pricing](https://www.guardsquare.com/request-pricing?hsCtaTracking=646b0379-d596-4b1a-8526-2ccbdbb0f81b%7Ce8809087-a83f-4476-8b22-34b9572013fd)

[Login](https://customers.guardsquare.com/login?utm_referrer=https%3A%2F%2Fwww.guardsquare.com%2F)

En

- [中文](https://www.guardsquare.com/zh-hans)
- [한국어](https://www.guardsquare.com/ko)
- [Português](https://www.guardsquare.com/pt-br)
- [Español](https://www.guardsquare.com/es)

# [Mobile Application]

# Security Research Center

 Table of contents

# Empty task affinity

|   | **Technique limitations** |
| --- | --- |
| **Technique** | Explicit empty task affinity |
| **Against** | [Task hijacking](https://23593082.hs-sites.com/knowledgebasetest/attacks/task-hijacking-attacks) |
| **Limitations** | Effective only against StrandHogg v1 |
| **Side effects** | Minor UX impact, for example, activities may not group as expected |
| **Recommendations** | Not recommended due to limited effectiveness. |

To use this countermeasure, [set `android:taskAffinity=""`](https://developer.android.com/guide/topics/manifest/activity-element#aff) for all exported activities.

In Android, `taskAffinity` is used to define the relationship between different activities and tasks (a stack of activities, "applications" from the user's perspective). By default, all activities in an app have the same affinity and belong to the same task, unless specified otherwise. Task hijacking attacks may exploit this feature by manipulating task affinity to trick the operating system into displaying a malicious activity in what appears to be the legitimate app's task.

When you set `android:taskAffinity=""` for all exported activities in your app, you ensure that these activities do not have a specific affinity towards any task. It prevents malicious activities from associating themselves with the app's task, reducing the risk of task hijacking.

## [Guardsquare](https://23593082.hs-sites.com/knowledgebasetest/author/guardsquare)

Connect with the author

** Table of contents **

![HubSpot CMS](https://cdn2.hubspot.net/hubfs/302335/hubspot-cms-logo-gray.svg "HubSpot CMS")

[General Terms](https://23593082.hs-sites.com/terms-of-use) | [Privacy Policy](https://23593082.hs-sites.com/privacy-policy) | [Cookie Policy](https://23593082.hs-sites.com/cookie-policy)

Tervuursevest 362 bus 1, 3000 Leuven, Belgium | VAT: BE0550675829 |

© 2016-2026 Guardsquare nv. All rights reserved.

<https://www.facebook.com/guardsquare> <https://twitter.com/Guardsquare> <https://www.linkedin.com/company/guardsquare/> <https://www.youtube.com/channel/UCP9s5F1ksT1E-7vSF2CDyhw> <https://github.com/Guardsquare>

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Guardsquare",
    "url" : "https://23593082.hs-sites.com/knowledgebasetest/author/guardsquare"
  },
  "dateModified" : "2024-02-28T02:09:25.558Z",
  "datePublished" : "2024-02-15T20:05:44.000Z",
  "headline" : "Empty Task Affinity Defense | Guardsquare",
  "mainEntityOfPage" : {
    "@id" : "https://23593082.hs-sites.com/knowledgebasetest/defense/task-hijacking-empty-affinity",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject"
    }
  }
}
```