Skip to content

[AUTOMATION] fix(clawpatch): address daily finding#270

Open
michiosw wants to merge 1 commit into
mainfrom
fix/clawpatch-daily-20260609T091435Z
Open

[AUTOMATION] fix(clawpatch): address daily finding#270
michiosw wants to merge 1 commit into
mainfrom
fix/clawpatch-daily-20260609T091435Z

Conversation

@michiosw

@michiosw michiosw commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Where We Are

The local Guard runtime accepts any existing socket parent directory under /tmp as long as os.MkdirAll succeeds. If that directory is a symlink or belongs to another uid, the daemon can remove and bind kontext.sock inside an untrusted path.

Where We Want To Go

The local Guard runtime should only bind its socket inside a real directory owned by the current user, with 0700 permissions. That keeps the Guard socket path under the same ownership rules as managed observe.

How do we get there

Mirror the managed-observe socket-directory checks in internal/localruntime.EnsureSocketDir: reject symlink parents, reject non-directories, require the current uid, and tighten permissions back to 0700 when needed. Add focused localruntime tests for writable-directory tightening, non-directory rejection, and symlink rejection. Verified with go 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, and git diff --check from the isolated checkout.

michiosw commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@michiosw michiosw force-pushed the fix/clawpatch-daily-20260609T091435Z branch from 3ef4f9c to 26e539e Compare June 9, 2026 09:34
@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR hardens Guard daemon startup and local runtime socket directory handling. The main changes are:

  • Bind the HTTP dashboard port before hook, judge, database, and socket startup.
  • Serve the dashboard with an explicit http.Server using the pre-bound listener.
  • Validate local runtime socket directory ownership, type, symlink status, and permissions.
  • Add regression coverage for occupied dashboard ports and socket directory checks.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The startup ordering change avoids mutating socket state after a dashboard bind failure.
  • The socket directory checks match the existing managed observe hardening pattern.

Important Files Changed

Filename Overview
internal/guard/cli/cli.go Moves dashboard TCP binding earlier and serves through the reserved listener.
internal/localruntime/socket.go Adds local runtime socket directory validation and permission tightening.

Reviews (1): Last reviewed commit: "fix(clawpatch): address daily finding" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant