[AUTOMATION] fix(clawpatch): restrict guard daemon to loopback#245
[AUTOMATION] fix(clawpatch): restrict guard daemon to loopback#245michiosw wants to merge 1 commit into
Conversation
Greptile SummaryThis PR restricts the Guard daemon bind address to local-only values. The main changes are:
Confidence Score: 4/5This is close, but the localhost validation gap should be fixed before merging.
|
| Filename | Overview |
|---|---|
| internal/guard/cli/cli.go | Adds daemon bind-address validation before startup continues. |
| internal/guard/cli/cli_test.go | Adds unit coverage for accepted loopback and rejected non-loopback daemon addresses. |
Reviews (1): Last reviewed commit: "fix(clawpatch): restrict guard daemon to..." | Re-trigger Greptile
| if strings.EqualFold(host, "localhost") { | ||
| return nil |
There was a problem hiding this comment.
Resolve localhost before accepting
This branch accepts localhost without checking what address it resolves to, then runDaemon passes the original host string to ListenAndServe. If a local resolver or hosts file maps localhost to a non-loopback interface, kontext guard start --addr localhost:4765 passes this guard and can still expose the unauthenticated dashboard/API off-machine. Resolve localhost and verify the resolved bind addresses are loopback, or normalize it to a known loopback literal before listening.

Where We Are
Guard accepts any --addr or KONTEXT_ADDR value today. If someone starts it on 0.0.0.0:4765, the unauthenticated dashboard and API become reachable off-machine.
Where We Want To Go
Guard should stay local-only by default. The daemon must reject non-loopback bind addresses before it starts listening.
How do we get there
Add loopback-only address validation in
runDaemonand cover accepted and rejected addresses with focused CLI tests. Verified withgo test ./...,go vet ./...,npm exec --yes --package pnpm@10.0.0 -- pnpm install --frozen-lockfile,npm exec --yes --package pnpm@10.0.0 -- pnpm --dir web/guard-dashboard typecheck, andgit diff --check.