Skip to content

[Android] Deprecate and remove loading deferred component .so files from app-writable internal storage (getFilesDir) #191139

Open

Description

@gmackall

Description

In PlayStoreDeferredComponentManager, searchPaths includes the app's internal files directory (context.getFilesDir()) as a search path for deferred component shared libraries (.so files):

https://github.com/flutter/flutter/blob/master/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java#L430-L431

While PR #189145 ensures that OS-installed signed split APKs are strictly prioritized ahead of getFilesDir(), loading standalone .so files from app-writable storage is still supported as a fallback.

We should investigate whether this fallback is still necessary and work towards deprecating and removing it entirely.


Motivation & Security Concerns

  1. Security / Code Tampering Risk:
    Loading native code from app-writable internal storage (getFilesDir()) poses a security risk if an attacker or another vulnerability manages to write to internal storage. Signed split APKs installed by the OS package manager provide signature and integrity guarantees that standalone files in writable storage do not.

  2. Android Platform Restrictions on Dynamic Code Execution:

    • Target API 29+ (Android 10+): SELinux policies enforce W^X (Write XOR Execute) restrictions, disallowing execmod / code execution from writable app data directories for 64-bit apps.
    • Target API 34+ (Android 14+): Dynamically loaded files must be marked strictly read-only, further restricting dynamic code loading from writable storage.
  3. Historical Context:
    Searching getFilesDir() was originally added when deferred components were built (~2020) to support fallback mechanisms, manual testing, or custom deferred component downloaders that unpacked .so files directly into internal storage rather than going through Play Feature Delivery. In standard Play Store workflows, deferred libraries are delivered and mounted via split APKs (splitSourceDirs).


Proposed Next Steps

  1. Audit whether any standard Flutter workflows or supported plugins still rely on getFilesDir() for deferred component loading, and audit why it was originally included.
  2. If legacy/custom downloaders need a migration path, document guidance on delivering native libraries via signed split APKs or read-only storage.
  3. Deprecate and remove getFilesDir() traversal in PlayStoreDeferredComponentManager.java (and remove the corresponding native fallback paths).

References

Activity

  1. added
    platform-androidAndroid applications specifically
    engineflutter/engine related. See also e: labels.
    c: proposalA detailed proposal for a change to Flutter
    team-androidOwned by Android platform team
    on Aug 15, 2026
  2. mbcorona commented on Aug 15, 2026

    @mbcorona
    Member

    Thanks for the report @gmackall , routing as proposal to the android team.

  3. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions