CVE-2026-58838 AI-generated analysis
platform/packages/providers/DownloadProvider, Helpers path restriction checks (isFileInExternalAndroidDirs, isFileInPrivateExternalAndroidDirs)
DownloadProvider's Helpers now NFD-normalizes a destination path and strips default-ignorable Unicode code points (such as zero-width spaces) before re-running the Android-directory regex restriction checks (PATTERN_ANDROID_DIRS, PATTERN_ANDROID_PRIVATE_DIRS), so invisible characters inserted into path segments no longer evade the checks.
Root cause
Helpers.isFileInExternalAndroidDirs matched PATTERN_ANDROID_DIRS against the raw filePath string, and Helpers.isFileInPrivateExternalAndroidDirs matched PATTERN_ANDROID_PRIVATE_DIRS against file.getCanonicalPath(). Neither one removed default-ignorable Unicode code points. A path such as "/storage/emulated/0/An\u200bdroid/data/..." or ".../Android/da\u200bta/..." does not match the literal regex, so the checks returned false. Per the commit's comment, the lower file system ignores these characters, so such a path can still refer to the restricted directory.
How the fix works
- src/com/android/providers/downloads/Helpers.java:normalizeAndFilterDefaultIgnorableCodepoints (new private static): returns null/empty input unchanged. Otherwise it applies java.text.Normalizer NFD and scans the code points with UCharacter.hasBinaryProperty(cp, UProperty.DEFAULT_IGNORABLE_CODE_POINT). If none are found it returns the NFD string; otherwise it rebuilds the string without the default-ignorable code points.
- src/com/android/providers/downloads/Helpers.java:isFileInExternalAndroidDirs: the result is now PATTERN_ANDROID_DIRS on the raw filePath OR PATTERN_ANDROID_DIRS on normalizeAndFilterDefaultIgnorableCodepoints(filePath).
- src/com/android/providers/downloads/Helpers.java:isFileInPrivateExternalAndroidDirs: computes canonicalPath = file.getCanonicalPath() once, then matches PATTERN_ANDROID_PRIVATE_DIRS on canonicalPath OR on the normalized and filtered canonicalPath. IOException handling is unchanged (it logs and returns false).
- tests/src/com/android/providers/downloads/HelpersTest.java: adds \u200b cases ('An\u200bdroid/data', 'Android/da\u200bta') to testIsFileInPrivateExternalAndroidDirs, and a new testIsFileInExternalAndroidDirs_zwspBypass covering 'An\u200bdroid/data', 'Android/da\u200bta' and 'Android/me\u200bdia'.
- New imports: android.icu.lang.UCharacter, android.icu.lang.UProperty, java.text.Normalizer.
Completeness
- Covers both regex-based Android-directory classifiers in Helpers (PATTERN_ANDROID_DIRS and PATTERN_ANDROID_PRIVATE_DIRS). It strips the whole DEFAULT_IGNORABLE_CODE_POINT class, not only U+200B.
- The check is OR'd with the original match, so it only adds matches; it never changes a previously true result to false.
- Only these two functions are modified. Other path checks in Helpers (for example isFilenameValidInKnownPublicDir, referenced in the test file) are not touched in the diff. The material does not show their code, so it cannot tell whether they are exposed to the same kind of input.
- Normalization is NFD only, and characters outside the DEFAULT_IGNORABLE_CODE_POINT property are not removed.
- The tests do not include an ignorable code point inside an obb segment.
Behavior changes
- Destination paths that match the Android-directory patterns only after default-ignorable code points are removed are now classified as inside those directories (previously the helpers returned false for them).
- Each call to these two helpers may now perform an NFD normalization and a code point scan. For paths without ignorable code points, the second regex match runs on the NFD form of the string.
- No new methods or error codes are added, and the helper signatures are unchanged.
Per major
- Android 14: same fix: commit 8c7db1173431 in android-security-14.0.0_r29 (RESTRICT AUTOMERGE, identical Helpers.java hunks at the same offsets, same test additions); 8/8 patched lines present at android-security-14.0.0_r31.
- Android 15: same fix: commit 58e8f2d880d0 in android-security-15.0.0_r17 (RESTRICT AUTOMERGE, cherry-picked from internal commit 3e69771bded3a82e5fd7a14c87fd4618d28255f7, Change-Id I247153c7015c1b4b229428cbcd091ff9ed263209); 8/8 patched lines present at android-security-15.0.0_r19.
- Android 16: same fix: commit a3ba6b22ea3d in android-security-16.0.0_r8; Helpers.java hunks identical, test hunks at different line offsets (646/668); 8/8 patched lines present at android-security-16.0.0_r10.
- Android 17: same fix: commit adbfd901579e in android-security-17.0.0_r1; identical logic with shifted line offsets (Helpers.java 579/691) and a Flags import in context; 8/8 patched lines present at android-security-17.0.0_r3.
Unknowns
- The material does not show the production call sites of the two helpers, which DownloadProvider entry points reach them, or how callers use the path after the check.
- The claim that the lower file system ignores these code points comes from the commit's code comment; the material does not show the file system behavior itself.
- The code of other path checks in Helpers (such as isFilenameValidInKnownPublicDir) is not shown, so whether they needed the same treatment is unknown.
- The definitions of PATTERN_ANDROID_DIRS and PATTERN_ANDROID_PRIVATE_DIRS are not shown in the material.