[Bug]: Sub-admin gets `Insufficient permissions to change groups` error when removing a user from a group by `PATCH`
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
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 worksRequest:
curl -u naruto:naruto \ -H "OCS-APIRequest: true" \ -X DELETE \ https://nextcloud.local/ocs/v2.php/cloud/users/sakura/groups\?groupid\=narutoResponse:
<?xml version="1.0"?> <ocs> <meta> <status>ok</status> <statuscode>200</statuscode> <message>OK</message> </meta> <data/> </ocs>
Steps to reproduce
- Log in as
admin. - Create two groups (e.g.
narutoandboruto). - Create a user (e.g.
naruto) and add the user (naruto) as both member and admin of the two groups. - Log in as the created user (
naruto). - Create another user (e.g.
hinata) and add them as a member of both groups. - Attempt to remove
hinatafrom 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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