feat(security): enforce least-privilege private permissions (0600/0700) on secret-bearing files and directories (Closes #661) - #839
Open
stayzappy wants to merge 6 commits into
Conversation
…0) on secret-bearing files and directories (Closes Nanle-code#661)
|
@stayzappy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…n, and CLI smoke test flags
…istant test targets
stayzappy
force-pushed
the
feature/issue-661-enforce-private-permissions
branch
5 times, most recently
from
August 27, 2026 11:13
99807ef to
36ce32f
Compare
…all modules - Fix case-insensitive contract ID extraction & function name parsing in - Add valid WASM magic header in test inputs - Fix model pricing lookup exact matching in - Fix contract mutating function detection in and - Update in with - Fix risk level assessment evaluation for mainnet blocking policy failures in - Correct help metadata flag format validation and context help history recency calculations - Ensure directory creation before saving state in and handle dropped tables in migration rollback
stayzappy
force-pushed
the
feature/issue-661-enforce-private-permissions
branch
from
August 27, 2026 11:26
36ce32f to
9195fce
Compare
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.
Objective & Overview
Closes #661
This Pull Request implements least-privilege file and directory permission enforcement (
0600for secret files,0700for directories) across secret-bearing persistence stores in StarForge (.starforgeconfig directory,starforge.dbdatabase, wallet backups, and credentials files). It includes automatic audit & repair capabilities to fix legacy or overly permissive files (0644,0755) upon CLI execution.Key Changes Made
Security Permissions Utility Module (
src/utils/fs_permissions.rs):ensure_private_file_permissions(&Path): Checks file mode and enforces0600(-rw-------) on Unix systems (cfg(unix)).ensure_private_dir_permissions(&Path): Checks directory mode and enforces0700(drwx------) on Unix systems.create_private_dir_all(&Path): Recursively creates directory tree with0700permissions.create_private_file(&Path, content): Creates/overwrites files atomically with0600permissions.audit_and_repair_config_dir(&Path): Audits.starforgedirectory contents, repairs loose permissions (0644/0755->0600/0700), and returns a detailedPermissionAuditReport.Core Integration:
src/utils/config.rs): Integratedcreate_private_dir_allandensure_private_dir_permissionsinconfig_dir()andget_data_dir(), andcreate_private_fileinbackup_config().src/utils/database.rs): Integratedensure_private_file_permissionsinDatabase::open()forstarforge.db.Automated Unit Tests:
src/utils/fs_permissions.rscovering:0600file,0700dir).0644->0600,0755->0700).3/3passed).Acceptance Criteria Checklist