The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): shared file names can no longer write outside the Android cache (#26175)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 16:23 UTC
622bc06d8ad987df1e249ee62ec9613b4ed50448
2 files changed
+55
-7
patches/expo-sharing@58.0.19.patch
+52
-4
@@ -1,5 +1,5 @@
1
diff --git a/android/src/main/java/expo/modules/sharing/SharingRecords.kt b/android/src/main/java/expo/modules/sharing/SharingRecords.kt
2
-index 1113a0a..e89529a 100644
2
+index 1113a0adbb951081dea5214a711fe1dbb5a3e814..e89529a43258ae3bd6ec730c19453aed5e5efac4 100644
3
--- a/android/src/main/java/expo/modules/sharing/SharingRecords.kt
4
+++ b/android/src/main/java/expo/modules/sharing/SharingRecords.kt
5
@@ -51,7 +51,8 @@ enum class ContentType(val value: String) : Enumerable {
@@ -12,8 +12,56 @@ index 1113a0a..e89529a 100644
12
) : Record
13
14
@OptimizedRecord
15
+diff --git a/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt b/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt
16
+index 0a4c92e4b6459632933027827a86a4ec994ce72f..54ff2b5f44df740c9b971e409397e4a08a973717 100644
17
+--- a/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt
18
++++ b/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt
19
+@@ -9,6 +9,7 @@ import java.io.File
20
+ import java.io.FileOutputStream
21
+ import java.net.HttpURLConnection
22
+ import java.net.URL
23
++import java.util.UUID
24
+ import kotlin.text.indexOf
25
+ import kotlin.text.substring
26
+
27
+@@ -56,14 +57,20 @@ class ResolvingShareIntentDataParser {
28
+
29
+ private fun resolveUri(context: Context, uri: Uri, mimeType: String): ResolvedSharePayload {
30
+ val contentResolver = context.contentResolver
31
+- val fileName = getFileName(contentResolver, uri) ?: "unknown"
32
++ val fileName = safeFileName(getFileName(contentResolver, uri))
33
+ val fileSize = getFileSize(contentResolver, uri)
34
+ val specificMimeType = contentResolver.getType(uri) ?: mimeType
35
+ val type = ShareType.fromMimeType(specificMimeType)
36
+
37
+- // Copy to cache dir to ensure access
38
+- val file = File(context.cacheDir, fileName)
39
++ // The sending app controls the name, so copy into a fresh directory and refuse any
40
++ // destination that resolves outside cacheDir.
41
++ val cacheDir = context.cacheDir.canonicalFile
42
++ val file = File(File(cacheDir, "shared-${UUID.randomUUID()}"), fileName)
43
++ if (!file.canonicalPath.startsWith(cacheDir.path + File.separator)) {
44
++ throw SecurityException("Shared file name escapes the cache directory")
45
++ }
46
+ try {
47
++ file.parentFile?.mkdirs()
48
+ contentResolver.openInputStream(uri)?.use { input ->
49
+ FileOutputStream(file).use { output ->
50
+ input.copyTo(output)
51
+@@ -85,6 +92,11 @@ class ResolvingShareIntentDataParser {
52
+ }
53
+ }
54
+
55
++ private fun safeFileName(name: String?): String {
56
++ val baseName = name?.let { File(it).name }
57
++ return if (baseName.isNullOrBlank() || baseName == "." || baseName == "..") "unknown" else baseName
58
++ }
59
++
60
+ private fun getFileName(resolver: ContentResolver, uri: Uri): String? {
61
+ val cursor = resolver.query(uri, null, null, null, null)
62
+ val name = cursor?.use { cursor ->
63
diff --git a/android/src/main/java/expo/modules/sharing/dataParsers/SimpleShareIntentDataParser.kt b/android/src/main/java/expo/modules/sharing/dataParsers/SimpleShareIntentDataParser.kt
16
-index 3381c5f..481cdb4 100644
64
+index 3381c5fd207ebb4cd8e0301aac59d307939ff162..481cdb4bc64ea5ae49919071f686324f6d56d55c 100644
65
--- a/android/src/main/java/expo/modules/sharing/dataParsers/SimpleShareIntentDataParser.kt
66
+++ b/android/src/main/java/expo/modules/sharing/dataParsers/SimpleShareIntentDataParser.kt
67
@@ -3,6 +3,7 @@ package expo.modules.sharing
@@ -93,7 +141,7 @@ index 3381c5f..481cdb4 100644
141
}
142
}
143
diff --git a/build/Sharing.types.d.ts b/build/Sharing.types.d.ts
96
-index 74544e0..92bd2f5 100644
144
+index 74544e0728d5f845351693d8d90596abae42eaea..92bd2f53108ac717f1ef7292fe89aea05c676c5e 100644
145
--- a/build/Sharing.types.d.ts
146
+++ b/build/Sharing.types.d.ts
147
@@ -100,6 +100,11 @@ export type SharePayload = {
@@ -175,7 +223,7 @@ index 943c263c0cf58be595bfc9745c91827da81befec..3a99a1822beb25fea3835123b9a4ad7a
223
224
if (mainGroupUuid && sharedGroupUuid) {
225
diff --git a/src/Sharing.types.ts b/src/Sharing.types.ts
178
-index 18af320..3a52b70 100644
226
+index 18af320420e7c01a8ffbd7fa5347320409f905d8..3a52b70a20efbc588ad5ca974c38c951e5757c97 100644
227
--- a/src/Sharing.types.ts
228
+++ b/src/Sharing.types.ts
229
@@ -108,6 +108,12 @@ export type SharePayload = {
pnpm-lock.yaml
+3
-3
@@ -375,7 +375,7 @@ patchedDependencies:
375
expo-audio@58.0.9: 530af071088a809fe1a97ce2b2269c78335fbb5dcd3893d6937ff5c304c85a0a
376
expo-modules-core@58.0.22: f0b0fd100550ed76e5c25b4d13eb7c9ff62825f8f197c53edf7bf447c50c9fb7
377
expo-network@58.0.3: cd09b6d1744dde4efa081b5619ebcff38877d98f7502a51cab121629dece8237
378
- expo-sharing@58.0.19: 61a9741dc6166fdbb5baa2e489275a65dd21aa11d2c915f490a1b337a4468e76
378
+ expo-sharing@58.0.19: dcdc534eeb18eb9fb0919c0ff7da1f7a75076b5b38b57f231cad32bb17c9dda3
379
expo-video@58.0.11: e80ec3ef8c4af50a607beea1c0917e71ba679844efdb702b45d17a5f03cf466c
380
expo-widgets@58.0.20: 8bf49067f93742855e15f29559ac75c8b50230b47069060993c9ea01dac11171
381
mdast-util-math@3.0.0: afe6b2c89e1eaddfd3c90cf2723f12c9a17d513e65beff51653781486013251c
@@ -697,7 +697,7 @@ importers:
697
version: 58.0.4(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))
698
expo-sharing:
699
specifier: 58.0.19
700
- version: 58.0.19(patch_hash=61a9741dc6166fdbb5baa2e489275a65dd21aa11d2c915f490a1b337a4468e76)(@tsc-rs/typescript@0.8.0)(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1)
700
+ version: 58.0.19(patch_hash=dcdc534eeb18eb9fb0919c0ff7da1f7a75076b5b38b57f231cad32bb17c9dda3)(@tsc-rs/typescript@0.8.0)(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1)
701
expo-splash-screen:
702
specifier: ~58.0.10
703
version: 58.0.10(@tsc-rs/typescript@0.8.0)(expo@58.0.14)(supports-color@8.1.1)
@@ -18514,7 +18514,7 @@ snapshots:
18514
18515
expo-server@58.0.5: {}
18516
18517
- expo-sharing@58.0.19(patch_hash=61a9741dc6166fdbb5baa2e489275a65dd21aa11d2c915f490a1b337a4468e76)(@tsc-rs/typescript@0.8.0)(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1):
18517
+ expo-sharing@58.0.19(patch_hash=dcdc534eeb18eb9fb0919c0ff7da1f7a75076b5b38b57f231cad32bb17c9dda3)(@tsc-rs/typescript@0.8.0)(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1):
18518
dependencies:
18519
'@expo/config-plugins': 58.0.9(@tsc-rs/typescript@0.8.0)(supports-color@8.1.1)
18520
'@expo/config-types': 58.0.3