microcks / microcks/microcks-cli
Security: Use OS keychain or encryption for storing credentials in config file instead of plain text
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 52
- Fork
- 68
- Merge medio
- 6h 54m
- PR unite (30g)
- 10
Descrizione
Describe the bug
Following up on a comment from https://github.com/microcks/microcks-cli/issues/503#issuecomment-5312648283 by @Harsh4902, the CLI currently stores credentials in the local configuration file in plain text.
Specifically, looking at pkg/config/localconfig.go, the LocalConfig struct stores AuthToken and RefreshToken inside the User struct, and ClientSecret inside the Auth struct. These are serialized directly to a YAML file (typically ~/.config/microcks/config).
If the file permissions on the config file are not strictly locked down, or if a malicious script gets read access to the user's home directory, these credentials can be easily stolen.
Expected behavior
CLI tools typically avoid storing access tokens, refresh tokens, and client secrets in plain text. Instead, we should consider:
- Using the operating system's native secure keystore/keychain (e.g., macOS Keychain, Windows Credential Manager, Linux Secret Service) using a library like zalando/go-keyring or 99designs/keyring.
- As a fallback, strictly enforcing
0600permissions on the config file so that only the file owner can read it (though native keystore is much preferred).
Actual behavior
No response
How to Reproduce?
No response
Microcks version or git rev
No response
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
No response
Additional information
Proposed Solution
- Integrate a keychain library like
github.com/zalando/go-keyring. - When saving a configuration (in
pkg/config/localconfig.go), extractAuthToken,RefreshToken, andClientSecretfrom the struct. - Save these extracted secrets securely into the OS keychain, using the server name or user context as the service key.
- Replace the struct values with a placeholder (e.g.,
keychain-stored) before writing the remaining configuration to the YAML file. - When reading the configuration, dynamically fetch the secrets from the keychain back into the struct.
Impact
Storing credentials securely will prevent local token theft and align microcks-cli with industry best practices for CLI security.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in pkg/config/localconfig.go tracciando il modo in cui AuthToken, RefreshToken e ClientSecret vengono serializzati nella configurazione YAML e caricati da essa. Valuta l'integrazione proposta con il portachiavi del sistema operativo e il fallback 0600, quindi verifica che i segreti non vengano memorizzati in testo in chiaro e rimangano disponibili nella configurazione caricata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- Ambito
- authentication, cli, security
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100