Conversation
On Windows, Unix permission modes (0600, 0700) are no-ops for access control. This introduces internal/fileutil with build-tagged implementations: thin wrappers on Unix, and DACL-setting variants on Windows that restrict owner-only files to the current user's SID. Updates 10 call sites across 8 files where sensitive data (OAuth tokens, email content, deletion manifests, attachments) is written with owner-only permissions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- restrictToCurrentUser now returns actual errors instead of swallowing them, making the function signature honest and letting callers decide - All callers (SecureWriteFile, SecureMkdirAll, SecureChmod, SecureOpenFile) log DACL failures as warnings but don't fail the operation - SecureMkdirAll now secures all intermediate directories created by os.MkdirAll, not just the leaf directory - Document the TOCTOU window in SecureOpenFile on Windows Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ky tests - Add CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE to directory DACLs so child files and subdirectories automatically inherit owner-only access - Secure os.MkdirTemp result in config.go with SecureChmod(0700) - Replace exact permission assertions with umask-tolerant helper that checks no extra bits are set beyond the requested mode Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…n tests - Apply SecureChmod(0700) to all MkTempDir return paths (preferred, system, and fallback), not just the fallback. Previously preferred and system temp dirs could inherit permissive ACLs on Windows. - Extract secureTempDir helper that logs warnings on failure instead of silently discarding errors. - Fix SecureOpenFile comment: DACL is intentionally applied whenever O_CREATE is set, not only for newly created files — all callers write sensitive data that should be owner-only. - Add assertTempDirSecured helper and permission checks to MkTempDir tests. - Make fallback test permission assertion umask-tolerant. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
|
This is weird: Claude told me the Windows cross-compilation was planned: ⏺ All tests pass. Now lint and cross-compile check. |
Owner
|
That is a little weird. just fixing the windows build issue, stand by |
The untyped constants NO_INHERITANCE, CONTAINER_INHERIT_ACE, and OBJECT_INHERIT_ACE default to int when assigned to a variable, but EXPLICIT_ACCESS.Inheritance is uint32. Use explicit type declaration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Unix permission modes (0600, 0700) used throughout the codebase are no-ops on Windows for access control. On a multi-user Windows machine, OAuth tokens, emails, and attachments are readable by other users.
Solution
Create internal/fileutil/ package with build-tagged implementations:
internal/fileutil/
Usage