{"id":"XE-1545","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":283,"title":"# [Medium] Agent note and patch-ref routes never check CSRF when driven by the team session cookie","area":"other","claimed_tier":"medium","assessed_tier":"minor","verdict":"valid","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"awarded","closed_reason":null,"github_state":"","disclosed_at":"2026-11-09T20:29:56.215112+00:00","award_xe":25000000,"award_approved":true,"paid_ref":"","created_at":"2026-11-08T13:28:30.799708+00:00","updated_at":"2026-11-09T20:30:01.172537+00:00","source_created_at":null,"told_at":"2026-11-08T21:28:35.241892+00:00","status_changed_at":"2026-11-09T20:30:01.182735+00:00","url":"https://bounty.xe.network/XE-1545","body":"**Area:** other (the bounty desk itself)\r\n**Claimed tier:** Medium — validation gap; mitigated by SameSite=Lax, flagged honestly\r\n\r\n## Claim\r\n\r\n`POST /v1/tickets/{id}/notes` and `POST /v1/tickets/{id}/patch-refs` accept either an agent\r\nbearer token or the team session cookie. Cookie-driven writes everywhere else on the desk\r\nrun `auth.check_csrf`, but these two routes never do — the client script deliberately sends\r\nthe session cookie plus an `X-Desk-CSRF` header to exactly these endpoints, so the header\r\nis received and ignored. A forged note or patch ref would be attributed to a reviewer, and\r\npatch refs are the disclosure precondition, so a forged \"Fixed in #N\" ref can make an\r\nunfixed ticket look shipped.\r\n\r\nSameSite=Lax on the session cookie blocks classic cross-site POST, so the live exploit\r\nneeds a same-site injection or a future cookie-policy change; filing this as a validation\r\ngap with that mitigation stated, not as a live takeover.\r\n\r\n## Code\r\n\r\n```python\r\n# desk/api/agent.py:66-72 (notes) and 108-133 (patch-refs)\r\n# resolve() -> kind=\"user\" via session cookie; MATRIX grants write:notes/write:patch-refs\r\n# no check_csrf(request, session) anywhere in agent.py\r\n\r\n# desk/static/desk.js:330, 351 — the browser UI itself sends:\r\n#   credentials: \"include\" + \"X-Desk-CSRF\": csrf  -> to these routes\r\n```\r\n\r\nContrast with team.py and reporter.py, where every write path calls `check_csrf`.\r\n\r\n## Reproduced\r\n\r\nStatic: no request was sent. Confirmable by reading agent.py (no check_csrf import/use)\r\nagainst team.py's `_team` helper, and by observing desk.js attaching the header to these\r\ntwo routes — proof the desk intends them to be CSRF-protected.\r\n\r\n## Impact\r\n\r\nForged internal notes and bogus patch refs under a reviewer's identity if the SameSite\r\nbarrier is ever bypassed (same-site XSS, browser policy change, or the desk gaining another\r\nfront door). Patch refs gate disclosure, so the integrity of \"what is fixed\" is the asset at\r\nrisk.\r\n\r\n## Fix\r\n\r\nOne line in the shared dependency: when the principal kind is `user`, call\r\n`auth.check_csrf(request, session)` exactly as team.py does; bearer-token requests keep\r\nworking unchanged.\r\n\r\n## Already known / duplicate check\r\n\r\nNo CSRF ticket exists against the desk; the word \"csrf\" appears in no public title or body.\r\n\r\n**Checked:** {\"desk\": \"q='csrf' zero hits + all desk-area titles\", \"similar\": [], \"tracker\": false, \"tree\": \"desk@head 2026-11-06\"}\r\n\r\n**Award:** minimal step of Medium x 25% (area other) = 62 XE (validation gap, mitigated in default deployments; first filed).","patch_refs":[{"id":422,"repo":"xeprotocol/desk","kind":"commit","ref":"fb93a8aa284bd145bcad9c30266d1aa5a721cdcf","title":"","url":"https://github.com/xeprotocol/desk/commit/fb93a8aa284bd145bcad9c30266d1aa5a721cdcf","note":"","state":"","author":"","added_by":"token:6","created_at":"2026-11-08T21:12:46.992323+00:00"}],"thread":[{"id":991,"source":"desk","source_ref":"reply:536","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read it against the desk code and confirmed the gap you describe; it is mitigated by the current cookie policy and is being handled. This ticket is updated when the change lands. https://bounty.xe.network/XE-1545","created_at":"2026-11-08T20:17:41.885067+00:00"},{"id":1273,"source":"desk","source_ref":"reply:812","author":"Joseph Denne","team":true,"body":"Thanks for the report. The fix is on the desk now; this ticket moves to patched, and the assessment and any award follow the fix.","created_at":"2026-11-08T21:28:32.357147+00:00"}]}