π‘οΈ Sentinel: Secure unix socket directory in /tmp#102
π‘οΈ Sentinel: Secure unix socket directory in /tmp#102
Conversation
β¦y in /tmp The previous implementation for non-root users fell back to creating the socket file directly in `/tmp`. This was vulnerable to pre-creation attacks (DoS) and potential race conditions in shared environments. This commit: - Changes `getSocketPath` to use a UID-namespaced subdirectory (`/tmp/cc-agent-<uid>/`) for non-root users. - Implements `ensureSocketDir` to enforce strict ownership (UID match) and permissions (0700) on the socket directory before binding. - Adds platform-specific logic (skipping strict permission checks on Windows). - Adds unit tests to verify directory security and fallback logic. This change ensures that the agent's socket is protected from unauthorized access or interference by other local users. Co-authored-by: minibota <1483356+minibota@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π Issue: Non-root agents created socket files directly in
/tmpwhenXDG_RUNTIME_DIRwas missing. This exposed the agent to Denial of Service (pre-creation) and race conditions in the shared temporary directory.π§ Risk: A local attacker could pre-create the socket file or directory to prevent the legitimate agent from starting, or potentially exploit race conditions to intercept connections (though
0660socket permissions mitigated direct access).π οΈ Fix:
getSocketPathto use a private subdirectory:/tmp/cc-agent-<uid>/cc-agent.sock.ensureSocketDirto strictly enforce directory existence, ownership (current user), and permissions (0700).π§ͺ Tests:
TestEnsureSocketDir_Creation,TestEnsureSocketDir_Existing,TestEnsureSocketDir_BadPermissions.TestGetSocketPath_Fallback.go test ./cmd/....π Notes: This change might affect users relying on the predictable
/tmp/cc-agent-$USER.sockpath, althoughcc-agent execautomatically resolves the correct new path.PR created automatically by Jules for task 5406643230361454756 started by @minibota