Prevent cli from sending git credentials#1988
Merged
JakeDawkins merged 2 commits intomasterfrom Jun 8, 2020
Merged
Conversation
Contributor
Author
|
This PR went through internal discussion and reviews, which is why none of that shows up in this PR :) |
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 PR aims to fix a security issue where the CLI would send some users' git credentials to Apollo Graph Manager (AGM).
Once the changed in this PR is released, we recommend all users upgrade to the newest version of the CLI to prevent sending any unnecessary sensitive information.
Issue description
Apollo Graph Manager attempts to link back to a PR or a repository on GitHub or BitBucket from the Graph Manager's history page. This url comes from the CLI, who reports the git remote url. This was coming from running the equivalent of
git ls-remote --get-urlwith the git-rev-sync package.We realized that this git remote can in certain circumstances (mostly BitBucket setups using a
gitlab-ci-tokenuser) contain a git user and/or password.Prior to realizing this, we weren't taking any effort on the CLI or backend services to sanitize these urls properly, and we were unintentionally storing this information.
The fix for the CLI
This PR aims to sanitize all git urls on the CLI before being sent to the backend. We now replace git usernames/passwords that are found with
REDACTEDprior to reporting. In addition to that, any URLs with sources that are unsupported by Graph Manager (i.e. not GitHub or BitBucket) are just removed and not reported. These changes have been accompanied by a test suite.The fix in Apollo Graph Manager
Before releasing this PR publicly, we have already changed the Graph Manager servers to perform the same sanitization on its input, and we have (conservatively) removed all git URLs from our databases and database backups that were sent to us before this server change was deployed. This means that users on older versions of the CLI may still send us git credentials but we will not save them persistently.
TODO:
*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.