API-key authenticated GraphQL queries fail with "Invalid CSRF token" on every guarded resolver (7.4.0-beta.3)
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
- Ambito
- api, authentication, security
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
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di unraid/api
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Work Intent: File Manager integration for #1599Forse già presa @elibosley l’ha presa 5 giorni fa. Aperta
unraid/api#2103 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Work Intent: Stop the temperature metrics query from spinning up array disks (#2017)Forse già presa @elibosley l’ha presa 15 giorni fa. Aperta
unraid/api#2090 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
farbenmeer/tapi#531 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
naver/egjs-flicking#971 ·
-
Renderer treats a sub-pixel width difference as a resize, which cancels the `motion()` entranceAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Tenant
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
MTES-MCT/Dossier-Facile-Frontend#2061 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
backnotprop/plannotator#1784 ·
I maintainer di solito rispondono entro 1 giorno