Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fixed insecure file creation permissions#391

Merged
acebytes merged 2 commits into
mainfrom
sentinel/fix-insecure-file-creation-11925611512342868902
Jun 16, 2026
Merged

πŸ›‘οΈ Sentinel: [HIGH] Fixed insecure file creation permissions#391
acebytes merged 2 commits into
mainfrom
sentinel/fix-insecure-file-creation-11925611512342868902

Conversation

@acebytes

Copy link
Copy Markdown
Contributor

🚨 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

Co-authored-by: acebytes <2820910+acebytes@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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 πŸ‘Β / πŸ‘Ž.

@acebytes

Copy link
Copy Markdown
Contributor Author

πŸ›‘οΈ Triage canonical β€” Security (P0)

This PR is the canonical fix for insecure-log-permissions / TOCTOU-symlink in Sources/Cacheout/Cleaner/CacheCleaner.swift. The following duplicate Sentinel PRs were closed in favor of this one: #268, #269, #272, #336, #342, #361, #365, #366, #376, #381.

Please review and merge or reject.

@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ›‘οΈ Triage canonical β€” Security (P0)

This PR is the canonical fix for insecure-log-permissions / TOCTOU-symlink in Sources/Cacheout/Cleaner/CacheCleaner.swift. The following duplicate Sentinel PRs were closed in favor of this one: #268, #269, #272, #336, #342, #361, #365, #366, #376, #381.

Please review and merge or reject.

Acknowledged. Standing by for review.

Co-authored-by: acebytes <2820910+acebytes@users.noreply.github.com>
@acebytes acebytes merged commit b400784 into main Jun 16, 2026
1 check passed
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