Security: the public link route served user and group shares by their internal key #1156

Closed
opened 2026-11-10 20:26:04 +00:00 by Cordy · 1 comment
Owner

Found by the #1036 wave 1 review (batch b6v07). The problem existed before this batch, in v0.6.405 and earlier.

What happened: the public link handler (/s/<token>, internal/share/public.go) looked tokens up with FileStore.Get. That function also matches the internal keys of user and group shares (g:<id>). So anyone who knew a share's internal id could fetch its files or folder listing at /s/g:<id>/... without signing in. It was read-only: PUT was refused.

Who could know an id: every recipient. GET /api/v1/shared returned the id of each item shared with the caller, and so did the Leave preview. Administrators also saw ids in the share lists and in audit notes (grant=). The realistic exposure is therefore people who once had access and lost it, who could keep reading without signing in:

  • someone removed from a group;
  • someone who chose Leave;
  • a disabled or departed account.

Fix (b6v07-fx1g, commit b9485e0c, ships in v0.6.406):

  • /s/ refuses g: tokens before the lookup.
  • It also refuses any record that is a grant or whose token differs from the one requested.
  • Test: TestPublicRefusesGrantKey1036 (posix and s3).
  • Confirmed in the final review through the real server with 18 spellings and six methods.

How to look for past use (corrected in the final review):

  • Request log: INFO request, on by default. Such requests appear as path=/s/g: followed by the first 6 characters of the share's id, with status and remote. Folder listings are included.
  • Access log: with access logging on, a file read this way is a read entry with no user and no link= note, on a path that was shared with people or groups. A real link's reads carry link=.
  • There is no link-access verb; an earlier version of this text was wrong about that.

Rollback: going back to v0.6.405 brings the problem back for shares with people and groups. Guest shares stay safe there.

For the release notes: list it as a security fix in v0.6.406 and recommend updating.

Found by the #1036 wave 1 review (batch b6v07). The problem existed before this batch, in v0.6.405 and earlier. **What happened:** the public link handler (`/s/<token>`, `internal/share/public.go`) looked tokens up with `FileStore.Get`. That function also matches the internal keys of user and group shares (`g:<id>`). So anyone who knew a share's internal id could fetch its files or folder listing at `/s/g:<id>/...` without signing in. It was read-only: PUT was refused. **Who could know an id:** every recipient. `GET /api/v1/shared` returned the id of each item shared with the caller, and so did the Leave preview. Administrators also saw ids in the share lists and in audit notes (`grant=`). The realistic exposure is therefore people who once had access and lost it, who could keep reading without signing in: - someone removed from a group; - someone who chose Leave; - a disabled or departed account. **Fix (b6v07-fx1g, commit b9485e0c, ships in v0.6.406):** - `/s/` refuses `g:` tokens before the lookup. - It also refuses any record that is a grant or whose token differs from the one requested. - Test: `TestPublicRefusesGrantKey1036` (posix and s3). - Confirmed in the final review through the real server with 18 spellings and six methods. **How to look for past use (corrected in the final review):** - **Request log:** INFO `request`, on by default. Such requests appear as `path=/s/g:` followed by the first 6 characters of the share's id, with `status` and `remote`. Folder listings are included. - **Access log:** with access logging on, a file read this way is a `read` entry with no user and no `link=` note, on a path that was shared with people or groups. A real link's reads carry `link=`. - There is no `link-access` verb; an earlier version of this text was wrong about that. **Rollback:** going back to v0.6.405 brings the problem back for shares with people and groups. Guest shares stay safe there. **For the release notes:** list it as a security fix in v0.6.406 and recommend updating.
Cordy closed this issue 2026-11-11 15:32:52 +00:00
Author
Owner

Fixed in v0.6.406 (PR #1157, merge bee68e7c), live on both dogfoods since 2026-11-11 15:34 UTC.

Live check: GET /s/g:abc/x answers 404 on .249 and .247.

The CHANGELOG has a security entry at the top of v0.6.406 that says how to look for past use: the request log shows path=/s/g:…. Rolling back to v0.6.405 reopens the problem for shares with people and groups.

Fixed in **v0.6.406** (PR #1157, merge bee68e7c), live on both dogfoods since 2026-11-11 15:34 UTC. Live check: `GET /s/g:abc/x` answers 404 on .249 and .247. The CHANGELOG has a security entry at the top of v0.6.406 that says how to look for past use: the request log shows `path=/s/g:…`. Rolling back to v0.6.405 reopens the problem for shares with people and groups.
Sign in to join this conversation.
No labels
No milestone
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#1156
No description provided.