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

Aperta Adatta ai principianti
#41,868 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, security

Direzione di ricerca

Inizia dal gestore GET /api/artifact-wall/list e dal generatore localRequest che utilizza. Leggi come vengono ottenuti ServerConfig.host e gli header di HttpServerRequest, e cosa accetta isLoopbackHostname. Modifica il controllo in modo da derivare la località dall'URL della richiesta e dall'assenza di x-forwarded-for, x-forwarded-host e forwarded, lasciando invariato il bind su 0.0.0.0. Verifica con test o curl che le richieste loopback abbiano successo e che i token non validi restituiscano 401, mentre le richieste non loopback e inoltrate continuino a ricevere 403.

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

Descrizione

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.

Lingua principale
TypeScript
Stelle
24.8k
Fork
6.4k
Merge medio
1h 27m
PR unite (30g)
530

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 pingdotgg/t3code

Tutte le issue di pingdotgg/t3code

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.