fix(drive): enforce the share ceiling on move(), not just share() - #590
Draft
ebrahimgamdiwala wants to merge 2 commits into
Draft
fix(drive): enforce the share ceiling on move(), not just share()#590ebrahimgamdiwala wants to merge 2 commits into
ebrahimgamdiwala wants to merge 2 commits into
Conversation
share() refuses to grant a level of access the granter doesn't hold themselves - a user with only read+write on a file can't turn around and grant someone else write. move() enforced no equivalent: it only checked `upload` on the destination and `write` on the file, so a user with write-only access could move that file into a folder they'd made public (or shared site-wide) and expose it to that whole audience - the exact escalation share() exists to block, reachable through a side door. Add File._exposes_more_broadly(), comparing the broad-audience access (anyone with the link, or every site user) the file already has against what the destination folder would grant. move() now requires `share` on the file whenever the destination would widen that audience - mirroring share()'s own ceiling, applied to the audience a folder move creates rather than an explicit grantee. Moves that don't widen the audience (the common case - reorganizing files you can already write to) are untouched. 5 regression tests; verified test_move_cannot_widen_audience_without_share_rights fails without the check. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ebrahimgamdiwala
marked this pull request as draft
August 11, 2026 08:03
Contributor
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "fix(drive): compare link and site audien..." | Re-trigger Greptile |
The move ceiling folded both broad audiences into one bit:
{t: bool(public.get(t) or general.get(t)) for t in PERMISSION_TYPES}
"Anyone with the link" and "every logged-in site user" are different
populations, so OR-ing them made a file already readable site-wide look
identical to one readable anonymously. A write-only collaborator could
move a site-wide-readable file into a link-public folder and the check
saw "broadly readable" on both sides, reported no widening, and let it
through - publishing an internal file to unauthenticated visitors.
The fold was doubly wrong: `generate_upward_path(entity, GENERAL_USER)`
resolves principals `["$GENERAL", ""]` (see `get_principals`), so the
`site` reading already covered the link audience and the `or` added
nothing. The link audience was never measured on its own.
Keep the two apart and compare each against its counterpart. `site` still
subsumes `link` for the reasons above, which is harmless now that `link`
is compared independently - widening onto the link audience is caught
there even though `site` can't distinguish it.
Reported by Greptile on frappe#590.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ebrahimgamdiwala
marked this pull request as ready for review
August 11, 2026 08:18
ebrahimgamdiwala
marked this pull request as draft
August 13, 2026 07:58
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.
share() refuses to grant a level of access the granter doesn't hold themselves - a user with only read+write on a file can't turn around and grant someone else write. move() enforced no equivalent: it only checked
uploadon the destination andwriteon the file, so a user with write-only access could move that file into a folder they'd made public (or shared site-wide) and expose it to that whole audience - the exact escalation share() exists to block, reachable through a side door.Add File._exposes_more_broadly(), comparing the broad-audience access (anyone with the link, or every site user) the file already has against what the destination folder would grant. move() now requires
shareon the file whenever the destination would widen that audience - mirroring share()'s own ceiling, applied to the audience a folder move creates rather than an explicit grantee. Moves that don't widen the audience (the common case - reorganizing files you can already write to) are untouched.5 regression tests; verified test_move_cannot_widen_audience_without_share_rights fails without the check.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.