[PR #2578] [MERGED] fix(labels): fix access-control query leak in label reads (GHSA-hj5c-mhh2-g7jq) #10095

Closed
opened 2026-04-23 09:23:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2578
Author: @tink-bot
Created: 4/9/2026
Status: Merged
Merged: 4/9/2026
Merged by: @kolaente

Base: mainHead: fix-label-access-sql-precedence


📝 Commits (2)

  • 6906857 fix(labels): correct broken access-control query for label reads (GHSA-hj5c-mhh2-g7jq)
  • c7711cf fix(labels): derive label max permission from accessible tasks only

📊 Changes

4 files changed (+194 additions, -30 deletions)

View changed files

📝 pkg/db/fixtures/label_tasks.yml (+12 -1)
📝 pkg/db/fixtures/labels.yml (+20 -0)
📝 pkg/models/label_permissions.go (+59 -19)
📝 pkg/models/label_test.go (+103 -10)

📄 Description

hasAccessToLabel chained .Where/.Or/.And on the xorm session, which flattened to WHERE A OR B OR C AND D. Under SQL precedence that evaluates as A OR B OR (C AND D), so the labels.id = ? scope only narrowed one branch — the other two branches leaked every label with any label_tasks row and every label the caller had ever created, regardless of the requested id.

The query is now built with explicit builder.And / builder.Or grouping so the label-id scope wraps the full disjunction. The bogus label_tasks.label_id IS NOT NULL branch is removed, the creator branch is restricted to real user auths, and Exist(ll) becomes Get(ll) so the follow-up Task.CanRead permission computation actually runs; the creator-only path falls back to PermissionRead.

Regression coverage adds fixture label #6 (private, task #34 in project #20) and label #7 (created by user #1, unattached) with explicit allow/deny assertions in TestLabel_ReadOne, and updates TestLabel_ReadAll expectations accordingly.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2578 **Author:** [@tink-bot](https://github.com/tink-bot) **Created:** 4/9/2026 **Status:** ✅ Merged **Merged:** 4/9/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-label-access-sql-precedence` --- ### 📝 Commits (2) - [`6906857`](https://github.com/go-vikunja/vikunja/commit/6906857cfe8fcf216c7394c0b736648c38fe2401) fix(labels): correct broken access-control query for label reads (GHSA-hj5c-mhh2-g7jq) - [`c7711cf`](https://github.com/go-vikunja/vikunja/commit/c7711cf3fa215f0be05e49f954c910818e646ebe) fix(labels): derive label max permission from accessible tasks only ### 📊 Changes **4 files changed** (+194 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `pkg/db/fixtures/label_tasks.yml` (+12 -1) 📝 `pkg/db/fixtures/labels.yml` (+20 -0) 📝 `pkg/models/label_permissions.go` (+59 -19) 📝 `pkg/models/label_test.go` (+103 -10) </details> ### 📄 Description `hasAccessToLabel` chained `.Where`/`.Or`/`.And` on the xorm session, which flattened to `WHERE A OR B OR C AND D`. Under SQL precedence that evaluates as `A OR B OR (C AND D)`, so the `labels.id = ?` scope only narrowed one branch — the other two branches leaked every label with any `label_tasks` row and every label the caller had ever created, regardless of the requested id. The query is now built with explicit `builder.And` / `builder.Or` grouping so the label-id scope wraps the full disjunction. The bogus `label_tasks.label_id IS NOT NULL` branch is removed, the creator branch is restricted to real user auths, and `Exist(ll)` becomes `Get(ll)` so the follow-up `Task.CanRead` permission computation actually runs; the creator-only path falls back to `PermissionRead`. Regression coverage adds fixture label #6 (private, task #34 in project #20) and label #7 (created by user #1, unattached) with explicit allow/deny assertions in `TestLabel_ReadOne`, and updates `TestLabel_ReadAll` expectations accordingly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 09:23:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#10095