Skip to content

[Bug]: Remote group share persists after user loses group membership #35159

Closed

Description

@smesterheide

⚠️ 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 (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

In a federated setting a remote group share remains available to the user once the share is accepted but the group membership is lost to the user, eg. by leaving said group. This behavior differs from local groups where group membership determines access to the group share.

Steps to reproduce

  1. On two instances A and B enable remote group sharing (sending and receiving)
  2. On instance B create a user alice and add the user to a group users
  3. Create a remote group share to group users on instance B from instance A
  4. As user alice accept the share
  5. As user alice leave group users
  6. The share remains available

Expected behavior

The share should be lost to user alice when the group membership is dissolved. The behavior for group shares should be the same for local and remote group shares.

Installation method

Other Community project

Operating system

Debian/Ubuntu

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MySQL

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

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

No response

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "debug": true,
        "profiler": true,
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/apps-extra",
                "url": "\/apps-extra",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/apps-writable",
                "url": "\/apps-writable",
                "writable": true
            }
        ],
        "allow_local_remote_servers": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "1025",
        "skeletondirectory": "\/skeleton",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 2,
        "log_query": false,
        "query_log_file": "\/var\/www\/html\/data\/query.log",
        "diagnostics.logging": false,
        "diagnostics.logging.threshold": 0,
        "log.condition": {
            "apps": [
                "diagnostics",
                "admin_audit"
            ]
        },
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "nextcloud2.home.arpa",
            "172.20.0.6",
            "localhost"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "26.0.0.0",
        "overwrite.cli.url": "https:\/\/nextcloud2.home.arpa",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "app_install_overwrite": [
            "vo_federation"
        ],
        "theme": "",
        "maintenance": false,
        "overwriteprotocol": "https"
    }
}

List of activated Apps

Enabled:
  - cloud_federation_api: 1.9.0
  - comments: 1.16.0
  - contactsinteraction: 1.7.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - federatedfilesharing: 1.16.0
  - federation: 1.16.0
  - files: 1.21.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.0
  - lookup_server_connector: 1.14.0
  - oauth2: 1.14.0
  - provisioning_api: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - systemtags: 1.16.0
  - theming: 2.1.0
  - twofactor_backupcodes: 1.15.0
  - updatenotification: 1.16.0
  - user_status: 1.6.0
  - viewer: 1.10.0
  - vo_federation: 0.0.4
  - weather_status: 1.6.0
  - workflowengine: 2.8.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - testing
  - user_ldap
  - user_oidc

Nextcloud Signing status

Integrity checker has been disabled. Integrity cannot be verified.

Nextcloud Logs

No response

Additional info

No response

Activity

  1. added
    0. Needs triage
    on Nov 14, 2022
  2. szaimen commented on Jan 23, 2023

    @szaimen
  3. nextcloud-command commented on Feb 23, 2023

    @nextcloud-command
  4. added
    stale
    on Feb 23, 2023
  5. smesterheide commented on Mar 7, 2023

    @smesterheide
    ContributorAuthor

    The bug persists in Nextcloud 26 rc1.

    Some more info on the mechanism of action. When the user is removed from the group, only local group shares are removed (TYPE_USERGROUP), see here via the DefaultShareProvider.

  6. added and removed
    stale
    on Mar 7, 2023
  7. kyteinsky commented on Feb 11, 2025

    @kyteinsky
    Contributor

    adding some initial findings on this:

    1. group-related functions are not implemented (commented: We don't handle groups here). They do not receive any calls when something changes even. For userDeletedFromGroup function, no call is registered for user removal (user1) from the local group (alpha) that receives the remote share. (
      /**
      * This provider does not handle groups
      *
      * @param string $gid
      */
      public function groupDeleted($gid) {
      // We don't handle groups here
      }
      /**
      * This provider does not handle groups
      *
      * @param string $uid
      * @param string $gid
      */
      public function userDeletedFromGroup($uid, $gid) {
      // We don't handle groups here
      }
      )
    2. function getSharesInFolder ( ) reports 0 shares after user is not part of the group but the share remains mounted in the user's filesystem.
    3. again, after the user is not part of the group, the table oc_share_external still shows the user user1 as a holder of the share:
      (schema for convenience)
      CREATE TABLE oc_group_folders_trash (trash_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(250) NOT NULL, original_location VARCHAR(4000) NOT NULL, deleted_time BIGINT NOT NULL, folder_id BIGINT NOT NULL, deleted_by VARCHAR(64) DEFAULT NULL, file_id BIGINT DEFAULT NULL);
      2|-1|1|http://nextcloud3.local/|1|Y7ilHBn1NFNl5Bw||/Nextcloud_Server_Administration_Manual.pdf|admin|alpha|{{TemporaryMountPointName#/Nextcloud_Server_Administration_Manual.pdf}}|8d281de3bc0f0e86946a01caca5ded40|0
      3|2|1|http://nextcloud3.local/|1|Y7ilHBn1NFNl5Bw||/Nextcloud_Server_Administration_Manual.pdf|admin|admin|/Nextcloud_Server_Administration_Manual.pdf|f16cefb733a361ce660dce8d754929b5|1
      4|2|1|http://nextcloud3.local/|1|Y7ilHBn1NFNl5Bw||/Nextcloud_Server_Administration_Manual.pdf|admin|user1|/Nextcloud_Server_Administration_Manual.pdf|f16cefb733a361ce660dce8d754929b5|1
    4. For group shares, users are extracted from the group and put in oc_share individually (also evident from the db entries above):
      $this->externalShareManager->acceptShare($shareId, $user->getUID());

      Maybe this could also be the file where we can add the OCP\Group\Events\UserAddedEvent and OCP\Group\Events\UserRemovedEvent handlers, even the OCP\Group\Events\GroupDeletedEvent event perhaps?
      This function can be called to remove the external shares:
      public function removeShare($mountPoint): bool {
  8. added
    1. to develop
    and removed
    0. Needs triage
    on Feb 11, 2025
  9. sorbaugh commented on Feb 12, 2025

    @sorbaugh
    Contributor

    Since this happens in a federated environment, pinging @ArtificialOwl

  10. added
    2. developing
    and removed
    1. to develop
    on Feb 18, 2025
  11. provokateurin commented on Feb 24, 2025

    @provokateurin
    Member

    I have a fix ready: #51000

  12. added
    3. to review
    and removed
    2. developing
    on Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions