π‘οΈ Sentinel: [HIGH] Fixed insecure file creation permissions#391
Conversation
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: 4e4191f5d5
βΉοΈ 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".
| handle.closeFile() | ||
| let fd = logFile.withUnsafeFileSystemRepresentation { pathPtr -> Int32 in | ||
| guard let pathPtr = pathPtr else { return -1 } | ||
| return open(pathPtr, O_CREAT | O_WRONLY | O_APPEND | O_NOFOLLOW | O_CLOEXEC, 0o600) |
There was a problem hiding this comment.
Chmod existing cleanup logs before appending
When cleanup.log already exists, which is the normal upgrade path from releases that created it via String.write using the process umask, this appends successfully but the 0o600 mode passed to open is ignored because it only applies when O_CREAT creates a new file. That leaves previously-created, potentially world-readable cleanup histories readable after this security fix; set the permissions on the opened fd/path, e.g. with fchmod(fd, 0o600), before writing.
Useful? React with πΒ / π.
| let logDir = FileManager.default.homeDirectoryForCurrentUser | ||
| .appendingPathComponent(".cacheout") | ||
| try? FileManager.default.createDirectory(at: logDir, withIntermediateDirectories: true) | ||
| try? FileManager.default.createDirectory(at: logDir, withIntermediateDirectories: true, attributes: [.posixPermissions: 0o700]) |
There was a problem hiding this comment.
Verify the log directory before trusting it
When ~/.cacheout already exists as a symlink or as a directory with unsafe permissions, this best-effort creation does not prove that the app is using a private real directory, and the later open(... O_NOFOLLOW ...) still follows symlinked parent components. In that setup the cleanup log is created/appended in the symlink target, so the symlink hardening can still write outside the intended state directory; validate/chmod the existing directory or use an openat flow that refuses symlinked parents before opening the file.
Useful? React with πΒ / π.
|
π‘οΈ Triage canonical β Security (P0) This PR is the canonical fix for insecure-log-permissions / TOCTOU-symlink in Please review and merge or reject. |
Acknowledged. Standing by for review. |
Co-authored-by: acebytes <2820910+acebytes@users.noreply.github.com>
π¨ Severity: HIGH
π‘ Vulnerability: Fixed insecure file creation permissions.
π― Impact: Fixed insecure file creation permissions.
π§ Fix: Fixed insecure file creation permissions.
β Verification: Code review to verify secure POSIX flags.
Please note: This PR is marked as high priority for review.
PR created automatically by Jules for task 11925611512342868902 started by @acebytes