Skip to content

fix(drive): enforce the share ceiling on move(), not just share() - #590

Draft
ebrahimgamdiwala wants to merge 2 commits into
frappe:developfrom
ebrahimgamdiwala:fix/drive-move-audience-ceiling
Draft

fix(drive): enforce the share ceiling on move(), not just share()#590
ebrahimgamdiwala wants to merge 2 commits into
frappe:developfrom
ebrahimgamdiwala:fix/drive-move-audience-ceiling

Conversation

@ebrahimgamdiwala

@ebrahimgamdiwala ebrahimgamdiwala commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

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.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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
ebrahimgamdiwala marked this pull request as draft August 11, 2026 08:03
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "fix(drive): compare link and site audien..." | Re-trigger Greptile

Comment thread suite/drive/overrides/file.py Outdated
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
ebrahimgamdiwala marked this pull request as ready for review August 11, 2026 08:18
@ebrahimgamdiwala
ebrahimgamdiwala marked this pull request as draft August 13, 2026 07:58
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.

1 participant