Skip to content

fix: block local remote shares on typos and contacts with a local Cloud ID - #64318

Draft
salmart-dev wants to merge 3 commits into
masterfrom
fix/block-local-remote-shares
Draft

salmart-dev wants to merge 3 commits into
masterfrom
fix/block-local-remote-shares

Conversation

@salmart-dev

@salmart-dev salmart-dev commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor
  • Resolves: #

Summary

This PR addresses two problems leading to confusing remote shares to local users, when the server is configured with allow_local_remote_servers set to yes.

  1. Any typo or difference in casing for emails typed in the external shares search box, would allow for remote shares if the server happens to have a user with the same cloud ID, except for the casing
  2. Saving someone as a contact with a local cloud ID filled in would allow a remote share with that contact, although the user matches a local one.

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Stops considering emails/cloudID with casing differences in the user or
domain part as different, to avoid a typo from resulting into a remote
share.

Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
This prevents users accidentally sharing via remote shares to local
users just because they saved them as contacts.

Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
@salmart-dev salmart-dev self-assigned this Sep 14, 2026
@salmart-dev salmart-dev changed the title Fix/block local remote shares fix: block local remote shares on typos and contacts with a local Cloud ID Sep 14, 2026
Comment on lines +184 to +201
return mb_strtolower($remoteCloudId->getUser()) === mb_strtolower($localCloudId->getUser())
&& $this->normalizeRemote($remoteCloudId->getRemote()) === $this->normalizeRemote($localCloudId->getRemote());
}

/**
* Normalize a remote for comparison: the protocol and trailing slashes are
* dropped, and the host is lowercased. The path is kept as-is, as it is
* case-sensitive (RFC 3986, section 6.2.2.1).
*/
private function normalizeRemote(string $remote): string {
$remote = rtrim(preg_replace('#^https?://#i', '', $remote), '/');
$pathPosition = strpos($remote, '/');
if ($pathPosition === false) {
return strtolower($remote);
}

return strtolower(substr($remote, 0, $pathPosition)) . substr($remote, $pathPosition);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should be moved into a new method in ICloudId, so it's reusable.

@susnux

susnux commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

account for foo@bar.local/cloud is NOT the same as foo@bar.local/clOud because paths are case sensitive in URLs

return false;
}

return mb_strtolower($remoteCloudId->getUser()) === mb_strtolower($localCloudId->getUser())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fix in this regard should respect the way that the user backend would actually do comparison for the user ID. According to the OCM specs, the identifier is case-sensitive, so lower-casing for comparison is only okay when the backend would do the same to identify the user. So lower-casing may be okay for checking if an inputted cloud ID may match a local user, but is not okay to compare if two remote users are the same user, as the decision about casing can only be done by the remote.

This branch has not been deployed

No deployments
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.

3 participants