Skip to content
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

Fix: Unauthorized users can be allowed to view the private pipeline if the logged-in user's scmContext and the pipeline's scmContext are different (scm-github) #194

Merged
merged 1 commit into from
Nov 13, 2021

Conversation

yoshwata
Copy link
Contributor

@yoshwata yoshwata commented Nov 12, 2021

Context

If multiple ghe instances are available from Screwdriver.cd, you may be able to see private pipelines that shouldn't be visible.

For example, if you have the following ghe instances:

  • ghe-a
  • ghe-b

Create a private pipeline private-1 on ghe-b. In this case, the user logged in to the Screwdriver in the context of ghe-b will not be able to view private-1. This access is 404 because this user's privileges cannot look up the target pipeline.

The problem occurs when the user's login context is ghe-a. The lookUpScmUri function does not take into account the pipeline's scmContext at all and uses the user's login context to get the repository information. Therefore, although the repository id is the same as private-1, the destination is ghe-a. Since this meaningless repository is public, you can see what you shouldn't be able to see after passing authentication.

Objective

Check the user's login context just before hitting the API to look up GHE. Accessing a GHE instance in a different context is meaningless and throws an error.

References

PR for scm-gitlab
screwdriver-cd/scm-gitlab#46

License

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@yoshwata yoshwata changed the title Fix: Unauthorized users can be allowed to view the private pipeline if the logged-in user's scmContext and the pipeline's scmContext are different, Fix: Unauthorized users can be allowed to view the private pipeline if the logged-in user's scmContext and the pipeline's scmContext are different Nov 12, 2021
@yoshwata yoshwata changed the title Fix: Unauthorized users can be allowed to view the private pipeline if the logged-in user's scmContext and the pipeline's scmContext are different Fix: Unauthorized users can be allowed to view the private pipeline if the logged-in user's scmContext and the pipeline's scmContext are different (scm-github) Nov 12, 2021
@tkyi tkyi merged commit 5bb8bc4 into screwdriver-cd:master Nov 13, 2021
@yoshwata yoshwata deleted the fix-scm-mismatch branch November 13, 2021 01:14
@sd-buildbot
Copy link

🎉 This PR is included in version 11.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@@ -227,6 +227,11 @@ class GithubScm extends Scm {
privateRepo = scmRepo.privateRepo || false;
} else {
try {
if (scmHost !== this.config.gheHost) {
Copy link
Member

Choose a reason for hiding this comment

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

there is a bug if we're using open source (and gheHost is not set)

{"level":"error","message":"Failed to getPermissions:  Pipeline's scmHost github.com does not match with user's scmHost undefined","stack":"Error: Pipeline's scmHost github.com does not match with user's scmHost undefined\n    at GithubScm.lookupScmUri (/Users/tkyi/repos/opensource/screwdriver/node_modules/screwdriver-scm-github/index.js:231:27)\n    at GithubScm._getPermissions (/Users/tkyi/repos/opensource/screwdriver/node_modules/screwdriver-scm-github/index.js:865:40)\n    at /Users/tkyi/repos/opensource/screwdriver/node_modules/screwdriver-scm-base/index.js:355:25","timestamp":"2021-11-17T00:32:35.390Z"}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will add a PR.

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.

4 participants