security: tighten credentials directory perms and document storage#15
Merged
Merged
Conversation
- 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
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.
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 with0600, the TUI usestextinput.EchoPassword, the plain CLI usesterm.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:
writeAllnow callsos.Chmod(dir, 0o700)afteros.MkdirAll, so pre-existing~/.config/mcp-wire/directories with broader permissions (e.g.0755from another tool or an older mcp-wire) are corrected automatically.MaskSecrethelper ininternal/credentialfor 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.mdgains a "Credential storage" section describing file location, the0600/0700permissions, 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 fmtmake vetmake test— all packages pass, including 7 new tests underinternal/credential