π‘οΈ Sentinel: [CRITICAL] Fix symlink vulnerability in config permissions enforcement#277
π‘οΈ Sentinel: [CRITICAL] Fix symlink vulnerability in config permissions enforcement#277acebytes wants to merge 1 commit into
Conversation
β¦nforcement Co-authored-by: acebytes <2820910+acebytes@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. |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebfba5b032
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Enforce 0600 permissions safely, preventing symlink attacks | ||
| URL(fileURLWithPath: path).withUnsafeFileSystemRepresentation { pathPtr in | ||
| guard let ptr = pathPtr else { return } | ||
| let fd = open(ptr, O_RDONLY | O_NOFOLLOW) |
There was a problem hiding this comment.
Open config fd without requiring read permission
Opening autopilot.json with O_RDONLY | O_NOFOLLOW makes permission repair fail whenever the file exists but is not currently readable (for example mode 0200 or 0000), because open returns EACCES before fchmod can run. That causes the subsequent contents(atPath:) read to fail and the daemon to treat the config as broken, whereas the previous chmod(path, 0o600) path could recover these owner-mispermissioned files. This is a functional regression in config reload behavior for restricted-but-valid files.
Useful? React with πΒ / π.
chmodto enforce0600permissions on theautopilot.jsonconfig file. Becausechmodfollows symlinks, an attacker could replace the config file with a symlink to a sensitive system file, causing the daemon to alter its permissions.chmodwithopen(O_NOFOLLOW)andfchmod()to securely change permissions only if the path is not a symlink.O_NOFOLLOWand all existing tests pass.PR created automatically by Jules for task 1132927680054077846 started by @acebytes