Repository navigation
Harden private key handling, owner only file and no stdout or log exposure - #71
Open
quantova-inc wants to merge 2 commits into
Open
quantova-inc wants to merge 2 commits into
quantova-inc wants to merge 2 commits into
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.
This hardens how the generated RSA private key is handled. There are two changes.
First the private key file is created with owner only permissions. The previous plain open call used the process default which on a typical system is world readable or group readable. It now creates the file with mode 0600 using os.open so there is no window where it is world readable and it calls os.chmod to enforce 0600 when the file already exists.
Second the private key is no longer written to stdout or to the debug log. The tool printed the full private key to the console and emitted it to the logger at debug which places the key in terminal history and log files. It now prints and logs only the public key and reports the path where the private key was written. The public key handling is unchanged.
I verified the file is created at 0600 on a POSIX system and that the private key no longer appears in stdout or the log. I am happy to adjust for any Windows path you support.
For any follow up I can be reached at partnerships@Quantova.org.