SECURITY: admin API reachable with app passwords and Basic credentials; restrict admin functions to browser/SSO sessions #890

Closed
opened 2026-10-12 23:23:53 +00:00 by Cordy · 4 comments
Owner

Found on 2026-10-13 while preparing #887. Decided by Nikola: restrict it.

Finding

requireAdmin (internal/api/admin.go:104) accepts any authenticated request (auth.UserFrom(...) plus the admin flag). That means:

  • an administrator's app password (for example the one stored in a WebDAV/sync client such as rclone, Explorer or Finder) can call every /api/v1/admin/* endpoint;
  • so can that administrator's Basic credentials.

If one of those credentials leaks, the attacker gets full admin power, not only file access.

Why it matters

  • Least privilege: NIST AC-6(2) says "use non-privileged accounts or roles, when accessing nonsecurity functions". BSI OPS.1.1.2.A22 says admin rights must not be used for tasks that don't need them, and sync clients don't.
  • BSI OPS.1.1.2.A5 (Edition 2023, verified) says "Jeder Anmeldevorgang (Login) über eine Administrationskennung MUSS protokolliert werden". With this fix, admin rights can only be used after an interactive sign-in. #887 logs every one of those, and also logs Basic/app-password sign-ins of admin accounts to be safe.

Proposal

  • The admin API (/api/v1/admin/*, plus any other requireAdmin route) accepts only interactive sessions: a session cookie from the form or OIDC sign-in.
  • Basic auth and app passwords get 403 admin-needs-session with a clear message. Their file and WebDAV access is unchanged.
  • Check before building:
    • Does any shipped feature, script or doc call admin endpoints with Basic? A first check of the handbook found none. Also check the license tooling, peering, OCM and the update check.
    • Should a scoped, revocable admin API token exist later for automation? Not now; record it if anyone needs it.
  • Docs: users-access.md / account.md (what app passwords can and cannot do), admin-policy.md, CHANGELOG with an upgrade note.
  • Standards page: add the AC-6(2) / OPS.1.1.2.A22 rows once shipped.

Tests

  • An admin's app password gets 403 admin-needs-session on an admin endpoint, but 200 on WebDAV.
  • An admin's Basic credentials get the same 403.
  • The same admin's browser session gets 200.
  • A non-admin's session still gets 403 admin access required.
Found on 2026-10-13 while preparing #887. Decided by Nikola: restrict it. ## Finding `requireAdmin` (`internal/api/admin.go:104`) accepts **any** authenticated request (`auth.UserFrom(...)` plus the admin flag). That means: - an administrator's **app password** (for example the one stored in a WebDAV/sync client such as rclone, Explorer or Finder) can call every `/api/v1/admin/*` endpoint; - so can that administrator's **Basic credentials**. If one of those credentials leaks, the attacker gets full admin power, not only file access. ## Why it matters - **Least privilege:** NIST AC-6(2) says "use non-privileged accounts or roles, when accessing nonsecurity functions". BSI OPS.1.1.2.A22 says admin rights must not be used for tasks that don't need them, and sync clients don't. - **BSI OPS.1.1.2.A5** (Edition 2023, verified) says "Jeder Anmeldevorgang (Login) über eine Administrationskennung MUSS protokolliert werden". With this fix, admin rights can only be used after an interactive sign-in. #887 logs every one of those, and also logs Basic/app-password sign-ins of admin accounts to be safe. ## Proposal - The admin API (`/api/v1/admin/*`, plus any other `requireAdmin` route) accepts only **interactive sessions**: a session cookie from the form or OIDC sign-in. - Basic auth and app passwords get **403 `admin-needs-session`** with a clear message. Their file and WebDAV access is unchanged. - **Check before building:** - Does any shipped feature, script or doc call admin endpoints with Basic? A first check of the handbook found none. Also check the license tooling, peering, OCM and the update check. - Should a scoped, revocable **admin API token** exist later for automation? Not now; record it if anyone needs it. - Docs: users-access.md / account.md (what app passwords can and cannot do), admin-policy.md, CHANGELOG with an upgrade note. - Standards page: add the AC-6(2) / OPS.1.1.2.A22 rows once shipped. ## Tests - An admin's app password gets 403 `admin-needs-session` on an admin endpoint, but 200 on WebDAV. - An admin's Basic credentials get the same 403. - The same admin's browser session gets 200. - A non-admin's session still gets 403 `admin access required`.
Author
Owner

Started in batch-v07k (together with #893 and #886), release v0.6.338. Spec: docs/superpowers/specs/2026-10-13-batch-v07k-design.md.

Findings from the code check:

  • Admin rights are checked in more places than requireAdmin:
    • the license gate, the peering gate and settings PUT;
    • admin overrides inside shared handlers: share revoke-any, the space admin override, instance capacity in /api/v1/quota, the Office token's Admin claim;
    • trash: over WebDAV an admin can list .trash trees and hard-delete inside them. With an app password, that is a deletion power in a sync client.
  • No shipped workflow, script or handbook example calls admin endpoints with Basic; only /dav uses curl -u. Peering authenticates with instance keys, not user credentials.

Approach:

  • One rule, auth.AdminPowers(u, admins): admin rights apply only when the request's credential was not a Basic credential verified on that request. This uses the existing User.ViaBasic flag, which local, app-password and LDAP Basic all set and sessions clear. It already drives the #841 throttle and the #887 sign-in audit.
  • Gates answer 403 admin-needs-session. Inside shared handlers, a Basic admin simply acts as a normal user.
  • u.Admin itself is unchanged, so the seat logic and the #887 admin sign-in audit stay as they are.
  • An end-to-end test runs through the real auth stack:
    • local Basic gets 403;
    • an app password gets 403 on the admin API but 207 on WebDAV;
    • a form session gets 200.

Not added: a scoped admin API token. Recorded here in case automation ever needs one.

**Started in batch-v07k (together with #893 and #886), release v0.6.338.** Spec: `docs/superpowers/specs/2026-10-13-batch-v07k-design.md`. **Findings from the code check:** - Admin rights are checked in more places than `requireAdmin`: - the license gate, the peering gate and settings PUT; - admin overrides inside shared handlers: share revoke-any, the space admin override, instance capacity in `/api/v1/quota`, the Office token's `Admin` claim; - **trash**: over WebDAV an admin can list `.trash` trees and hard-delete inside them. With an app password, that is a deletion power in a sync client. - No shipped workflow, script or handbook example calls admin endpoints with Basic; only `/dav` uses `curl -u`. Peering authenticates with instance keys, not user credentials. **Approach:** - One rule, `auth.AdminPowers(u, admins)`: admin rights apply only when the request's credential was **not** a Basic credential verified on that request. This uses the existing `User.ViaBasic` flag, which local, app-password and LDAP Basic all set and sessions clear. It already drives the #841 throttle and the #887 sign-in audit. - Gates answer 403 `admin-needs-session`. Inside shared handlers, a Basic admin simply acts as a normal user. - `u.Admin` itself is unchanged, so the seat logic and the #887 admin sign-in audit stay as they are. - An end-to-end test runs through the real auth stack: - local Basic gets 403; - an app password gets 403 on the admin API but 207 on WebDAV; - a form session gets 200. **Not added:** a scoped admin API token. Recorded here in case automation ever needs one.
Cordy closed this issue 2026-10-13 20:47:20 +00:00
Author
Owner

Shipped in v0.6.338 (PR #894). Both dogfoods run it (homelab-config 9a26c3f). The startup log shows version=v0.6.338 with no errors.

What changed:

  • auth.AdminPowers now decides every admin power. Gates answer 403 {"error":"Administrator functions need a browser sign-in. App passwords and other Basic credentials cannot use them.","code":"admin-needs-session"} on these routes:
    • /api/v1/admin/*
    • the license and peering admin routes
    • PUT /api/v1/settings
  • A Basic or app-password request now acts as an ordinary user for:
    • share revoke-any and space administration;
    • force-unlocking another user's lock (this check was missing from the first inventory; the task review found it);
    • quota capacity and the Office token's admin claim;
    • trash, both over WebDAV and through /api/v1/trash;
    • the settings GET redaction;
    • the admin bell items. The bell cache is now keyed separately for session and Basic requests, after the final review found it could serve a cached session result to a Basic request.
  • u.Admin, seat admission and the #887 admin sign-in audit are unchanged.
  • Behaviour change: force-unlock now counts every administrator (group, dashboard grant, local flag), not only auth.admins names. This matches the Locks page's Break lock and admin-policy.md.
  • Docs: users-access.md has a new section, "Administrator rights need a browser sign-in (#890)". account.md, admin-policy.md, deployment.md and ARCHITECTURE.md are updated. security-standards.md moves AC-6(2) and OPS.1.1.2.A22 to shipped.

Tests:

  • Unit tests for every gate and power.
  • An end-to-end test on the real stack:
    • an admin's local Basic login gets 403;
    • the admin's app password gets 403 on the admin API but 207 on /dav;
    • a form session gets 200.

Still open: Nikola's live check of the admin pages in the browser after the restart, and optionally an admin app password against /api/v1/admin/info, which should return 403 admin-needs-session.

**Shipped in v0.6.338** (PR #894). Both dogfoods run it (homelab-config 9a26c3f). The startup log shows `version=v0.6.338` with no errors. **What changed:** - `auth.AdminPowers` now decides every admin power. Gates answer 403 `{"error":"Administrator functions need a browser sign-in. App passwords and other Basic credentials cannot use them.","code":"admin-needs-session"}` on these routes: - `/api/v1/admin/*` - the license and peering admin routes - `PUT /api/v1/settings` - A Basic or app-password request now acts as an ordinary user for: - share revoke-any and space administration; - force-unlocking another user's lock (this check was missing from the first inventory; the task review found it); - quota capacity and the Office token's admin claim; - trash, both over WebDAV and through `/api/v1/trash`; - the settings GET redaction; - the admin bell items. The bell cache is now keyed separately for session and Basic requests, after the final review found it could serve a cached session result to a Basic request. - `u.Admin`, seat admission and the #887 admin sign-in audit are unchanged. - **Behaviour change:** force-unlock now counts every administrator (group, dashboard grant, local flag), not only `auth.admins` names. This matches the Locks page's **Break lock** and admin-policy.md. - **Docs:** users-access.md has a new section, "Administrator rights need a browser sign-in (#890)". account.md, admin-policy.md, deployment.md and ARCHITECTURE.md are updated. security-standards.md moves AC-6(2) and OPS.1.1.2.A22 to shipped. **Tests:** - Unit tests for every gate and power. - An end-to-end test on the real stack: - an admin's local Basic login gets 403; - the admin's app password gets 403 on the admin API but 207 on `/dav`; - a form session gets 200. Still open: Nikola's live check of the admin pages in the browser after the restart, and optionally an admin app password against `/api/v1/admin/info`, which should return 403 `admin-needs-session`.
Author
Owner

Live check on files-bao (v0.6.338), browser session as nikola-test (OIDC): passed.

  • Reads: these all return 200 with the expected data:
    • /api/v1/admin/info, emergency-access, audit, local-users, admin-review, holds, client-address, peering/keys, shares;
    • /api/v1/license/seats;
    • /api/v1/quota (it includes the instance total, so the admin path is intact);
    • /api/v1/notifications (it includes the admin-only breakglass-signin item).
  • Write: PUT /api/v1/settings with the unchanged object returns 200.
  • Audit: the new sign-in is recorded as auth-admin-signin source=oidc.
  • UI: Users & access › Accounts renders normally, and the rail shows v0.6.338.

The Basic and app-password 403 path is covered end to end by cmd/cairnd/admin890_test.go. I don't use real credentials, so I haven't run it live; an optional curl -u <admin>:<app-password> …/api/v1/admin/info is left to Nikola.

**Live check on files-bao (v0.6.338), browser session as `nikola-test` (OIDC): passed.** - **Reads:** these all return 200 with the expected data: - `/api/v1/admin/info`, `emergency-access`, `audit`, `local-users`, `admin-review`, `holds`, `client-address`, `peering/keys`, `shares`; - `/api/v1/license/seats`; - `/api/v1/quota` (it includes the instance `total`, so the admin path is intact); - `/api/v1/notifications` (it includes the admin-only `breakglass-signin` item). - **Write:** `PUT /api/v1/settings` with the unchanged object returns 200. - **Audit:** the new sign-in is recorded as `auth-admin-signin source=oidc`. - **UI:** Users & access › Accounts renders normally, and the rail shows v0.6.338. The Basic and app-password 403 path is covered end to end by `cmd/cairnd/admin890_test.go`. I don't use real credentials, so I haven't run it live; an optional `curl -u <admin>:<app-password> …/api/v1/admin/info` is left to Nikola.
Author
Owner

Live check of the Basic path, approved by Nikola: a throwaway local instance built from main e3b6ffb1 (v0.6.338), local auth, posix storage on 127.0.0.1. admin1 is a config admin and user1 an ordinary user, both with generated test passwords. The instance was deleted afterwards.

Request Result
admin1 Basic → GET /api/v1/admin/info 403 {"code":"admin-needs-session","error":"Administrator functions need a browser sign-in. App passwords and other Basic credentials cannot use them."}
admin1 Basic → PUT /api/v1/settings 403 admin-needs-session
admin1 Basic → POST /api/v1/license/refresh 403 admin-needs-session
admin1 Basic → PROPFIND /dav/ 207 (file access unchanged)
admin1 Basic → GET /api/v1/quota {} (no instance capacity, acts as an ordinary user)
admin1 form sign-in, then the session → admin/info 200; quota shows total
user1 session → admin/info 403 admin access required

The audit log still records the Basic sign-in: admin1 auth-breakglass-signin source=basic. admin1 is a config file admin, so it counts as break-glass under #880.

App passwords exist only in OIDC mode, so that path is covered by the end-to-end test TestAdminNeedsSessionLive890. It runs the real server with a fake IdP, and was re-run now: PASS. In it, an admin's app password gets 403 admin-needs-session on admin/info, license and peering, 207 on /dav/, and the form session gets 200.

Together with the browser-session check above, #890 is verified. Closing.

**Live check of the Basic path, approved by Nikola:** a throwaway local instance built from main e3b6ffb1 (v0.6.338), local auth, posix storage on 127.0.0.1. `admin1` is a config admin and `user1` an ordinary user, both with generated test passwords. The instance was deleted afterwards. | Request | Result | |---|---| | `admin1` Basic → `GET /api/v1/admin/info` | **403** `{"code":"admin-needs-session","error":"Administrator functions need a browser sign-in. App passwords and other Basic credentials cannot use them."}` | | `admin1` Basic → `PUT /api/v1/settings` | **403** `admin-needs-session` | | `admin1` Basic → `POST /api/v1/license/refresh` | **403** `admin-needs-session` | | `admin1` Basic → `PROPFIND /dav/` | **207** (file access unchanged) | | `admin1` Basic → `GET /api/v1/quota` | `{}` (no instance capacity, acts as an ordinary user) | | `admin1` form sign-in, then the session → `admin/info` | **200**; quota shows `total` | | `user1` session → `admin/info` | **403** `admin access required` | The audit log still records the Basic sign-in: `admin1 auth-breakglass-signin source=basic`. admin1 is a config file admin, so it counts as break-glass under #880. App passwords exist only in OIDC mode, so that path is covered by the end-to-end test `TestAdminNeedsSessionLive890`. It runs the real server with a fake IdP, and was re-run now: PASS. In it, an admin's app password gets 403 `admin-needs-session` on admin/info, license and peering, 207 on `/dav/`, and the form session gets 200. Together with the browser-session check above, #890 is verified. Closing.
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#890
No description provided.