Security: Use OS keychain or encryption for storing credentials in config file instead of plain text
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- go
- Domain
- authentication, cli, security
Research direction
Start in pkg/config/localconfig.go by tracing how AuthToken, RefreshToken, and ClientSecret are serialized to and loaded from the YAML configuration. Evaluate the proposed OS keychain integration and 0600 fallback, then verify that secrets are not stored in plain text and remain available in the loaded configuration.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Go
- Stars
- 59
- Forks
- 74
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 15
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microcks/microcks-cli
-
Malformed local configuration is silently accepted and can be overwrittenPossibly taken @aniket866 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microcks/microcks-cli#615 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microcks/microcks-cli#610 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
microcks/microcks-cli#608 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microcks/microcks-cli#606 ·
Maintainers usually reply within 1 day
-
Windows test failures in MockFileSystem.Walk due to path separatorPossibly taken @dipak0000812 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microcks/microcks-cli#601 · 1 comment ·
Maintainers usually reply within 1 day
All issues in microcks/microcks-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement tariffs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
evcc-io/evcc#35698 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day