Skip to content

πŸ›‘οΈ Sentinel: Secure unix socket directory in /tmp#102

Open
minibota wants to merge 1 commit intomainfrom
security/nightly-2026-02-03-5406643230361454756
Open

πŸ›‘οΈ Sentinel: Secure unix socket directory in /tmp#102
minibota wants to merge 1 commit intomainfrom
security/nightly-2026-02-03-5406643230361454756

Conversation

@minibota
Copy link
Copy Markdown
Contributor

@minibota minibota commented Feb 3, 2026

πŸ” Issue: Non-root agents created socket files directly in /tmp when XDG_RUNTIME_DIR was 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 0660 socket permissions mitigated direct access).

πŸ› οΈ Fix:

  • Updated getSocketPath to use a private subdirectory: /tmp/cc-agent-<uid>/cc-agent.sock.
  • Implemented ensureSocketDir to strictly enforce directory existence, ownership (current user), and permissions (0700).
  • Added platform compatibility (skips permission bit checks on Windows).

πŸ§ͺ Tests:

  • Added TestEnsureSocketDir_Creation, TestEnsureSocketDir_Existing, TestEnsureSocketDir_BadPermissions.
  • Added TestGetSocketPath_Fallback.
  • Verified all tests pass with go test ./cmd/....

πŸ“Ž Notes: This change might affect users relying on the predictable /tmp/cc-agent-$USER.sock path, although cc-agent exec automatically resolves the correct new path.


PR created automatically by Jules for task 5406643230361454756 started by @minibota

…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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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