Create ~/.aws/credentials at 0o600 (CWE-732 hardening)#944
Open
JAE0Y2N wants to merge 1 commit into
Open
Conversation
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.
What
When
grantedexports AWS credentials for the first time,pkg/cfaws/cred_exporter.go:22usesos.Create(credPath)which masks the mode through the current umask. On a stock Linux / macOS install (umask022), the new~/.aws/credentialsfile lands at0o644— world-readable.This PR swaps the call for
os.OpenFile(credPath, O_WRONLY|O_CREATE|O_TRUNC, 0o600), which sets the on-creation mode explicitly to owner-only (-rw-------). Same pattern aws-cli uses for the same file.Why
aws_access_key_id+aws_secret_access_keyin~/.aws/credentialsgrant full programmatic access scoped to that profile. On multi-user hosts (shared CI runners, multi-tenant servers, containers that mount the host's home dir), the umask-default0o644lets any other UID on the box read the keys.Existing credentials files are not touched — only newly-created ones get the tighter mode. No API surface change, no behavioral difference for the user.
How to verify
Before this PR:
-rw-r--r--. After this PR:-rw-------.Context
This was originally sent as a security disclosure via
security@commonfate.io, then re-routed throughfwdcloudsec@after the commonfate.* addresses started bouncing. Filing it as a public PR now since the project is open-source and the fix is small / defensive — no embargo concerns.Surface
One file, ~5 LOC of code + 5 lines of explanatory comment. No new dependencies.