LDAP mode: every LDAP user reads as "departed" (links 404, shares frozen, admin can transfer a live user's home) #857

Closed
opened 2026-10-07 18:22:48 +00:00 by Cordy · 5 comments
Owner

Severity: high. Found during the #844/#856 batch review (2026-10-07); investigation confirmed. It is pre-existing, from #597, not new in this batch.

Cause

The liveness oracle is built with LocalAuthoritative: cfg.Auth.Mode != "oidc" (cmd/cairnd/main.go ~916). In LDAP mode it therefore treats the local store and config accounts as the complete list of accounts (internal/liveness/liveness.go ~73), so every LDAP user counts as departed.

Effects in LDAP mode

  • Public links of LDAP users answer 404 (internal/share/public.go ~110), and their person and group shares stop serving (main.go ~1810).
  • LDAP users are listed under Departed owners, and their shares show "Frozen, owner departed".
  • They are filtered out of share recipients.
  • The transfer and revoke guards treat them as departed, so an admin can move a live LDAP user's whole home or revoke all of their shares.

The OIDC dogfoods are unaffected, which is why this wasn't noticed. LDAP was only exercised against Mokapi (#838).

Fix direction

  • Treat the local store as the full list of accounts only in local mode.
  • In LDAP mode, add a directory lookup to the oracle. ldapauth.Provider.Recheck from #838 already does exists, enabled and groups lookups, with outage handling. An outage must never count as departed.
  • Tests per mode: local, ldap and oidc, with and without an IdP admin client, including an outage case.
  • Re-run the Mokapi setup from #838 to verify links, shares and the Departed owners list.
**Severity: high.** Found during the #844/#856 batch review (2026-10-07); investigation confirmed. It is pre-existing, from #597, not new in this batch. ## Cause The liveness oracle is built with `LocalAuthoritative: cfg.Auth.Mode != "oidc"` (`cmd/cairnd/main.go` ~916). In **LDAP** mode it therefore treats the local store and config accounts as the complete list of accounts (`internal/liveness/liveness.go` ~73), so every LDAP user counts as departed. ## Effects in LDAP mode - Public links of LDAP users answer 404 (`internal/share/public.go` ~110), and their person and group shares stop serving (`main.go` ~1810). - LDAP users are listed under Departed owners, and their shares show "Frozen, owner departed". - They are filtered out of share recipients. - **The transfer and revoke guards treat them as departed**, so an admin can move a live LDAP user's whole home or revoke all of their shares. The OIDC dogfoods are unaffected, which is why this wasn't noticed. LDAP was only exercised against Mokapi (#838). ## Fix direction - Treat the local store as the full list of accounts only in `local` mode. - In LDAP mode, add a directory lookup to the oracle. `ldapauth.Provider.Recheck` from #838 already does exists, enabled and groups lookups, with outage handling. An outage must never count as departed. - Tests per mode: local, ldap and oidc, with and without an IdP admin client, including an outage case. - Re-run the Mokapi setup from #838 to verify links, shares and the Departed owners list.
Author
Owner

Preparation (2026-10-08)

Code facts

  • internal/liveness/liveness.go Oracle.Alive:
    • checks the local store first;
    • then if LocalAuthoritative, returns not alive;
    • then if there's no Directory, returns alive;
    • otherwise asks Directory (cached 60s positive, 15s negative).
    • Any directory error reads as not alive ("fail-frozen"). Outage uses a separate Probe.
  • cmd/cairnd/main.go ~914 sets LocalAuthoritative: cfg.Auth.Mode != "oidc", so in ldap mode every LDAP user is departed. Directory/Probe are wired only from the Keycloak admin client.
  • Consumers:
    • public links: internal/share/public.go:110;
    • the person/group share gate: main.go:1809;
    • the Departed owners list and the transfer/revoke guards: internal/api/owners.go:75-510;
    • recipients: recipients.go:171;
    • the admin Shares "Frozen" badge: admin_shares.go:184;
    • space owner checks: main.go:1325;
    • the #849 leftover gate: localusers.go:346, which currently refuses in ldap mode because of this bug.
  • What #838 already provides: ldapauth.Provider.Recheck(ctx, canonical) (exists, enabled, groups, err). It distinguishes missing from outage (err only for transport failures; more than one match is an error), honours the ctx deadline, and falls back to the login filter when the username attribute doesn't match.

How others handle it

  • Nextcloud with LDAP: a background job (every 51 min by default) checks whether each mapped LDAP account still exists and flags the missing ones as "remnants". Nothing is deleted automatically; an admin reviews occ ldap:show-remnants and removes them deliberately with occ user:delete (docs). Users report shares breaking around remnant users and transfer failing for them (forum, server#15536).
  • Nextcloud with a disabled account: current docs say external shares (public links, email) of a disabled user stop working while internal shares keep working (admin manual). The setting behind this changed meaning in 34.0.2 and caused "files disappeared" reports (server#63159). Older versions kept links alive (server#10869, server#16302), and people also ask for the opposite (server#57444).
  • Lesson:
    • "missing in the directory" must be distinguished from "directory unreachable";
    • destructive follow-ups (transfer, revoke) must stay an explicit admin act;
    • silently changing what "disabled" means breaks trust.

Decisions for Nikola (asked now, while this is being worked on)

  1. Does a disabled (but existing) directory account count as alive or departed?
  2. During a directory outage, freeze (as today) or keep the last known answer?
## Preparation (2026-10-08) ### Code facts - `internal/liveness/liveness.go` `Oracle.Alive`: - checks the local store first; - then if `LocalAuthoritative`, returns not alive; - then if there's no `Directory`, returns alive; - otherwise asks `Directory` (cached 60s positive, 15s negative). - Any directory error reads as not alive ("fail-frozen"). `Outage` uses a separate `Probe`. - `cmd/cairnd/main.go` ~914 sets `LocalAuthoritative: cfg.Auth.Mode != "oidc"`, so in **ldap** mode every LDAP user is departed. `Directory`/`Probe` are wired only from the Keycloak admin client. - **Consumers:** - public links: `internal/share/public.go:110`; - the person/group share gate: `main.go:1809`; - the Departed owners list and the transfer/revoke guards: `internal/api/owners.go:75-510`; - recipients: `recipients.go:171`; - the admin Shares "Frozen" badge: `admin_shares.go:184`; - space owner checks: `main.go:1325`; - the #849 leftover gate: `localusers.go:346`, which currently refuses in ldap mode because of this bug. - **What #838 already provides:** `ldapauth.Provider.Recheck(ctx, canonical) (exists, enabled, groups, err)`. It distinguishes missing from outage (err only for transport failures; more than one match is an error), honours the ctx deadline, and falls back to the login filter when the username attribute doesn't match. ### How others handle it - **Nextcloud with LDAP:** a background job (every 51 min by default) checks whether each mapped LDAP account still exists and **flags** the missing ones as "remnants". Nothing is deleted automatically; an admin reviews `occ ldap:show-remnants` and removes them deliberately with `occ user:delete` ([docs](https://docs.nextcloud.com/server/stable/admin_manual/configuration_user/user_auth_ldap_cleanup.html)). Users report shares breaking around remnant users and transfer failing for them ([forum](https://help.nextcloud.com/t/files-not-accessible-after-sharing-ldap-user-was-deleted/38185), [server#15536](https://github.com/nextcloud/server/issues/15536)). - **Nextcloud with a disabled account:** current docs say external shares (public links, email) of a disabled user stop working while internal shares keep working ([admin manual](https://docs.nextcloud.com/server/stable/admin_manual/configuration_user/user_configuration.html)). The setting behind this changed meaning in 34.0.2 and caused "files disappeared" reports ([server#63159](https://github.com/nextcloud/server/issues/63159)). Older versions kept links alive ([server#10869](https://github.com/nextcloud/server/issues/10869), [server#16302](https://github.com/nextcloud/server/issues/16302)), and people also ask for the opposite ([server#57444](https://github.com/nextcloud/server/issues/57444)). - **Lesson:** - "missing in the directory" must be distinguished from "directory unreachable"; - destructive follow-ups (transfer, revoke) must stay an explicit admin act; - silently changing what "disabled" means breaks trust. ### Decisions for Nikola (asked now, while this is being worked on) 1. Does a **disabled** (but existing) directory account count as alive or departed? 2. During a directory **outage**, freeze (as today) or keep the last known answer?
Author
Owner

Decision (Nikola, 2026-10-08): outage keeps the last known answer. Someone confirmed alive stays alive while the directory is unreachable. People never seen, or already known to be departed, stay as they were. Transfer and revoke stay blocked during an outage.

Disabled accounts: Nikola asked for deeper research first: ISO norms; what ownCloud and OpenCloud do; what users and operators of ownCloud, OpenCloud and Nextcloud say and wish for; and what issues those implementations caused. Research follows below.

**Decision (Nikola, 2026-10-08): outage keeps the last known answer.** Someone confirmed alive stays alive while the directory is unreachable. People never seen, or already known to be departed, stay as they were. Transfer and revoke stay blocked during an outage. **Disabled accounts:** Nikola asked for deeper research first: ISO norms; what ownCloud and OpenCloud do; what users and operators of ownCloud, OpenCloud and Nextcloud say and wish for; and what issues those implementations caused. Research follows below.
Author
Owner

Norms

  • ISO/IEC 27001:2022 A.5.18 (access rights): access must be revoked or adjusted when it's no longer needed, especially at termination. How is left to the organisation's access-control policy (Advisera, ISMS.online summary). The standard doesn't distinguish disable from delete.
  • CIS Controls v8, safeguard 6.2: disable accounts immediately on termination instead of deleting them, to preserve audit trails (CIS). So disabled is the normal leaver state, often with a grace period before deletion.
  • BSI IT-Grundschutz ORP.4: defines processes for granting, withdrawing and checking rights, and for removing identities and rights no longer needed when someone leaves (BSI ORP.4 PDF).
  • Reading: a leaver's external exposure (public links to third parties) is access that is "no longer needed" and should end at termination. Internal hand-over of their work to colleagues is legitimate during the grace period.

ownCloud (classic and oCIS)

  • Product stance (ownCloud product lead, owncloud/core#12601, restated in #38291): "The only effect a disabled user shall have is that the user can't login any longer." Links and shares stay.
  • In practice it was inconsistent. The acceptance tests in #38291 show a disabled user's public link answering 404 on the new public WebDAV API and 200 on the old one.
  • oCIS: a disabled user creating a share got an empty response instead of an error (ocis#2212). There is no documented link behaviour.

OpenCloud

  • No documented behaviour for disabled accounts' links and shares.
  • Disabled users are still treated as normal share recipients: space-share notification mails are sent to disabled users and to disabled group members (opencloud#3513).

Nextcloud: what operators said, and what broke

  • Until 34.0.1 the default was:
    • public links and email shares of a disabled user stop;
    • internal shares keep working;
    • hide_disabled_user_shares=yes hid internal shares too.
  • PR #62092, backported to 30 through 34, changed the default to block everything. Since then the only way to restore internal access also re-enables public links. After upgrading, users saw files and folders disappear (server#63159).
  • TU Wien's operator explained the real requirement: they keep leavers' accounts disabled for a grace period before deletion. Colleagues must be able to pull shared files to re-host them, but the disabled account's public shares must be gone immediately: otherwise former employees could exfiltrate data, and stopping compromised accounts gets harder. They asked to split the setting into "external" and "internal", and the Nextcloud dev agreed that this is the request. It is still open.
  • The opposite wish also exists. Teams using shared or group folders want links created inside a shared folder to survive the creator's disablement or deletion, because third parties and automations depend on them (server#57444, groupfolders#4248). Older reports asked for links to be disabled (server#10869, server#16302).
  • LDAP-deleted accounts (remnants): these are only flagged by a background job and removed by an admin (docs). Shares around remnants broke, and transfer failed for them (forum, server#15536).

Options for Cairn

  • A. Alive (ownCloud's stance; what Cairn does today with Keycloak):
    • disabled only blocks sign-in (done in #838);
    • links and shares keep working.
    • Risk: a leaver's public links keep serving third parties, which is the exfiltration concern the norms point at.
  • B. Paused (Nextcloud's pre-34.0.2 default; the split TU Wien asked for):
    • public links of a disabled owner stop at once;
    • internal person and group shares keep working, so colleagues can take over;
    • the owner is shown as Disabled, not Departed;
    • no automatic transfer or revoke;
    • re-enabling brings the links back unchanged.
    • Needs a small UI state (badge, Frozen reason) and therefore a mockup.
  • C. Departed (Nextcloud's current default):
    • everything freezes and the owner shows under Departed owners;
    • this is the setting that caused "files disappeared" on upgrade, and it blocks the hand-over.

Recommendation: B. It is the only option that satisfies both the security requirement (external exposure ends at termination, A.5.18) and the hand-over requirement. It's also what operators asked for explicitly, and it avoids both Nextcloud failure modes. Links inside Spaces (#57444's wish) are a separate question, already tracked in #835/#654.

## Research: what should a DISABLED (still existing) account mean for links and shares? (2026-10-08) ### Norms - **ISO/IEC 27001:2022 A.5.18 (access rights):** access must be revoked or adjusted when it's no longer needed, especially at termination. How is left to the organisation's access-control policy ([Advisera](https://advisera.com/iso27001/control-5-18-access-rights/), [ISMS.online summary](https://www.isms.online/iso-27001/annex-a-2022/8-15-logging-2022/)). The standard doesn't distinguish disable from delete. - **CIS Controls v8, safeguard 6.2:** disable accounts immediately on termination **instead of deleting** them, to preserve audit trails ([CIS](https://controls-assessment-specification.readthedocs.io/en/latest/control-6/control-6.2.html)). So disabled is the normal leaver state, often with a grace period before deletion. - **BSI IT-Grundschutz ORP.4:** defines processes for granting, **withdrawing** and checking rights, and for removing identities and rights no longer needed when someone leaves ([BSI ORP.4 PDF](https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Grundschutz/IT-GS-Kompendium_Einzel_PDFs_2022/02_ORP_Organisation_und_Personal/ORP_4_Identitaets_und_Berechtigungsmanagement_Editon_2022.pdf)). - **Reading:** a leaver's **external** exposure (public links to third parties) is access that is "no longer needed" and should end at termination. Internal hand-over of their work to colleagues is legitimate during the grace period. ### ownCloud (classic and oCIS) - **Product stance (ownCloud product lead, owncloud/core#12601, restated in [#38291](https://github.com/owncloud/core/issues/38291)):** "The only effect a disabled user shall have is that the user can't login any longer." Links and shares stay. - **In practice it was inconsistent.** The acceptance tests in #38291 show a disabled user's public link answering 404 on the new public WebDAV API and 200 on the old one. - **oCIS:** a disabled user creating a share got an empty response instead of an error ([ocis#2212](https://github.com/owncloud/ocis/issues/2212)). There is no documented link behaviour. ### OpenCloud - No documented behaviour for disabled accounts' links and shares. - Disabled users are still treated as normal share recipients: space-share notification mails are sent to disabled users and to disabled group members ([opencloud#3513](https://github.com/opencloud-eu/opencloud/issues/3513)). ### Nextcloud: what operators said, and what broke - **Until 34.0.1 the default was:** - public links and email shares of a disabled user **stop**; - internal shares **keep working**; - `hide_disabled_user_shares=yes` hid internal shares too. - **PR #62092**, backported to 30 through 34, changed the default to **block everything**. Since then the only way to restore internal access also re-enables public links. After upgrading, users saw files and folders **disappear** ([server#63159](https://github.com/nextcloud/server/issues/63159)). - **TU Wien's operator explained the real requirement:** they keep leavers' accounts disabled for a grace period before deletion. Colleagues must be able to **pull shared files to re-host them**, but the disabled account's **public shares must be gone immediately**: otherwise former employees could exfiltrate data, and stopping compromised accounts gets harder. They asked to **split the setting into "external" and "internal"**, and the Nextcloud dev agreed that this is the request. It is still open. - **The opposite wish also exists.** Teams using shared or group folders want links created **inside a shared folder** to survive the creator's disablement or deletion, because third parties and automations depend on them ([server#57444](https://github.com/nextcloud/server/issues/57444), groupfolders#4248). Older reports asked for links to be disabled ([server#10869](https://github.com/nextcloud/server/issues/10869), [server#16302](https://github.com/nextcloud/server/issues/16302)). - **LDAP-deleted accounts (remnants):** these are only flagged by a background job and removed by an admin ([docs](https://docs.nextcloud.com/server/stable/admin_manual/configuration_user/user_auth_ldap_cleanup.html)). Shares around remnants broke, and transfer failed for them ([forum](https://help.nextcloud.com/t/files-not-accessible-after-sharing-ldap-user-was-deleted/38185), [server#15536](https://github.com/nextcloud/server/issues/15536)). ### Options for Cairn - **A. Alive** (ownCloud's stance; what Cairn does today with Keycloak): - disabled only blocks sign-in (done in #838); - links and shares keep working. - **Risk:** a leaver's public links keep serving third parties, which is the exfiltration concern the norms point at. - **B. Paused** (Nextcloud's pre-34.0.2 default; the split TU Wien asked for): - public links of a disabled owner **stop at once**; - internal person and group shares **keep working**, so colleagues can take over; - the owner is shown as **Disabled**, not Departed; - no automatic transfer or revoke; - re-enabling brings the links back unchanged. - Needs a small UI state (badge, Frozen reason) and therefore a mockup. - **C. Departed** (Nextcloud's current default): - everything freezes and the owner shows under Departed owners; - this is the setting that caused "files disappeared" on upgrade, and it blocks the hand-over. **Recommendation: B.** It is the only option that satisfies both the security requirement (external exposure ends at termination, A.5.18) and the hand-over requirement. It's also what operators asked for explicitly, and it avoids both Nextcloud failure modes. Links inside Spaces (#57444's wish) are a separate question, already tracked in #835/#654.
Author
Owner

Decision (Nikola, 2026-10-08): disabled accounts are "Paused", with Personal links only.

For a directory account that still exists but is disabled (AD userAccountControl, Keycloak enabled=false):

  • public links into their Personal folder stop serving immediately;
  • public links into Spaces keep serving, but are flagged "creator disabled" in Administration › Sharing › Shares so an admin reviews them;
  • internal person and group shares keep working, so colleagues can take over during the grace period;
  • the account counts as Disabled, not Departed: no automatic transfer or revoke, and it doesn't appear under Departed owners;
  • re-enabling the account restores everything unchanged.

Deleted (departed) accounts keep today's behaviour: all of their links and shares freeze until an admin acts. Links in Spaces for departed creators stay in #835/#654.

Outage: keep the last known answer (decided earlier today).

UI work (a Disabled marker and the "creator disabled" flag) gets a mockup before it's built.

**Decision (Nikola, 2026-10-08): disabled accounts are "Paused", with Personal links only.** For a directory account that still exists but is **disabled** (AD `userAccountControl`, Keycloak `enabled=false`): - public links into their **Personal folder** stop serving immediately; - public links into **Spaces** keep serving, but are flagged "creator disabled" in Administration › Sharing › Shares so an admin reviews them; - **internal** person and group shares keep working, so colleagues can take over during the grace period; - the account counts as **Disabled, not Departed**: no automatic transfer or revoke, and it doesn't appear under Departed owners; - re-enabling the account restores everything unchanged. **Deleted (departed) accounts** keep today's behaviour: all of their links and shares freeze until an admin acts. Links in Spaces for departed creators stay in #835/#654. **Outage:** keep the last known answer (decided earlier today). UI work (a Disabled marker and the "creator disabled" flag) gets a mockup before it's built.
Author
Owner

Verification: Mokapi AD, branch ldap-857 (2026-10-08)

Setup: ldap mode; users boss (admin via cairn-admins), carla, anna and bob. Each of carla, anna and bob has a public link to a file in their Personal folder. Then anna is disabled (userAccountControl: 514) and bob is deleted.

Check Before change After 65s Directory stopped
carla's link (active) 200 200 (main: 404, the bug) 200 (last known)
anna's link (disabled, Personal) 200 404 (paused) 404
bob's link (deleted) 200 404 (frozen) 404
  • Departed owners lists only bob.
  • Admin Shares shows carla active, anna paused, bob frozen.
  • Transferring from anna answers this account is disabled, not deleted; transfer is for departed accounts.
  • /license/seats?liveness=1 marks anna as disabled: true, and only her.

Not covered by this run: Space links of a disabled creator (they keep serving with a flag). Unit tests cover that case.

Follow-up filed: OCM outbound grants ignore creator liveness (#860).

## Verification: Mokapi AD, branch ldap-857 (2026-10-08) Setup: ldap mode; users boss (admin via cairn-admins), carla, anna and bob. Each of carla, anna and bob has a public link to a file in their Personal folder. Then anna is disabled (`userAccountControl: 514`) and bob is deleted. | Check | Before change | After 65s | Directory stopped | |---|---|---|---| | carla's link (active) | 200 | **200** (main: 404, the bug) | **200** (last known) | | anna's link (disabled, Personal) | 200 | **404** (paused) | 404 | | bob's link (deleted) | 200 | **404** (frozen) | 404 | - Departed owners lists **only bob**. - Admin Shares shows carla `active`, anna `paused`, bob `frozen`. - Transferring from anna answers `this account is disabled, not deleted; transfer is for departed accounts`. - `/license/seats?liveness=1` marks anna as `disabled: true`, and only her. Not covered by this run: Space links of a disabled creator (they keep serving with a flag). Unit tests cover that case. Follow-up filed: OCM outbound grants ignore creator liveness (#860).
Cordy closed this issue 2026-10-08 11:32:49 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#857
No description provided.