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

Aberta Para iniciantes
#41,868 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
node.js, typescript
Domínio
backend, security

Direção de pesquisa

Comece no handler GET /api/artifact-wall/list e no gerador localRequest que ele usa. Leia como ServerConfig.host e os headers de HttpServerRequest são obtidos, e o que isLoopbackHostname aceita. Altere a verificação para derivar a localidade a partir da URL da requisição e da ausência de x-forwarded-for, x-forwarded-host e forwarded, deixando o bind em 0.0.0.0 intacto. Verifique com testes ou curl que requisições de loopback têm sucesso e que tokens inválidos resultam em 401, enquanto requisições não loopback e encaminhadas continuam recebendo 403.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
24.8k
Forks
6.4k
Merge médio
1h 27min
PRs com merge (30d)
530

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de pingdotgg/t3code

Todas as issues de pingdotgg/t3code

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.