Coding-agent terminals never connect when the apps host is 32 characters or longer (ttyd --check-origin)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 49/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- go, helm, kubernetes
- Domain
- backend, networking
Research direction
Start with the four ttyd templates at deploy/helm/javo/files/templates/{pi,claude-code,herdr,terminal}.yaml and the gateway origin check at internal/gateway/proxy/proxy.go:650. Check how NetworkPolicy restricts access to app pods, then assess removing --check-origin and adding a gateway test with an apps host of at least 32 characters. Done when terminals connect through the gateway and the regression test covers the long-host case.
Written by the indexing model from the issue text.
Description
On a NIC cluster on AWS, every coding-agent terminal showed "Press Enter to Reconnect" and never connected. ttyd logged this on each attempt:
refuse to serve WS client from different origin due to the --check-origin option.
User code denied connection
The apps host there was javo-apps.int-hub-dev.openteams.dev, which is 35 characters. ttyd 1.7.7 with --check-origin refuses any websocket whose Origin host is 32 characters or longer, even when Host matches it exactly. The pi, claude-code, herdr and terminal templates all pass that flag (deploy/helm/javo/files/templates/{pi,claude-code,herdr,terminal}.yaml).
Repro
I bypassed the gateway, port-forwarded straight to a pi pod's ttyd on 7681, and sent a websocket handshake with Host: H and Origin: https://H:
| Host length | Result |
|---|---|
| 4, 22, 28, 29, 30, 31 | 101 Switching Protocols |
| 32, 33, 35, 38 | connection refused, same log line |
The gateway is not involved. It keeps Host as is (internal/gateway/proxy/proxy.go:309), and its own same-origin check (foreignOrigin, proxy.go:650) passes for the same request.
Why
check_host_origin in ttyd 1.7.7 (src/protocol.c) parses the Origin header in place with lws_parse_uri, which leaves address pointing inside buf, and then runs sprintf(buf, "%s", address). Source and destination overlap, which is undefined behaviour. A 32-byte limit fits a copy routine that moves 32 bytes at a time and only goes wrong past that. This is inferred from the code and the measured limit. Patching in a separate buffer and re-running the table above would confirm or rule it out. ttyd main swapped sprintf for snprintf (tsl0922/ttyd@e2819f2), which still overlaps, so upgrading ttyd may not fix it. tsl0922/ttyd#1566 is a different --check-origin failure (HTTP/2).
Who hits it
Anyone whose apps host is 32 characters or longer. javo-pack defaults to javo-apps.<domain> (values.yaml:164), so that's every domain of 22 characters or more. The Hetzner deploy at javo-apps.nebari.openteams.app is 30, which is why it works there.
Workaround today: an apps host of 31 characters or fewer. On the AWS cluster apps.int-hub-dev.openteams.dev (30) fixed it, and the pi terminal connected and answered.
What I think we should do
Drop --check-origin from the four templates. The gateway already refuses a websocket from a foreign origin before it reaches the app, and with NetworkPolicy enforced (allow-gateway-only in javo-apps) only the gateway can reach app pods, so ttyd's own check adds nothing we rely on. A test that opens an agent terminal through the gateway with a long apps host would keep this from coming back. Separately, we should report the overlap upstream to ttyd.
- Dominant language
- Go
- Stars
- 5
- Forks
- 0
- Avg merge
- 21h 13m
- Merged PRs (30d)
- 53
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nebari-dev/tapas
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
nebari-dev/tapas#124 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nebari-dev/tapas#121 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nebari-dev/tapas#32 ·
Maintainers usually reply within 1 day
-
Suggest saving a memory when a chat message holds something worth rememberingPossibly taken @jbouder claimed this today. Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
nebari-dev/tapas#137 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 54/100
nebari-dev/tapas#136 ·
Maintainers usually reply within 1 day
All issues in nebari-dev/tapas
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
prime-radiant-inc/evener#8335 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Docker healthcheck logs a 500 on every checkPossibly taken @zackwag claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
writefreely/writefreely#1801 ·
Maintainers usually reply within 2 days
-
BUG: Backend Docker build fails due to Go version mismatchPossibly taken @Aakriti0207 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 93/100
gittuf/visualizer#203 ·
Maintainers usually reply within 2 days
-
contribution Windows 主机
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Lee-xeo/Claude-Cage#1519 ·
Maintainers usually reply within 1 day