fix: Enforce owner-only permissions on local files on POSIX#251
Merged
aviatco merged 11 commits intoJun 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Fabric CLI’s local security posture on POSIX systems by enforcing owner-only permissions for sensitive files (notably the MSAL token cache and log files), and adds tests to validate permission tightening behavior.
Changes:
- Added
restrict_existing_file()plusOWNER_ONLY_FILE_MODE/OWNER_ONLY_DIR_MODEconstants, and refactored restricted file/dir helpers to use them. - Tightened permissions for MSAL’s on-disk cache via
FabAuth.acquire_token()(including afinallyblock) and for log files/rotations in the logger. - Added POSIX-only tests covering permission tightening for pre-existing files and the auth cache file across success and error paths.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/fabric_cli/utils/fab_secure_io.py |
Introduces reusable permission constants and restrict_existing_file(), and refactors restricted file/dir creation to use them. |
src/fabric_cli/core/fab_auth.py |
Ensures MSAL cache file permissions are tightened before use and after token acquisition (finally). |
src/fabric_cli/core/fab_logger.py |
Tightens permissions for existing log files and rotated backups via restrict_existing_file(). |
src/fabric_cli/errors/auth.py |
Adds a centralized token_acquisition_failed() error-message helper. |
tests/test_utils/test_fab_secure_io.py |
Adds POSIX-only unit tests for restrict_existing_file() and write_restricted_file(). |
tests/test_core/test_fab_auth.py |
Adds POSIX-only tests verifying cache file permission tightening after token acquisition success/failure and updates an error-message assertion. |
.changes/unreleased/fixed-20260618-123845.yaml |
Adds changelog entry for the permission enforcement fix. |
ayeshurun
reviewed
Jun 21, 2026
ayeshurun
reviewed
Jun 21, 2026
ayeshurun
reviewed
Jun 21, 2026
Co-authored-by: Alon Yeshurun <98805507+ayeshurun@users.noreply.github.com>
ayeshurun
previously approved these changes
Jun 21, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ayeshurun
previously approved these changes
Jun 23, 2026
added 2 commits
June 23, 2026 07:53
…ithub.com/aviatco/fabric-cli into dev/aviatcohen/fixWorldReadablePermission
ayeshurun
approved these changes
Jun 23, 2026
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.
📥 Pull Request
✨ Description of new changes
This pull request enforces strict owner-only (0o600) permissions on all sensitive files managed by the CLI on POSIX systems, ensuring that files written to disk are never world-readable. It introduces a new utility function to tighten permissions on any pre-existing files, updates file and directory creation to consistently use secure permissions, and adds comprehensive tests to verify these behaviors. These changes significantly improve the security posture of the CLI regarding file access.
Security and Permissions Enforcement
restrict_existing_fileutility to ensure files are tightened to owner-only permissions (0o600) on POSIX, and refactored code to use this for all sensitive files, including authentication caches and log files. (src/fabric_cli/utils/fab_secure_io.py,src/fabric_cli/core/fab_auth.py,src/fabric_cli/core/fab_logger.py) [1] [2] [3] [4] [5] [6] [7] [8]OWNER_ONLY_FILE_MODE(0o600) andOWNER_ONLY_DIR_MODE(0o700) for consistent permission use across the codebase. (src/fabric_cli/utils/fab_secure_io.py)src/fabric_cli/utils/fab_secure_io.py)Testing
tests/test_core/test_fab_auth.py,tests/test_utils/test_fab_secure_io.py) [1] [2]Changelog
.changes/unreleased/fixed-20260618-123845.yaml)