Skip to content

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

Open
miaulalala wants to merge 1 commit into
masterfrom
fix/59225-profile-scope-api-bypass
Open

fix(accounts): enforce per-property scope restrictions via API#60348
miaulalala wants to merge 1 commit 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

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>
@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
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

1 participant