Repository navigation
fix(storage): let callers refuse endpoint overrides in a tenant's DSN - #266
Merged
Merged
Conversation
The url and insecure parameters replace the host a DSN names. An operator sets them on purpose, but a DSN holding tenant values could carry them through a spliced bucket and send every request to an address the tenant chose (appwrite-labs/cloud#6857). getDevice(trusted: false) refuses them, and the local device, so the host the caller checked is the one reached.
TorstenDittmann
approved these changes
Oct 28, 2026
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.
The
urlandinsecureDSN parameters replace the host a DSN names. Operators set them deliberately: Appwrite's self-hosted docs and CI uses3://…@localhost?…&url=http%3A%2F%2Fminio%3A9000, and so does this README. A DSN built from a tenant's values can carry them too: withs3://AK:SK@{endpoint}/{bucket}spliced together, a bucket ofb?url=http://169.254.169.254/latest&insecure=trueredirects every request to the metadata service.Change
getDevice()takesbool $trusted = true. Withtrusted: false:urlorinsecureparameter is refused, so the host the caller checked is the host reached;file://orlocal://connection is refused instead of resolving to the local filesystem.The default is unchanged, so existing callers and operator DSNs behave as before. Callers pass
trusted: falsefor stores a tenant configures.Related: appwrite/appwrite#15066 adds
DSN::from(), which encodes each part, so spliced values can't add parameters in the first place. This PR is the backstop for DSNs already stored as strings.Tests
StorageFactoryTest:url,insecure, aurlspliced in through the bucket, a local or file scheme, an empty string or null are refused;Pint, PHPStan and Rector pass on the changed files.