Skip to content

nightshift/security: apply completeFileProtection to image snippet files#1

Open
perandre wants to merge 1 commit intomainfrom
nightshift/security-2026-04-09
Open

nightshift/security: apply completeFileProtection to image snippet files#1
perandre wants to merge 1 commit intomainfrom
nightshift/security-2026-04-09

Conversation

@perandre
Copy link
Copy Markdown
Owner

@perandre perandre commented Apr 9, 2026

Summary

Image snippets (screenshots pasted via ⌘V) are stored as PNG files in ~/Library/Application Support/Snippy/images/. These files were written with plain Data.write(to:) — no file-protection class — leaving them readable at the OS level while the device is locked, unlike snippets.json which already used .completeFileProtection.

Risk

A user who stores a screenshot of a password, token, or other sensitive content as an image snippet has that image accessible to any process with the same sandbox entitlements while the Mac is locked or in screensaver mode. The snippets.json was already guarded but image files were not, creating an inconsistent protection boundary.

Fix

  • addImage(_:) now writes with options: [.atomic, .completeFileProtection] (matching the pattern used for snippets.json)
  • Each image file immediately gets 0o600 POSIX permissions after write
  • The images/ directory itself is set to 0o700 in init(), matching snippyDir

No logic changes — purely write-option additions.

Verification

Review the two changed call sites in SnippetStore.swift:

  1. init() — added setAttributes([.posixPermissions: 0o700], …imagesDir)
  2. addImage(_:)pngData.write(to: fileURL, options: [.atomic, .completeFileProtection]) + setAttributes([.posixPermissions: 0o600], …)

Image snippets could contain screenshots of sensitive content.
The snippets.json was already protected with .completeFileProtection
but the per-image PNG files in the images/ subdirectory were not,
leaving them readable while the device is locked.

Apply .completeFileProtection to each PNG immediately after writing it,
and tighten the images/ directory itself to 0700 (matching snippyDir).
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