[Bug]: Artifact wall always 403s on desktop because the server binds 0.0.0.0

オープン 初心者向け
#41,868 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
backend, security

調査の方向性

GET /api/artifact-wall/list ハンドラと、それが使用する localRequest ジェネレーターから始めてください。ServerConfig.host と HttpServerRequest のヘッダーがどのように取得されているか、また isLoopbackHostname が何を受け入れるかを読んでください。ローカル判定を、リクエストURLと x-forwarded-for、x-forwarded-host、forwarded が存在しないことから導出するようにチェックを変更してください。0.0.0.0 へのバインドは変更しないでください。ループバックのリクエストが成功し、不正なトークンが 401 になること、また非ループバックおよび転送されたリクエストが引き続き 403 を受け取ることを、テストまたは curl で検証してください。

索引モデルが issue の本文から書いたものです。

説明

needs more info

What happens

The artifact panel shows Artifacts 0 and This connection can’t read artifacts. (Chinese UI: 此连接无权读取产物). Retry does nothing. The artifacts exist; the list endpoint rejects every request before it checks the token.

Environment

  • App: T3 Code (Nightly), bundle id com.t3tools.t3code
  • Version: 0.1.11-nightly.20261122.4761 (CFBundleShortVersionString 1.2.3)
  • macOS, Apple Silicon
  • Server listen address: *:3773 (lsof on the desktop process)

Reproduction

From the same machine, with the desktop app running:

curl -sS -D - -o /tmp/aw.txt \
  "http://127.0.0.1:3773/api/artifact-wall/list?threadId=any&scope=thread"
# HTTP/1.1 403 Forbidden, empty body

curl -sS -D - -o /dev/null \
  -H "Authorization: Bearer not-a-real-token" \
  "http://127.0.0.1:3773/api/artifact-wall/list?threadId=any&scope=thread"
# still HTTP 403, not 401

Both This thread and This project in the panel hit this endpoint (scope=thread and scope=project) and stop at the same 403.

Cause

Desktop startup sets the server host to all interfaces:

host: "0.0.0.0"

GET /api/artifact-wall/list returns 403 immediately when localRequest is false:

const localRequest = gen(function* () {
  const config = yield* ServerConfig;
  const request = yield* HttpServerRequest;
  const url = toURL(request);
  return isLoopbackHostname(config.host ?? "127.0.0.1")
    && Boolean(request.headers.host)
    && isSome(url)
    && isLoopbackHostname(url.value.hostname)
    && !request.headers["x-forwarded-for"]
    && !request.headers["x-forwarded-host"]
    && !request.headers.forwarded;
});

isLoopbackHostname only accepts 127.0.0.1, ::1, and localhost. 0.0.0.0 fails that check, so a request to http://127.0.0.1:3773 is refused before authenticateRawRouteWithScope runs. A missing or bad token therefore never becomes a 401.

The panel maps every 403 from this route to This connection can’t read artifacts. EnvironmentScopeRequiredError uses the same status, so a real missing orchestration:read scope and this bind-address mismatch look identical.

Expected

A request whose URL hostname is loopback, with no forwarded headers, should be allowed to list artifacts on the desktop app. Listening on 0.0.0.0 should stay as it is, so remote pairing still works. A non-loopback client, or a request that carries X-Forwarded-For / Forwarded, should still be rejected.

Suggested check: decide localRequest from the request URL and the forwarded headers, not from config.host.

主要言語
TypeScript
スター
24.8k
フォーク
6.4k
平均マージ
1時間 27分
マージ済み PR(30日)
530

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pingdotgg/t3code のほかの issue

pingdotgg/t3code の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。