🛡️ Sentinel: Secure socket directory creation to prevent pre-creation and symlink attacks#106
🛡️ Sentinel: Secure socket directory creation to prevent pre-creation and symlink attacks#106
Conversation
…attacks 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: The daemon created the Unix socket in a shared
/tmpdirectory (fallback) with a predictable name, allowing local attackers to pre-create the socket (DoS) or potentially hijack connections. The original fix attempt introduced a TOCTOU race condition.🧠 Risk: A local attacker could prevent the agent from starting or potentially intercept execution reports.
🛠️ Fix:
/tmp/cc-agent-<euid>/cc-agent.sock.ensureSocketDirwith robust security checks:MkdirAllto minimize TOCTOU window.os.Lstatto detect symlinks.verifySocketDirOwnershipto ensure directory is owned by the current user (preventing "confused deputy").0700permission enforcement.🧪 Tests:
TestGetSocketPath_SecureFallbackto verify path structure.TestEnsureSocketDirto verify permission enforcement.TestEnsureSocketDir_SymlinkAttackto verify symlink rejection.This PR was created by an automated nightly security task.
PR created automatically by Jules for task 12974733664033318369 started by @minibota