<!-- XE-1545 · # [Medium] Agent note and patch-ref routes never check CSRF when driven by the team session cookie · testnet -->
*Markdown view of <https://bounty.xe.network/XE-1545>. The page is the record; this is the same page for reading.*

XE-1545 · Bounty

# \# \[Medium\] Agent note and patch-ref routes never check CSRF when driven by the team session cookie

Awarded
Minorclaimed Medium
web
filed 2026-11-08 13:28 UTC
by Kingdavid

Verdict
:   Valid

Tier
:   Minor

Claimed
:   Medium

Area
:   Other

Duplicate of
:   —

Tracked
:   —

Award
:   25 XE approved
    · ceiling 650

Updated
:   2026-11-09 20:30 UTC

Told
:   2026-11-08 21:28 UTC

### Patches

- [desk@fb93a8aa28](https://github.com/xeprotocol/desk/commit/fb93a8aa284bd145bcad9c30266d1aa5a721cdcf)

### History

- [57178](https://bounty.xe.network/log/57178) 2026-11-09 20:30 UTC ticket.status disclosed → awarded
- [57177](https://bounty.xe.network/log/57177) 2026-11-09 20:29 UTC ticket.status patched → disclosed
- [57176](https://bounty.xe.network/log/57176) 2026-11-09 20:29 UTC ticket.disclosed

[Full history](https://bounty.xe.network/log?ref=XE-1545) · [JSON](https://bounty.xe.network/v1/tickets/XE-1545) · [markdown](https://bounty.xe.network/XE-1545.md)

### 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

**Joseph Denne**team2026-11-08 20:17 UTCdesk

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

**Joseph Denne**team2026-11-08 21:28 UTCdesk

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.
