[spark-compete] fix: set restrictive permissions on generated .env files#693
Open
ifeoluwaaj wants to merge 1 commit into
Open
[spark-compete] fix: set restrictive permissions on generated .env files#693ifeoluwaaj wants to merge 1 commit into
ifeoluwaaj wants to merge 1 commit into
Conversation
Root cause: write_generated_env() and write_env_file() create .env files containing secrets (API keys, tokens) without setting restrictive file permissions. The files inherit the default umask, which typically allows world-readable permissions. Fix: Added os.chmod(path, 0o600) after write_text in both functions to ensure .env files are only readable by the owner. This prevents other users on the system from reading sensitive credentials. Risk notes: - chmod 0o600 is the standard security practice for secret files - Both functions already exist and are in use; this is a security hardening change only - os is already imported in both files - No functional behavior changes beyond file permissions
3 tasks
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.
spark-compete Packet
Team: Sequence
Bug Summary
Generated .env files containing secrets are created with default umask permissions, making them world-readable on multi-user systems.
Root Cause
Generated .env files containing secrets are created with default umask permissions, making them world-readable on multi-user systems.
Fix
Added os.chmod(path, 0o600) after write_text in write_generated_env() and write_env_file()
Before (The Bug)
Generated .env files containing secrets are created with default umask permissions, making them world-readable on multi-user systems.
After (The Fix)
Fix prevents the issue from occurring.
Testing
Verified: generated .env files now have 0o600 permissions
Before (The Bug)
After (The Fix)
Files Changed
src/spark_cli/cli.py, src/spark_cli/sandbox/access.py
Duplicate Notes
No existing PR covers this specific issue. This fix addresses a distinct bug not covered by other submissions.
Risk Notes
Minimal risk - security hardening only. 0o600 is standard for secret files. Existing files retain old permissions until rewritten.