API-key authenticated GraphQL queries fail with "Invalid CSRF token" on every guarded resolver (7.4.0-beta.3)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- graphql, typescript
- 領域
- api, authentication, security
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 113
- フォーク
- 23
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 12
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
unraid/api のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
Work Intent: File Manager integration for #1599対応中かも @elibosley が 5 日前に担当しました。 オープン
メンテナーはふだん 1 日以内に返信
-
Work Intent: Stop the temperature metrics query from spinning up array disks (#2017)対応中かも @elibosley が 15 日前に担当しました。 オープン
unraid/api#2090 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
siyuan-note/siyuan#20313 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
alunduil/projects-v2-sync#14 ·
-
Service process inherits the caller's cwd at first use, holding that folder open on Windows (EBUSY)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
DevTools page styles leak into the host app in development対応中かも @onmax が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nuxt-modules/better-auth#567 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信