Skip to content

fix(security): administrators decide where a mount connects - #3

Merged
elcreator merged 2 commits into
mainfrom
fix-mount-destinations
Nov 15, 2026
Merged

elcreator merged 2 commits into
mainfrom
fix-mount-destinations

Conversation

@elcreator

Copy link
Copy Markdown
Owner

Fixes three audit findings about where a mount may connect. Administrators decide where a mount connects.

H-003: local mount with an arbitrary root reads host files

The local folder and ZIP drivers read and write anywhere PHP can reach, outside the file manager's root. Only an administrator may now create, test or repoint them, and the driver picker hides them from everyone else. ZIP is included because a ZIP path on this server allows the same arbitrary read and write.

H-002: an arbitrary WebDAV base_uri enables authenticated SSRF

When a mount was not set up by an administrator, every configured destination must resolve to public addresses only, across all of its DNS records. A new Support\Destination does the check, and drivers declare their destinations through Driver::destinations(). Covered: WebDAV URLs, S3 endpoints including the virtual-hosted bucket.host, FTP/SFTP hosts and the computer gateway, since the same class of problem applies to all of them.

  • Pinning: the checked address is the one connected to: cURL RESOLVE for WebDAV and S3, the IP itself for FTP and SFTP. This closes DNS rebinding.
  • No redirects: WebDAV follows no redirect.
  • Administrators may still target internal hosts, for example a Nextcloud on the LAN.

M-004: SFTP connects without host-key pinning

SFTP now refuses to connect without a pinned host key. It accepts the OpenSSH SHA256:… form printed by ssh-keyscan HOST | ssh-keygen -lf -, and md5/hex forms. Several keys can be pinned, so a key can be rotated without downtime. This requires league/flysystem-sftp-v3 ^3.36, the first release that accepts these formats.

Enforcement

The rules are checked on save and test, with readable 403/422 answers, and again on every connection through Mount::trusted(). A mount is trusted when it comes from the site configuration, or when whoever last set its connection settings (options.configured_by, otherwise the owner, otherwise the creator) is an administrator now. A demoted administrator's mounts stop at the next run.

Breaking

  • SFTP mounts without a pinned key fail until a key is added.
  • Local and ZIP mounts created by non-administrators, and mounts that point a non-administrator at internal hosts, fail until an administrator re-saves them.

Tests

  • Unit: the full suite passes in Docker against a CMS built with this plugin (271 passed, 7 skipped). The new tests/Unit/DestinationsTest.php covers the three findings; its only skips are drivers whose optional packages are not installed (async-s3, ftp).
  • End to end: 19 checks pass in the demo stack against a real S3 mock and a live SFTP server. Among them: a manager is refused /, 127.0.0.1, 169.254.169.254, localhost, 2130706433 and the internal S3 endpoint, while the administrator's demo mounts keep working; SFTP refuses a missing or wrong key, and connects with the real key and with an old+new pair.
  • Translations: all locales are updated.

🤖 Generated with Claude Code

elcreator and others added 2 commits November 15, 2026 18:20
- Local folder and ZIP mounts read and write wherever PHP can, outside the
  file manager root. Only an administrator may create, test or repoint one;
  the driver picker hides them from everyone else (H-003).
- WebDAV URLs, S3 endpoints (and the virtual-hosted bucket name), FTP/SFTP
  hosts and the computer gateway must resolve to public addresses only, every
  record, unless an administrator configured the mount. The checked address
  is the one connected to (cURL RESOLVE / the IP itself) and WebDAV follows no
  redirect, so neither DNS rebinding nor a redirect reaches an internal
  service (H-002).
- SFTP refuses to connect without a pinned host key. OpenSSH SHA256 form, md5
  hex, and several keys for rotation are accepted; flysystem-sftp-v3 ^3.36
  for those formats (M-004).

Enforced on save/test with readable 403/422 answers, and again on every
connection through Mount::trusted(): config mounts, or whoever last set the
connection settings being an administrator now. Mounts a manager set up before
this change stop working until an administrator re-saves them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elcreator
elcreator merged commit cc28a43 into main Nov 15, 2026
7 checks passed
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