Skip to content

Cannot view or delete groups with a slash in their name using provisioning API #31015

Open

Description

@phil-davis

You can create groups with all sorts of names in the webUI or with the provisioning API like:

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups -X POST -d "groupid=q?mark"
curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups -X POST -d "groupid=a%sign"
curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups -X POST -d "groupid=a/slash"

and other special characters.

You can list all groups fine with:

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups

And view individual groups with:

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups/a%sign

and to get a "?" through, you have to put the escaped value "%3F"

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups/q%3Fmark

You can delete such groups with:

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups/a%sign -X DELETE
curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups/q%3Fmark -X DELETE

The problem comes if you try with groups that have a / in their name. A literal slash is never going to work:

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups/a/slash

And an escaped slash, like this, is rejected by the server (Apache or PHP dev server):

curl http://admin:admin@localhost:8080/ocs/v2.php/cloud/groups/a%2Fslash

So you cannot manage a group like a/slash via the provisioning API. But you can manage it through webUI.

Activity

  1. added this to the development milestone on Apr 5, 2018
  2. self-assigned this
    on Apr 5, 2018
  3. phil-davis commented on Apr 5, 2018

    @phil-davis
    ContributorAuthor

    This was noticed while merging code for webUI and API acceptance tests. The webUI tests have a scenario that creates a group called a/slash - the API acceptance test steps could not delete the group.

  4. ownclouders commented on Apr 5, 2018

    @ownclouders
    Contributor

    GitMate.io thinks possibly related issues are #25465 (Сan not delete a group with a slash in the group name), #29990 (cannot add user to group called "0" by using provisioning API), #21249 (Deleting user with provisioning API can take a long time), #29698 (a group called "0" cannot be created by provisioning API), and #6435 (Cannot delete group).

  5. modified the milestones: development, on Apr 10, 2018
  6. modified the milestones: development, triage on Apr 24, 2018
  7. phil-davis commented on May 31, 2021

    @phil-davis
    ContributorAuthor

    There are acceptance tests tagged @issue-31015 @skipOnOcV10 that do stuff with group names that contain a /
    The expected behavior and current actual behavior is covered by tests.
    If someone thinks of a way to fix this, then remove the tags and adjust the code to make the tests pass...

    Removing my assignment, because the tests are there.

  8. removed their assignment
    on May 31, 2021
  9. stale commented on Sep 20, 2021

    @stale

    This issue has been automatically closed.

  10. phil-davis commented on Sep 20, 2021

    @phil-davis
    ContributorAuthor

    This is still a problem. "someone" needs to decide if groups are allowed to have a slash in their name. Then either we fix this somehow, or we prevent groups from having a slash in their name.

  11. DeepDiver1975 commented on Jun 19, 2026

    @DeepDiver1975
    Contributor

    🤖 Automated issue analysis by Claude Code review agent.

    Classification: confirmed-bug (still present in current master)

    Summary

    Groups whose name contains a forward slash (/) cannot be viewed, deleted, or otherwise managed through the OCS Provisioning API, even though they can be created and managed via the webUI. This was reported in 2018, re-confirmed by the reporter in 2021, and the behavior is still present in the current codebase.

    Evidence that it is still unfixed

    1. The single-group routes use the group id as a URL path segment, so a literal / in the name is interpreted as a path separator and an encoded %2F is rejected by the web server before reaching the app:

      • apps/provisioning_api/appinfo/routes.php registers:
        • GET /cloud/groups/{groupid} → Groups::getGroup
        • DELETE /cloud/groups/{groupid} → Groups::deleteGroup
        • GET /cloud/groups/{groupid}/subadmins → Groups::getSubAdminsOfGroup
      • The {groupid} placeholder matches a single path segment, so a/slash splits across segments and never reaches the handler intact.
    2. The application layer does nothing special with slashes — apps/provisioning_api/lib/Groups.php just reads $parameters['groupid'] directly (e.g. in getGroup() and deleteGroup()). The bug is therefore at the routing / web-server layer, not in the controller logic. Create (POST /cloud/groups with groupid in the body via addGroup()) works precisely because the name travels in the request body, not the URL path.

    3. No web-server-level mitigation is present — there is no AllowEncodedSlashes directive anywhere in the repo (searched repo-wide), so encoded %2F is rejected by Apache/PHP-FPM defaults (HTTP 404/400) before the OCS router runs. This matches the original report ("an escaped slash ... is rejected by the server").

    4. Acceptance tests still document the broken behavior as of current master — they remain tagged @issue-31015 and assert the failing state, with comments saying to flip the assertions only "after fixing issue-31015":

      • tests/acceptance/features/apiProvisioningGroups-v1/deleteGroupOc10Issue31015.feature
      • tests/acceptance/features/apiProvisioningGroups-v2/deleteGroupOc10Issue31015.feature
      • tests/acceptance/features/apiProvisioningGroups-v{1,2}/addGroupOc10Issue31015.feature
      • tests/acceptance/features/apiProvisioningGroups-v{1,2}/removeFromGroupOc10Issue31015.feature
      • tests/acceptance/features/apiProvisioningGroups-v{1,2}/getUserGroupsOc10Issue31015.feature
      • plus @issue-31015 @skipOnOcV10 scenarios scattered in addGroup.feature, deleteGroup.feature, addToGroup.feature, removeFromGroup.feature, getUserGroups.feature.
      • Several comments explicitly read: "After fixing issue-31015, change the following step to 'has been created'/'should exist'", confirming the maintainers consider it open and unfixed.

    Proposed fix

    This is a genuine design tension: the group id is part of the URL path, but group ids are allowed to contain /. There are two viable directions; option B is the lower-risk, recommended one and matches the reporter's 2021 comment ("either we fix this somehow, or we prevent groups from having a slash in their name").

    Option A — Make slashes work in the path (larger, web-server-dependent)

    • Root cause: {groupid} matches one path segment, and encoded %2F is blocked at the web-server tier.
    • Would require: configuring AllowEncodedSlashes NoDecode (Apache) plus nginx/PHP-FPM equivalents, and decoding/normalizing the segment in the OCS routing layer. This is fragile across deployments and changes documented HTTP behavior, so it is not recommended as the primary fix.

    Option B — Forbid / in group names at creation time (recommended)

    • Root cause to address: invalid input is accepted, producing groups that are unmanageable via the API.
    • Exact location: apps/provisioning_api/lib/Groups.php, method addGroup(). It currently validates only for empty names and leading/trailing whitespace:
      if (\trim($groupId) !== $groupId) {
          return new \OC\OCS\Result(null, 101, 'Invalid group name');
      }
      Add a check rejecting / (and, for consistency with the /subadmins collision noted in addGroup.feature, validate the name does not break route matching):
      if (\strpos($groupId, '/') !== false) {
          \OCP\Util::writeLog('provisioning_api', 'Group name must not contain a forward slash', \OCP\Util::ERROR);
          return new \OC\OCS\Result(null, 101, 'Invalid group name');
      }
    • For true consistency the same restriction should also be enforced at the group-manager / webUI level (the webUI currently allows slash names), otherwise an API-created restriction can still be bypassed by the UI. Relevant entry point: \OC\Group\Manager::createGroup (lib/private/Group/Manager.php) — adding validation there centralizes the rule for both UI and API.
    • Test approach: the acceptance tests already exist and are pre-wired for this. Update the *Oc10Issue31015.feature files and the @issue-31015 @skipOnOcV10 scenarios so that creating a group named e.g. a/slash or Mgmt/Sydney is now rejected (expect the 101 "Invalid group name" response) rather than silently created-then-unmanageable, remove the @issue-31015/@skipOnOcV10 skip tags, and flip the "should not exist"/"change to has been created" comments accordingly. Add/adjust a unit test for Groups::addGroup() asserting a slash-containing name returns failure code 101.

    Caveat

    This repository is in maintenance mode and the issue was auto-closed by the stale bot in 2021 then re-opened/re-confirmed by a maintainer. A fix is still technically valid, but Option B is a behavior change (rejecting previously-accepted names) and needs a product decision, which is exactly what the reporter requested in the last comment.


    Read-only automated analysis. No repository changes were made.

  12. phil-davis commented on Jun 19, 2026

    @phil-davis
    ContributorAuthor

    Correct analysis. It should be easy to prevent creation of group names containing a slash in the first place.

    In an LDAP environment with group names coming from an LDAP backend, we won't have control over the names. But in that case we don't delete them anyway. The "/" will still cause problems for the API trying to access an endpoint like ocs/v2.php/cloud/groups/a/slash but I don't see what can realistically be done about that. Just document that group names containing a slash should not be used.

  13. DeepDiver1975 commented on Jun 19, 2026

    @DeepDiver1975
    Contributor

    Option B

  14. phil-davis commented on Jun 19, 2026

    @phil-davis
    ContributorAuthor

    Note: there is also an issue #34086 about problems with groups that have a vertical bar in their name "|".
    Who does that in real life?!

    While we are implementing a ban on / then maybe consider other special characters like | and ban those.

  15. dj4oC commented on Jul 9, 2026

    @dj4oC
    Contributor

    Implementation prompt

    Problem: Groups whose name contains a forward slash (e.g. a/slash) can be created via the web UI but cannot be viewed, deleted, or managed through the OCS Provisioning API, because the single-group routes (apps/provisioning_api/appinfo/routes.php) use {groupid} as a URL path segment — a literal or encoded / in the name breaks routing before it reaches the controller. Maintainers have settled on Option B in-thread (@DeepDiver1975, @phil-davis): reject / in group names at creation time rather than attempting to make slashes work in the URL path (which would require fragile, deployment-dependent web-server configuration).

    Acceptance criteria:

    • Creating a group whose name contains a forward slash via the Provisioning API (addGroup()) is rejected with the existing "Invalid group name" response (OCS code 101), not silently accepted.
    • The same restriction is enforced centrally (e.g. at the group-manager level) so the web UI cannot create a slash-containing group that the API then can't manage — closing the gap between the two entry points.
    • Existing groups with slashes already created before this change are unaffected by this validation (no migration/deletion of existing data implied here).
    • The acceptance tests already scaffolded for this (tagged @issue-31015, @skipOnOcV10) are updated: creation of a slash-containing group now expects rejection (101) instead of the current skip/expected-failure state, and the tags are removed.

    Files:

    • apps/provisioning_api/lib/Groups.php — addGroup(): add a check rejecting / in $groupId alongside the existing empty/whitespace validation, returning the same \OC\OCS\Result(null, 101, 'Invalid group name').
    • lib/private/Group/Manager.php — createGroup(): add the same slash restriction so the web UI is covered too, not just the API.
    • tests/acceptance/features/apiProvisioningGroups-v1/addGroupOc10Issue31015.feature, apiProvisioningGroups-v2/addGroupOc10Issue31015.feature, and the @issue-31015 @skipOnOcV10 scenarios in addGroup.feature, deleteGroup.feature, addToGroup.feature, removeFromGroup.feature, getUserGroups.feature — update expectations to "creation rejected" and remove the skip tags.
    • Unit test for Groups::addGroup() asserting a slash-containing name returns OCS code 101.

    Constraints:

    • Test coverage ≥ 85% on touched code (e2e preferred — run the tool, do not trust claimed %)
    • Commit signing: GPG signature + DCO Signed-off-by
    • Rebase onto base branch before pushing
    • No root-directory edits
    • Scope this PR to / only (per the agreed decision); a separate related report (groups of systemtags are separated by "|" #34086, | in group names) should be handled independently rather than folded in silently.

    🤖 Automated by Claude Code


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions