Repository navigation
fix(security): administrators decide where a mount connects - #3
Merged
Merged
Conversation
- 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>
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.
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_urienables authenticated SSRFWhen 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\Destinationdoes the check, and drivers declare their destinations throughDriver::destinations(). Covered: WebDAV URLs, S3 endpoints including the virtual-hostedbucket.host, FTP/SFTP hosts and the computer gateway, since the same class of problem applies to all of them.RESOLVEfor WebDAV and S3, the IP itself for FTP and SFTP. This closes DNS rebinding.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 byssh-keyscan HOST | ssh-keygen -lf -, and md5/hex forms. Several keys can be pinned, so a key can be rotated without downtime. This requiresleague/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
Tests
tests/Unit/DestinationsTest.phpcovers the three findings; its only skips are drivers whose optional packages are not installed (async-s3, ftp)./,127.0.0.1,169.254.169.254,localhost,2130706433and 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.🤖 Generated with Claude Code