nextcloud / nextcloud/server

[Bug]: Sub-admin gets `Insufficient permissions to change groups` error when removing a user from a group by `PATCH`

Open
#61,013 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 34-feedback bug
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

A sub-admin of the two groups receives the following error when attempting to remove a user (who is member of the same two groups) from a group they administer by doing PATCH req same as web browser does:

Error:

groups: Insufficient permissions to change groups

Request:

curl -u naruto:naruto \
  -H "OCS-APIRequest: true" \
  -H "Content-Type: application/json" \
  -X PATCH \
  https://nextcloud.local/ocs/v2.php/cloud/users/hinata \
  -d '{"groups":["naruto"]}'  

Response:

{
    "ocs": {
        "meta": {
            "status": "failure",
            "statuscode": 422,
            "message": ""
        },
        "data": {
            "errors": {
                "groups": "Insufficient permissions to change groups"
            }
        }
    }
}

[!NOTE]
DELETE request works

Request:

curl -u naruto:naruto \
-H "OCS-APIRequest: true" \
 -X DELETE \ 
 https://nextcloud.local/ocs/v2.php/cloud/users/sakura/groups\?groupid\=naruto

Response:

<?xml version="1.0"?>
<ocs>
<meta>
<status>ok</status>
<statuscode>200</statuscode>
<message>OK</message>
</meta>
<data/>
</ocs>
Steps to reproduce
  1. Log in as admin.
  2. Create two groups (e.g. naruto and boruto).
  3. Create a user (e.g. naruto) and add the user (naruto) as both member and admin of the two groups.
  4. Log in as the created user (naruto).
  5. Create another user (e.g. hinata) and add them as a member of both groups.
  6. Attempt to remove hinata from either group.
Expected behavior

The group admin should be able to remove the user from the group.

Nextcloud Server version

34

Operating system

Debian/Ubuntu

PHP engine version

None

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the OCS users PATCH endpoint for group changes and compare its permission handling with the DELETE group-membership endpoint shown in the report. Reproduce the two-group sub-admin scenario and verify that PATCH removal succeeds without the insufficient-permissions error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, authorization, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.