matcha
matcha copied to clipboard
BUG: Unchecked os.Chmod() error leaves daemon socket permissions vulnerable
Describe the bug In daemon/daemon.go line 100, os.Chmod() is called to set socket permissions but the error return is completely ignored. If chmod fails, the socket could remain with default permissions (potentially world-readable) instead of owner-only (0700), creating security risk.
To reproduce
- Examine daemon/daemon.go lines 95-100:
if err != nil {
return fmt.Errorf("listen: %w", err)
}
defer d.listener.Close()
// Set socket permissions (owner only).
os.Chmod(sockPath, 0700) // Error completely ignored
- Observe error is not checked or handled
Expected behavior Error from os.Chmod() should be checked and handled. If setting permissions fails, daemon should either:
- Return error and abort startup (safer)
- Log warning about permission failure
Additional context
- Security-sensitive: daemon socket permissions protect local RPC communication
- Good first issue: simple error check addition
- In contrast, main.go lines 3201, 3233, 3242 DO check chmod errors correctly
- Similar unchecked os.Remove() exists at line 89
Suggested fix:
// Set socket permissions (owner only).
if err := os.Chmod(sockPath, 0700); err != nil {
return fmt.Errorf("failed to set socket permissions: %w", err)
}
OS Linux (affects Unix-like systems with file permissions)
This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.