-
Notifications
You must be signed in to change notification settings - Fork 971
Open
Open
Copy link
Description
Feature Request: Secure Token Storage in OS Keyring
Problem
Currently, the Coder CLI stores authentication tokens in plaintext configuration files, which poses a security risk. Users' tokens are stored unencrypted and can be easily accessed by other processes or users with file system access.
Proposed Solution
Implement secure token storage using the OS keyring with graceful fallback to file storage when keyring is unavailable.
Acceptance Criteria
-
CLI should by default store the token in the OS keyring using a library like zalando/go-keyring
- Keychain on macOS
- GNOME Keyring on Linux (Secret Service dbus interface)
- Wincred on Windows
-
CLI should fallback to storing the token in text file if the keyring is not available
- Maintain backward compatibility
- Ensure minimal disruption if keyring operations fail
- Log appropriate warnings when falling back to file storage
-
Address security considerations from GitHub CLI's keyring implementation discussion:
- Consider the security implications of using
zalando/go-keyring
which shells out to thesecurity
command on macOS - On macOS, this grants access to the
security
binary rather than the specific application, which can weaken the security model - Document this limitation and consider future improvements to use native APIs
- Despite this limitation, keyring storage is still significantly more secure than plaintext files
- Consider the security implications of using
Implementation Considerations
- Library Choice: Use
zalando/go-keyring
for pure Go implementation without CGO requirements - Migration: Handle existing plaintext tokens gracefully during the transition
- Error Handling: Robust fallback mechanism when keyring operations fail
- Cross-platform: Ensure consistent behavior across macOS, Linux, and Windows
- User Experience: Minimal prompts and clear messaging about keyring access
- Testing: Comprehensive tests for both keyring and fallback scenarios
Security Benefits
- Tokens encrypted at rest using OS-provided security mechanisms
- Reduced risk of accidental token exposure in config files
- Better integration with enterprise security policies
References
matifali and bpmct