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

Open Beginner friendly
#41,868 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
backend, security

Research direction

Start at the GET /api/artifact-wall/list handler and the localRequest generator it uses. Read how ServerConfig.host and HttpServerRequest headers are obtained, and what isLoopbackHostname accepts. Change the check to derive locality from the request URL plus absence of x-forwarded-for, x-forwarded-host and forwarded, leaving the 0.0.0.0 bind untouched. Verify with tests or curl that loopback succeeds (and bad tokens become 401), while non-loopback and forwarded requests still get 403.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
24.8k
Forks
6.4k
Avg merge
1h 13m
Merged PRs (30d)
584

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pingdotgg/t3code

All issues in pingdotgg/t3code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.