# [Medium] Agent note and patch-ref routes never check CSRF when driven by the team session cookie
Report
Area: other (the bounty desk itself) Claimed tier: Medium — validation gap; mitigated by SameSite=Lax, flagged honestly
Claim
POST /v1/tickets/{id}/notes and POST /v1/tickets/{id}/patch-refs accept either an agent
bearer token or the team session cookie. Cookie-driven writes everywhere else on the desk
run auth.check_csrf, but these two routes never do — the client script deliberately sends
the session cookie plus an X-Desk-CSRF header to exactly these endpoints, so the header
is received and ignored. A forged note or patch ref would be attributed to a reviewer, and
patch refs are the disclosure precondition, so a forged "Fixed in #N" ref can make an
unfixed ticket look shipped.
SameSite=Lax on the session cookie blocks classic cross-site POST, so the live exploit needs a same-site injection or a future cookie-policy change; filing this as a validation gap with that mitigation stated, not as a live takeover.
Code
# desk/api/agent.py:66-72 (notes) and 108-133 (patch-refs)
# resolve() -> kind="user" via session cookie; MATRIX grants write:notes/write:patch-refs
# no check_csrf(request, session) anywhere in agent.py
# desk/static/desk.js:330, 351 — the browser UI itself sends:
# credentials: "include" + "X-Desk-CSRF": csrf -> to these routes
Contrast with team.py and reporter.py, where every write path calls check_csrf.
Reproduced
Static: no request was sent. Confirmable by reading agent.py (no check_csrf import/use)
against team.py's _team helper, and by observing desk.js attaching the header to these
two routes — proof the desk intends them to be CSRF-protected.
Impact
Forged internal notes and bogus patch refs under a reviewer's identity if the SameSite barrier is ever bypassed (same-site XSS, browser policy change, or the desk gaining another front door). Patch refs gate disclosure, so the integrity of "what is fixed" is the asset at risk.
Fix
One line in the shared dependency: when the principal kind is user, call
auth.check_csrf(request, session) exactly as team.py does; bearer-token requests keep
working unchanged.
Already known / duplicate check
No CSRF ticket exists against the desk; the word "csrf" appears in no public title or body.
Checked: {"desk": "q='csrf' zero hits + all desk-area titles", "similar": [], "tracker": false, "tree": "desk@head 2026-11-06"}
Award: minimal step of Medium x 25% (area other) = 62 XE (validation gap, mitigated in default deployments; first filed).
Thread
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
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.