Skip to content

Bugfix/ftpserver harden control permission - #4758

Draft
TranceLove wants to merge 2 commits into
hotfix/3.11.4from
bugfix/ftpserver-harden-control-permission
Draft

TranceLove wants to merge 2 commits into
hotfix/3.11.4from
bugfix/ftpserver-harden-control-permission

Conversation

@TranceLove

@TranceLove TranceLove commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Hardening fixes

  • Shareable content URIs, for filesystem level access. Those beyond userland filesystem boundaries will be copied to app's cache, then emits shareable content URIs for external apps.
  • FTP server start/stop hardened to allow only apps signed by Amaze to control via Intents with parameters. For external app integrations, there are still new Actions com.amaze.filemanager.action.EXTERNAL_START_FTP and com.amaze.filemanager.action.EXTERNAL_STOP_FTP which takes no arguments - just start and stop signals.

Courtesy of report by Zhang Jinshan 2831737873a@gmail.com thanks!

Automatic tests

  • Added unit tests for specific individual functions
  • Added headless tests for new app functionality

Manual tests

  • Done

  • Device:

  • OS:

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

Generative code

  • This PR used generative code tools (GenAI, LLMs, etc.)

  • Model: Claude Sonnet

  • Version: 5.5

  • Provider: Github Copilot

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).
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.
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