Skip to content

Use CredentialsSnapshotTaker #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

bitwiseman
Copy link
Contributor

Description

#326 made GitHub App Credentials much more stable and tolerant of errors during transport. It also implemented an asymmetric design where a GitHubAppCredentials instance that has been serialize via a path other than XStream is not a fully functional GitHubAppCredentials instance. This is fine for controller to agent, but breaks for controller-to-controller transfer.

This change fixes that by using CredentialsSnapshotTaker and detecting whether where the new credential is landing on an agent.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify

@bitwiseman bitwiseman force-pushed the task/app-cred-snapshot branch 4 times, most recently from 762a261 to 1a87d31 Compare September 4, 2020 02:44
@bitwiseman bitwiseman force-pushed the task/app-cred-snapshot branch from 1a87d31 to 3f1668f Compare September 4, 2020 02:46
Copy link
Member

@amuniz amuniz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}
appInstallationToken = cachedToken.getToken();
LOGGER.log(Level.FINE, "Generating App Installation Token for app ID {0} on agent", getAppID());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This degrades security as now the agent has access to the private key.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I think there is a way to use CredentialsSnapshotTaker that retains the security benefits of the current code; would be a minor refinement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick
You mean like this #336 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has access to the private key

Also there is risk in the agent being able to select a different apiUrl: it could trick the controller into sending a “GitHub API” request to a malicious endpoint. I am not sure if it could actually mount a useful attack this way (since the controller would be sending a JWT not the original secret) but it is certainly unnerving and best avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants