Repository navigation
Bugfix/ftpserver harden control permission - #4758
Open
TranceLove wants to merge 6 commits into
Open
TranceLove wants to merge 6 commits into
TranceLove wants to merge 6 commits into
Conversation
Follow-up to the FileProvider root-path / pre-grant hardening. With root-path narrowed to storage/ and mnt/media_rw/, files elsewhere (eg. /data, root-only files) no longer get a provider URI, so opening, sharing, picking and installing them would throw. Changes: - Add FileUtils.getShareableUri(): returns the provider URI when the path is covered, otherwise copies the file into cache/open_with/<uuid>/ and returns the URI of the copy. Root-only files are read through SuFileInputStream and written by the app itself, so the copy carries the app's own SELinux label/ownership (no root cp/chmod). Copies older than 24 hours are purged. - Add getShareableUriAsync() (RxJava Maybe): copying runs on the IO scheduler, shows the "Copying" toast, result delivered on main thread. - Add ShareCopyException; copy failures show copy_error toast, files that cannot be shared at all keep showing no_app_found. - Use the async helper in openFile, openWith(File), shareFiles, installApk and MainFragment.returnIntentResults (picker). - fromContentUri() maps storage_root/ -> /storage/ and media_rw_root/ -> /mnt/media_rw/, keeping legacy URI fallback; the database viewer path extra now uses it. - Tests in FileUtilsTest for URI mapping, cache copy, name collisions, async scheduling/toast and root copy failure cleanup. Grants stay READ-only everywhere, so external editors cannot write back to the original file; this is intentional (strictest, per the report).
TranceLove
force-pushed
the
bugfix/ftpserver-harden-control-permission
branch
2 times, most recently
from
November 6, 2026 11:48
720fdfc to
844a1a9
Compare
Make CONTROL_FTP_SERVER signature-only and add CONTROL_FTP_SERVER_SIMPLE (dangerous) guarding a new FtpExternalControlReceiver that only starts or stops the server with saved settings and never forwards intent extras.
TranceLove
force-pushed
the
bugfix/ftpserver-harden-control-permission
branch
from
November 6, 2026 12:16
844a1a9 to
8c96a75
Compare
TranceLove
marked this pull request as ready for review
November 6, 2026 12:22
TranceLove
requested review from
EmmanuelMess,
VishalNehra and
VishnuSanal
and
a balanced review from Copilot
November 6, 2026 12:23
There was a problem hiding this comment.
🟡 Changes recommended
Worker-thread toasts crash file operations, while temporary-copy URIs prevent the internal editor from saving changes to original files.
5 open issues
What changed in this PR
This PR hardens Amaze’s file sharing and FTP server controls by narrowing exposed filesystem paths and separating trusted, parameterized FTP commands from third-party start/stop signals.
Changes:
- Restricts FileProvider roots and adds asynchronous cache-copy fallbacks for files outside them.
- Protects legacy FTP controls with a signature permission and adds permission-gated external actions that ignore extras.
- Removes blanket URI grants, adds regression tests, and raises CI inotify limits.
| File | Description |
|---|---|
app/src/test/java/com/amaze/filemanager/utils/UtilsTest.java |
Updates the expected storage URI. |
app/src/test/java/com/amaze/filemanager/filesystem/files/FileUtilsTest.kt |
Tests URI mapping, cache copies, failures, and read-only intent flags. |
app/src/test/java/com/amaze/filemanager/asynchronous/services/ftp/FtpExternalControlReceiverTest.kt |
Tests external actions, ignored extras, and manifest permissions. |
app/src/main/res/xml/provider_paths.xml |
Narrows filesystem exposure and adds the sharing cache root. |
app/src/main/res/values/strings.xml |
Describes the external FTP control permission. |
app/src/main/java/com/amaze/filemanager/utils/Utils.java |
Uses shareable URIs for local and root files. |
app/src/main/java/com/amaze/filemanager/ui/fragments/MainFragment.java |
Resolves picker result URIs in the background. |
app/src/main/java/com/amaze/filemanager/ui/dialogs/OpenFileDialogFragment.kt |
Removes blanket read/write grants to matching apps. |
app/src/main/java/com/amaze/filemanager/filesystem/files/FileUtils.java |
Adds cache-backed sharing, asynchronous preparation, and URI mapping. |
app/src/main/java/com/amaze/filemanager/asynchronous/services/ftp/FtpService.kt |
Defines external FTP action constants and reformats existing code. |
app/src/main/java/com/amaze/filemanager/asynchronous/services/ftp/FtpReceiver.kt |
Refactors legacy action handling and logging. |
app/src/main/java/com/amaze/filemanager/asynchronous/services/ftp/FtpExternalControlReceiver.kt |
Handles external start/stop signals without forwarding extras. |
app/src/main/AndroidManifest.xml |
Declares separate FTP permissions and registers the external receiver. |
.github/workflows/android-main.yml |
Raises inotify limits for unit tests. |
.github/workflows/android-feature.yml |
Raises inotify limits for unit tests. |
Review effort: Balanced
| } | ||
| return uris; | ||
| }) | ||
| .subscribeOn(Schedulers.io()) |
| --> | ||
| <root-path path="." name="storage_root" /> | ||
| </paths> No newline at end of file | ||
| <root-path path="storage/" name="storage_root" /> |
TranceLove
force-pushed
the
bugfix/ftpserver-harden-control-permission
branch
from
November 6, 2026 14:42
e42fe94 to
a7c5236
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Chooser and open-as flows still lose original file URIs, causing editor saves to modify cache copies instead of source files, while synchronous log copying can freeze the UI.
6 open issues
Open-as flow saves edits to the cache copy · New Chooser launches discard the original URI · New Dispatch unsupported-file toast to the main thread Sharing large logs copies them on the UI thread · New Preparing large log attachments blocks the UI thread · New Use the shareable-copy helper for log-file URIs
3 resolved since last review
Review effort: Balanced
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
- Preserved original URIs through Open As and chooser app launches - Moved About log sharing to asynchronous cache preparation - Added async email-intent construction and updated feedback/crash-report flows
TranceLove
force-pushed
the
bugfix/ftpserver-harden-control-permission
branch
from
December 1, 2026 10:43
5000baf to
fa121f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Hardening fixes
Actionscom.amaze.filemanager.action.EXTERNAL_START_FTPandcom.amaze.filemanager.action.EXTERNAL_STOP_FTPwhich takes no arguments - just start and stop signals.Courtesy of report by Zhang Jinshan 2831737873a@gmail.com thanks!
Automatic tests
Manual tests
Done
Device:
OS:
Build tasks success
Successfully running following tasks on local:
./gradlew assembledebug./gradlew spotlessCheckGenerative code
This PR used generative code tools (GenAI, LLMs, etc.)
Model: Claude Sonnet
Version: 5.5
Provider: Github Copilot