Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

API-key authenticated GraphQL queries fail with "Invalid CSRF token" on every guarded resolver (7.4.0-beta.3)

Aperta
#2,092 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
graphql, typescript

Direzione di ricerca

Start by reproducing the guarded and unguarded GraphQL requests against the /graphql endpoint with the x-api-key header, then trace the authentication and CSRF handling used by the info, array, and docker resolvers. Done means valid API-key requests reach guarded resolvers without requiring a cookie/session CSRF token, while existing session authentication remains covered.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Environment

  • Unraid version: 7.4.0-beta.3
  • API key created via WebGUI: Settings → Management Access → API Keys, role: admin

Summary

Any GraphQL query that hits a resolver with an auth guard fails with Invalid CSRF token / UNAUTHENTICATED when authenticated purely via the x-api-key header — even though the official docs and a related report (Connect login loop from unraid-api socket path mismatch) both state that "the API responds correctly when using an explicit API key," implying API-key auth should bypass CSRF entirely (which is a cookie/session-auth concern).

This isn't intermittent — it's 100% reproducible across every guarded field I tried, while a query with no valid resolver (or a resolver with no guard, like welcome) passes authentication fine and returns a normal GraphQL error/response instead.

Steps to reproduce

# This succeeds (passes auth, hits GraphQL validation instead):
curl -s -k -X POST "https://<unraid-ip>/graphql" \
  -H "content-type: application/json" \
  -H "x-api-key: $API_KEY" \
  --data-raw '{"query":"{ welcome { message } }"}'

# This fails every time with "Invalid CSRF token":
curl -s -k -X POST "https://<unraid-ip>/graphql" \
  -H "content-type: application/json" \
  -H "x-api-key: $API_KEY" \
  --data-raw '{"query":"query { info { os { platform } } }"}'

Observed behavior

{"errors":[{"message":"Invalid CSRF token","locations":[{"line":1,"column":9}],"path":["info"],"extensions":{"code":"UNAUTHENTICATED","originalError":{"message":"Invalid CSRF token","error":"Unauthorized","statusCode":401}}}],"data":null}

Repeated 4x back-to-back with identical headers — same result every time. Also reproduced on array { state } and docker { containers { names state status } }.

Expected behavior

A request authenticated via a valid x-api-key header should authenticate the same way regardless of which resolver/field is queried — guarded resolvers shouldn't additionally require a CSRF token that only makes sense for cookie/session-based auth.

Impact

This makes the GraphQL API effectively unusable for programmatic/automation use via API keys, since essentially every field that returns real data (info, array, docker, etc.) is guarded and hits this. Only fields with no guard (e.g. welcome) work.

Possibly related to the socket-path/CSRF issue described in https://product.unraid.net/p/7-3-1-connect-login-loop-from-unraid-api-socket-path-mismatch, which may be a regression carried into this beta.

🤖 Generated with Claude Code

Lingua principale
TypeScript
Stelle
113
Fork
23
Merge medio
1g 21h
PR unite (30g)
12

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di unraid/api

Tutte le issue di unraid/api

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.