Security Fix: Restrict file permissions in file_tracker.go (Alert #378) #8950
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.
Security Fix: Incorrect Default Permissions in File Tracker
Alert Number: #378
Severity: Medium
Rule: G306 - Expect WriteFile permissions to be 0600 or less
File: pkg/cli/file_tracker.go:158
Vulnerability Description
The security scanner identified that files being restored during rollback operations were written with overly permissive permissions (0644). This violates the principle of least privilege and could expose file contents to unauthorized users on shared systems.
With 0644 permissions (rw-r--r--), files are:
This is unnecessary for workflow files that should only be accessible to the owner.
Fix Applied
Changed file permissions from 0644 to 0600 in the
RollbackModifiedFilesfunction at line 159.Before:
After:
With 0600 permissions (rw-------), files are:
Security Best Practices Applied
Files Affected
This fix applies to:
Testing
go build ./pkg/cli/...Impact Assessment
Risk: Low
Breaking Changes: None
Backwards Compatibility: Full
Performance: No impact
Files restored during rollback operations remain fully functional with more restrictive permissions. The rollback functionality is performed by the same user who created the files, so the tighter permissions do not affect functionality.
References
🤖 Generated by Security Fix Agent in workflow run 20701728409