Summary
A path traversal flaw in react-native-receive-sharing-intent allows crafted file names from a malicious ContentProvider to escape the intended cache directory.
A co-resident Android app can exploit this by sending a specially crafted ACTION_SEND intent, enabling it to overwrite arbitrary files in the target app's private storage with attacker-controlled data.
Affected context
This vulnerability arises in Android applications that integrate the react-native-receive-sharing-intent library and expose a share-receiver activity to handle ACTION_SEND intents.
The issue becomes relevant when the library trusts the _display_name field supplied by an external ContentProvider and uses it directly to construct file paths under a cache directory.
On devices where a malicious app is installed, that app can co-reside and interact with the vulnerable app's exported share-receiver to influence where incoming shared files are written.
Exploit preconditions
- Attack surface: Local inter-app communication via Android intents and ContentProviders.
- Required access: Installation of a malicious app on the same device capable of issuing explicit ACTION_SEND intents to the vulnerable app's exported activity.
- Trigger point: The vulnerable app processes a shared file whose
_display_namecontains..segments, causing the library to construct a path that escapes the cache directory. - Why exploitation is possible: The library fails to sanitize or canonicalize the
_display_namebefore using it in filesystem operations, allowing directory traversal and writes outside the intended cache path.
Why this happens
The core defect maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory (Path Traversal).
The library constructs file system paths by concatenating a base cache directory with a user-controlled _display_name value without normalizing or validating it.
Because no check is performed to ensure the final resolved path remains within the intended directory, an attacker can insert ../ components to traverse directories and target arbitrary files under the application's private storage.
Potential impact
- Overwriting application databases with attacker-controlled content, potentially corrupting or manipulating stored data.
- Modifying shared preferences to alter feature flags, authentication state, or configuration values.
- Replacing cached configuration or temporary files to influence application behavior.
- Causing application crashes or denial of service by corrupting critical internal files.
- Creating conditions that may assist in further logic or security bypasses within the app.
General mitigation guidance
Mitigation generally focuses on strictly constraining file paths derived from external input and treating all inter-app data as untrusted.
Common defensive patterns include:
- Normalizing and canonicalizing filenames, rejecting any that contain
.., path separators, or other traversal indicators. - Generating server-side or application-side filenames (e.g., random UUIDs) instead of trusting
_display_nameor other external metadata. - Ensuring that after path resolution, the resulting path is verified to reside strictly under the intended cache or storage directory before performing write operations.
- Minimizing exposure of exported activities and requiring appropriate permissions or intent filters where possible, thereby reducing unintended inter-app access.
- Applying least-privilege principles to file operations, limiting what locations the app writes to based on clear, pre-defined rules instead of dynamic input.
How teams detect issues like this
Detection efforts can focus on both code-level review and behavioral testing:
- Static analysis rules that flag direct concatenation of filesystem paths with data sourced from intents, ContentProviders, or other IPC channels.
- Code review checklists that require verification of path canonicalization and directory-bound checks wherever external filenames or paths are consumed.
- Automated tests that send crafted ACTION_SEND intents with
_display_namecontaining../sequences to observe whether the app writes outside the expected directory. - Security-focused linting or mobile app security scanners configured to detect path traversal patterns and unvalidated use of external metadata in file operations.

