Skip to content

fix(accounts): enforce per-property scope restrictions via API - #60348

Open
miaulalala wants to merge 2 commits into
masterfrom
fix/59225-profile-scope-api-bypass
Open

fix(accounts): enforce per-property scope restrictions via API#60348
miaulalala wants to merge 2 commits into
masterfrom
fix/59225-profile-scope-api-bypass

Conversation

@miaulalala

Copy link
Copy Markdown
Contributor

Summary

Fixes #59225 — the PUT /ocs/v2.php/cloud/users/<uid> API accepted any valid scope value for any profile property, allowing users to bypass the visibility restrictions enforced by the frontend UI (e.g. setting websiteScope=v2-published on an instance where the admin has disabled lookup server upload).

  • Adds IAccountManager::UNPUBLISHED_PROPERTIES constant listing the profile fields that must never be federated or published (biography, birthdate, headline, organisation, role) — mirrors the frontend's UNPUBLISHED_READABLE_PROPERTIES
  • testPropertyScope now rejects SCOPE_FEDERATED/SCOPE_PUBLISHED for those properties
  • testPropertyScope now rejects SCOPE_PUBLISHED for all properties unless the admin has enabled lookup server upload (files_sharing.lookupServerUploadEnabled)

Test plan

  • NOCOVERAGE=1 ./autotest.sh sqlite tests/lib/Accounts/AccountManagerTest.php — all 63 tests pass including 3 new ones
  • Manually: PUT /ocs/v2.php/cloud/users/<uid> with biographyScope=v2-federated → expect HTTP 400 Invalid scope
  • Manually: PUT /ocs/v2.php/cloud/users/<uid> with websiteScope=v2-published on an instance with lookup server upload disabled → expect HTTP 400 Invalid scope
  • Manually: same request with lookup server upload enabled → expect success

🤖 Generated with Claude Code

@miaulalala
miaulalala requested a review from a team as a code owner May 13, 2026 12:31
@miaulalala
miaulalala requested review from ArtificialOwl, come-nc, leftybournes and salmart-dev and removed request for a team May 13, 2026 12:32
@miaulalala miaulalala self-assigned this May 13, 2026
@miaulalala miaulalala added bug 3. to review Waiting for reviews feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) 31-feedback 32-feedback 33-feedback AI assisted labels May 13, 2026
@miaulalala

Copy link
Copy Markdown
Contributor Author

/backport to stable33

@miaulalala

Copy link
Copy Markdown
Contributor Author

/backport to stable32

@miaulalala
miaulalala requested a review from Rello May 13, 2026 12:35
Comment thread lib/public/Accounts/IAccountManager.php Outdated
Comment thread lib/private/Accounts/AccountManager.php Outdated
Comment thread lib/public/Accounts/IAccountManager.php
@miaulalala
miaulalala requested a review from come-nc May 20, 2026 11:00

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is federation of account info always going through the lookup server 🤔

@miaulalala
miaulalala force-pushed the fix/59225-profile-scope-api-bypass branch from e9fcdde to b4dbff6 Compare May 26, 2026 17:08
@susnux susnux added this to the Nextcloud 35 milestone Jun 9, 2026
Adds `UNPUBLISHED_PROPERTIES` to `IAccountManager` for profile fields
that must never be federated or published to the global lookup server
(biography, birthdate, headline, organisation, role), matching the
frontend's `UNPUBLISHED_READABLE_PROPERTIES` constant.

Enforces two new constraints in `testPropertyScope`:
- `UNPUBLISHED_PROPERTIES` may not use `SCOPE_FEDERATED` or
  `SCOPE_PUBLISHED`, even when set via the API.
- `SCOPE_PUBLISHED` is rejected for all properties unless the admin
  has enabled lookup server upload (`files_sharing.lookupServerUploadEnabled`).

Previously the `PUT /ocs/v2.php/cloud/users/<uid>` endpoint accepted any
valid scope value regardless of these restrictions, allowing users to
bypass the visibility limits enforced by the frontend UI.

Fixes #59225

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tPropertyScope and fix @SInCE

- Remove the always-true $throwOnData parameter from testPropertyScope; the
  dead else-branches (setScope(LOCAL)) are dropped, all paths now throw directly
- Fix @SInCE annotation on UNPUBLISHED_PROPERTIES to 34.0.0

AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miaulalala
miaulalala force-pushed the fix/59225-profile-scope-api-bypass branch from b4dbff6 to ec8d8fe Compare June 24, 2026 11:31
@nextcloud-bot nextcloud-bot mentioned this pull request Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews 31-feedback 32-feedback 33-feedback AI assisted backport-request bug feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: User can overwrite profile visibility settings via API

3 participants