Repository navigation
Add --host and --allowed-host to codeburn web for authenticating reverse proxies - #1789
Open
MarcelRoozekrans wants to merge 1 commit into
Open
MarcelRoozekrans wants to merge 1 commit into
MarcelRoozekrans wants to merge 1 commit into
Conversation
…rse proxies The web dashboard only listens on 127.0.0.1 and refuses any Host or Origin that is not a loopback name, which keeps DNS rebinding and cross-site requests out. That also makes it unreachable behind a reverse proxy, even one that authenticates. --host sets the listen address, and --allowed-host names extra hostnames, matched exactly and case-insensitively against Host and Origin without the port. Without them the behaviour is unchanged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codeburn webonly listens on127.0.0.1, and its guard refuses anyHostorOriginthat isn't a loopback name. That is the right default, but it also makes the dashboard unreachable behind a reverse proxy, even one that authenticates: oauth2-proxy, Authelia, SSO forward auth. I run it on a headless VM and reach it through Traefik behind Keycloak, and today every proxied request gets a 403.--host <address>sets the listen address, default127.0.0.1.--allowed-host <name>is repeatable and adds exact hostnames. They are matched case-insensitively and without the port, against bothHostandOrigin. Without the flags nothing changes; with them, any other host or origin still gets a 403.isAllowedHostandisAllowedOrigin, with unit tests: loopback default, exact matching (dash.example.org.evil.exampleandevil-dash.example.orgare refused), Origin limited to http and https,nullrefused. There are also server tests that send a proxiedHost, an allowedOrigin, and refused ones.docs/web.mdgains a "Behind a reverse proxy" section saying the dashboard has no login, so the port should be firewalled to the proxy.Testing / Verification
node dist/cli.js web --no-open --port 4799 --allowed-host usage.roozekrans.nlon 30 days of Claude Code history and got:Host: 127.0.0.1:4799→ 200Host: usage.roozekrans.nl:8200→ 200, real payload of 33,463 callsHost: evil.example→ 403HostwithOrigin: https://evil.example→ 403npm testpasses: 5,216 pass, 1 fails. The failure istests/serve-stdio.test.ts, "reflects a single appended call on the poll after it", and it fails the same way on unchangedmainon this machine, so it isn't caused by this PR.tests/web-dashboard.test.ts: 9/9 pass.npm run buildsucceeds, andtsc --noEmitis clean.