Skip to content

Android task hijacking with taskAffinity, Automatically add android:taskAffinity in a new project  #63559

Closed

Description

@Wouter12

Use case

I discovered that Android task hijacking is allowed in a flutter application, any malicious app can put itself on the stack of the flutter application by adding taskAffinity="com.example.myFlutterApp" in the AndroidManifest.xml of the <activity> tag of the MainActivity

Steps to Reproduce

  1. create a new blank android project, in AndroidManifest.xml add
    android:excludeFromRecents="true" android:launchMode="singleTask" android:taskAffinity="{com.example.myFlutterApp}" in the <activity> tag from the MainActivity.
  2. open the com.example.myflutterapp application.
  3. run the android app
  4. close it and open the flutter application again

Expected results:

The flutter application

Actual results:

the android application

Proposal

Automatically add android:taskAffinity="" to the <application> tag in the AndroidManifest.xml of the flutter app

Activity

  1. added
    platform-androidAndroid applications specifically
    c: proposalA detailed proposal for a change to Flutter
    a: platform-viewsEmbedding Android/iOS views in Flutter apps
    on Aug 12, 2020
  2. added
    engineflutter/engine related. See also e: labels.
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    engineflutter/engine related. See also e: labels.
    on Sep 21, 2020
  3. changed the title [-]Android task hijacking with taskAffinity[/-] [+]Android task hijacking with taskAffinity, Automatically add android:taskAffinity in a new project [/+] on Sep 21, 2020
  4. anjalsaneen commented on May 17, 2021

    @anjalsaneen

    Anti-virus software can be detected as a malicious app if app id is not the same as task affinity.

  5. added
    c: new featureNothing broken; request for a new capability
    P3Issues that are less important to the Flutter project
    on Aug 2, 2022
  6. 18 remaining items

  7. assigned and unassigned on Feb 28, 2024
  8. reopened this on Feb 28, 2024
  9. Hixie commented on Feb 28, 2024

    @Hixie
    Contributor

    https://www.guardsquare.com/blog/protecting-against-strandhogg has some information that suggests there's more we can do.

  10. johnmccutchan commented on Feb 28, 2024

    @johnmccutchan
    Contributor
    1. The template addresses Strandhogg 1.0

    2. For devices running Android <= 28 it is impossible to protect against Strandhogg 2.0

    3. For devices running Android == 29 you need (1) to protect your app against Strandhogg 1.0 and 2.0

    4. For devices running Android >= 30 your app is protected from Strandhogg 1.0 and 2.0.

  11. mariamhas commented on Feb 28, 2024

    @mariamhas
    Contributor

    Are there versions of Android where it is fundamentally impossible to secure an application from hijacking in this way? Should we be saying something on our supported platforms page about this?

    I think its a good idea to point people to the doc that the Android folks are updating about having a minsdk set being the only way to mitigate this issue in our support platforms page.

    Android doc: https://developer.android.com/privacy-and-security/risks/strandhogg

  12. johnmccutchan commented on Feb 28, 2024

    @johnmccutchan
    Contributor

    Yes, the existing official documentation has a bug in it that suggests setting "targetSdkVersion" is sufficient but it needs to be "minSdkVersion".

    One way Flutter could protect its developers is to stop supporting Android < 29

  13. Hixie commented on Feb 28, 2024

    @Hixie
    Contributor

    I think it's sufficient to warn people of the problem (not all applications will care about being spoofed). (edit: I mean, as opposed to entirely dropping support for older versions.)

    It seems like we should detect apps that don't have the template's mitigation in place, and warn about the problem (is there any useful case where one would not put the mitigation in place? If so we'd need a way to silence the warning, e.g. leaving a comment in the file that says it's intentionally not set).

    We could consider what our default minimum should be, maybe with a comment in the file saying that we support down to a particular version but that certain versions have known vulnerabilities, pointing to the relevant documentation.

    I agree with @mariamhas that documenting this on our web site's "supported platforms" page is good regardless.

  14. Hixie commented on Apr 19, 2024

    @Hixie
    Contributor

    I'm going to close this issue in favor of the ones filed above.

  15. github-actions commented on May 3, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsplatform-androidAndroid applications specificallyteam-androidOwned by Android platform team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions