Skip to content

Banner upload returns 403 after navigating from /admin/drafts → Edit (CSRF token rotation) #101

@vnykmshr

Description

@vnykmshr

Repro on v3.18.0:

  1. Authenticate; go to /admin/drafts.
  2. Click Edit on any draft → /compose/edit/.
  3. Click Upload banner image, pick a PNG.

POST /compose/upload/ returns 403; status panel shows "Draft saving unavailable — copy your work before leaving".

Cause: the page captures meta[name=csrf-token] at initial render, but compose.go's edit-mode GET path appears to rotate the _csrf cookie (calls to refreshCSRFToken visible in compose.go around lines 220/240/292/310/329). The submitted X-CSRF-Token header is the page's stale meta value; the cookie has the new value → middleware.CSRF mismatch → 403.

Workaround: hard-reload /compose/edit/<slug> immediately before clicking Upload. Verified 100% reproducible and 100% fixed by the reload.

Reasonable fix: have the frontend refresh meta from the response on every CSRF-rotating GET, or stop rotating on idempotent edit-mode GETs, or have the upload XHR read the cookie directly (double-submit on body, not just meta-captured header).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions