Skip to content

fix(sharing): reject custom tokens that match a username - #66472

Open
ELHart05 wants to merge 3 commits into
nextcloud:masterfrom
ELHart05:fix/share-token-username
Open

ELHart05 wants to merge 3 commits into
nextcloud:masterfrom
ELHart05:fix/share-token-username

Conversation

@ELHart05

@ELHart05 ELHart05 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

A custom share token equal to a username saved without an error, but the link then returned a 404. Two shares could also end up with the same token.

getShareByToken() deliberately treats a username as not found, and the duplicate check in updateShare() swallowed that result. updateShare() now refuses a new token that equals a username, and the sharing form shows the error. generateToken() had the same gap, so it skips usernames too.

The check only runs when the token changes, so an existing share stays editable if a user later takes that name.

The error reuses the existing "already exists" text, so it doesn't say a user exists. A refusal does still show the token is taken, so someone allowed to set custom tokens could use it to probe usernames. Happy to change the approach if you'd prefer something else.

Tested on a local instance through the API and the sharing form.

Checklist

AI (if applicable)

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

getShareByToken() treats these as not found, so the link never works and the duplicate check misses them. The check only runs when the token changes, so existing shares stay editable.

Signed-off-by: Okba Allaoua <o.allaoua@esi-sba.dz>
Assisted-by: ClaudeCode:claude-opus-5-5
@ELHart05
ELHart05 requested review from a team as code owners November 7, 2026 14:50
@ELHart05
ELHart05 requested review from GhassenKefi, leftybournes, pabzm and salmart-dev and removed request for a team November 7, 2026 14:50

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.

[Bug]: Custom share token can't equal any username, UI doesn't forbid it

1 participant