fix: keychain stores -U flag as password instead of actual secret#21
Merged
Conversation
…oses #18) Move -U (update) flag before -w in the security add-generic-password command so -w is the last argument and correctly reads the password from stdin. Previously -U followed -w, causing macOS security to interpret -U as the password value. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kaushalpaneri
commented
Mar 23, 2026
kaushalpaneri
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review Summary
| # | Severity | Category | Finding |
|---|---|---|---|
| — | — | — | No findings |
All 15 CI checks pass. One-line fix with regression test.
Code Review: The fix correctly moves -U (update flag) before -w in the security add-generic-password command. With -w as the last argument, macOS security reads the password from stdin as intended. The regression test verifies both that -w is last and that -U precedes it.
Security Review: This fix resolves a security-relevant data loss bug — secrets were silently discarded. No new attack surface introduced.
Documentation Review: No doc changes needed for an internal bug fix.
Verdict: APPROVE — clean fix, well-tested regression guard.
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
Fixes #18. The
security add-generic-passwordcommand had-wfollowed by-U, causing macOS to interpret-Uas the password value instead of reading the actual secret from stdin. Moved-Ubefore-wso-wis the last argument and correctly reads from stdin.Changes
Source
src/crux_cli/secrets.py: Reordered flags inMacOSKeychainBackend.set()— moved-Ubefore-wso the password is read from stdin, not interpreted as the literal string "-U"Tests
tests/unit/test_secrets_backends.py: Addedtest_keychain_set_w_flag_is_lastregression test that verifies-wis the last argument and-Uprecedes itDocs
No doc changes
Config
No config changes
Breaking Changes
None
Security Considerations
This fix ensures secrets are correctly stored in the macOS keychain. Previously, the actual secret was silently discarded and
-Uwas stored instead — a security-relevant data loss bug.Test Plan
uv run pytest tests/unit/ -v) — 368 passeduv run pytest tests/integration/ -v)uv run ruff check src/ tests/)Closes #18
🤖 Generated with Claude Code