Skip to content

security: tighten credentials directory perms and document storage#15

Merged
andreagrandi merged 1 commit into
masterfrom
security/credential-storage-review
May 18, 2026
Merged

security: tighten credentials directory perms and document storage#15
andreagrandi merged 1 commit into
masterfrom
security/credential-storage-review

Conversation

@andreagrandi
Copy link
Copy Markdown
Owner

Summary

Addresses #9 — review of credential storage and secret-redaction behavior.

Audit results: the existing posture is already solid. Credentials file is created with 0600, target config files (Claude, Codex, Gemini, OpenCode) are created with 0600, the TUI uses textinput.EchoPassword, the plain CLI uses term.ReadPassword, and no code path prints credential values back to the user (review and apply screens only show status/labels). No leaks were found.

This PR makes three small, targeted improvements:

  • Directory permissions are tightened on every store. writeAll now calls os.Chmod(dir, 0o700) after os.MkdirAll, so pre-existing ~/.config/mcp-wire/ directories with broader permissions (e.g. 0755 from another tool or an older mcp-wire) are corrected automatically.
  • New MaskSecret helper in internal/credential for safe credential display. Short values are fully masked (********); longer values reveal only the last four characters so a user can recognise a stored credential without disclosing it. Includes a "never leaks full value" test.
  • README.md gains a "Credential storage" section describing file location, the 0600/0700 permissions, resolution order (env → file → prompt), the plaintext caveat (no keychain integration), and how to remove stored credentials.

Tests cover both the directory permission tightening on new and pre-existing directories, and the masking helper.

Test plan

  • make fmt
  • make vet
  • make test — all packages pass, including 7 new tests under internal/credential

- Re-chmod the credentials directory to 0700 on every store so
  pre-existing directories with broader permissions are corrected, not
  only those created by mcp-wire.
- Add a MaskSecret helper with tests for safe credential display in
  future output paths.
- Document credential storage location, permissions, resolution order,
  and the plaintext caveat in README.

Refs #9
@andreagrandi andreagrandi merged commit 03a637c into master May 18, 2026
8 checks passed
@andreagrandi andreagrandi deleted the security/credential-storage-review branch May 18, 2026 20:34
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.

1 participant