Skip to content

fix(config): protect credentials before writing configuration - #369

Merged
overtrue merged 1 commit into
mainfrom
overtrue/fix-config-permissions
Sep 9, 2026
Merged

fix(config): protect credentials before writing configuration#369
overtrue merged 1 commit into
mainfrom
overtrue/fix-config-permissions

Conversation

@overtrue

@overtrue overtrue commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #357.

ConfigManager::save previously wrote alias credentials before tightening file permissions. An interrupted or failed write could leave the configuration readable by other local users.

Create new Unix configuration files with mode 0600 and tighten existing files through the opened file handle before truncating or writing. Add regression coverage that forces writes to fail under a permissive umask, checks both new and existing files, and verifies that shorter configuration updates remove stale trailing content.

Protected-file review — BREAKING marker required by repository policy: this permission fix touches crates/core/src/config.rs. The configuration schema remains at version 1, existing files remain compatible, and no data migration is needed.

Validation on macOS:

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace — 2,649 passed, 2 ignored
  • The permission regression fails against the original implementation and passes with the fix.

@overtrue
overtrue merged commit 0c25223 into main Sep 9, 2026
17 checks passed
@overtrue
overtrue deleted the overtrue/fix-config-permissions branch September 9, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config.toml containing alias credentials is created world-readable (0644) and chmod'd to 0600 only afterwards

1 participant