Skip to content

fix(android): keep cropped images and their Exif data off external storage - #227

Draft
retyui wants to merge 2 commits into
masterfrom
fix/android-crops-off-external-storage
Draft

retyui wants to merge 2 commits into
masterfrom
fix/android-crops-off-external-storage

Conversation

@retyui

@retyui retyui commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

H9: privacy leak. Crops now go to the internal cacheDir by default, and the 32 TAG_GPS_* entries are removed from the set of EXIF tags that get copied.

createTempFile picked whichever cache dir had more free space, which on most devices is external storage. A crop inherits the original's EXIF data, so GPS coordinates and the device serial ended up in a shared location. Any app with READ_EXTERNAL_STORAGE could read it on API ≤ 29, and it stayed there until the next launch. iOS drops EXIF when it re-encodes, so only Android had this problem.

External storage stays as the fallback when there is no internal cache dir. cleanTask already cleans both dirs. Tags that describe how the image was shot, including orientation, are still copied. (TAG_GPS_STATUS was listed twice. Both copies are gone.)

Follow-up not in this PR: the doc comment in src/index.ts still says a downloaded source image may be cached in external storage. That is still true, because it is Fresco's cache and not the crop file.

Behavior change

Crops used to land in externalCacheDir on most devices, and now land in the internal cacheDir. Host apps that pass the returned path to a FileProvider (sharing, uploading through another app) need a <cache-path> entry in their provider XML. With only <external-cache-path>, FileProvider.getUriForFile throws IllegalArgumentException: Failed to find configured root. The release notes should mention this.

Verification

Not compiled. No :android:compileDebugKotlin run and nothing run on a device. The Kotlin was checked for syntax errors only, and the external API signatures were checked against the published artifacts.

Split out of #221 (now closed), which bundled six Android fixes in ImageEditorModuleImpl.kt. Each one can be reviewed and merged separately.

…orage

`createTempFile` picked whichever cache dir had more free space, which in
practice means external storage on most devices. A crop inherits the
original's Exif data, so GPS coordinates and the device serial ended up in
a file in a shared location, readable by any app holding
`READ_EXTERNAL_STORAGE` on API <= 29, and left there until the next launch
cleaned it up. iOS discards Exif on re-encode, so this was Android-only.

Write crops to the internal cache dir, keeping external storage as the
fallback it already was when there is no internal one. `cleanTask` already
sweeps both dirs, so nothing is left behind.

Also stop copying the GPS tags: the crop is a new picture the user may
share on its own, and it should not carry where the original was taken.
The tags that describe how the image was shot, orientation included, are
still carried over. (`TAG_GPS_STATUS` was listed twice; both are gone.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant