concept GitHub in category system administration

appears as: GitHub
Securing DevOps

This is an excerpt from Manning's book Securing DevOps.

  • A source code repository —Open source and proprietary solutions exist to manage source code: Bitbucket, Beanstalk, GitHub, GitLab, SourceForge, and so on. A popular choice at the time of writing is GitHub, which we’ll use to host the invoicer’s code.
  • A CI platform —Again, the options are numerous: Travis CI, CircleCI, Jenkins, GitLab, and so on. Depending on your needs and environment, there’s a CI platform for you. In this example, we’ll use CircleCI because it integrates easily with GitHub and allows SSH access to build instances, which is handy for debugging the build steps.
  • The code-management infrastructure shown in figure 6.2 is a common pattern in the DevOps pipeline: a developer uses a code repository, GitHub being the popular example, to host the source code of an application and collaborate with colleagues. To test their code and build application containers, the code repository is integrated with an automated build tool, like CircleCI, Travis CI, or Jenkins, that performs several tasks every time a change is made to the source code.

    Figure 6.2 The code-management infrastructure is composed of developers that publish their code in GitHub and run automated tests and builds in CircleCI. Each component provides access control that must be used to increase the security of the pipeline.

    c06_02FPO.png

    The critical step here is obviously step 3, where Sam grants broad permissions to CircleCI. This is what OAuth calls the “scope.” From an HTTP perspective, when CircleCI redirected Sam to GitHub for authentication, it sent her to the address shown as follows.

    Listing 6.1 CircleCI oauth redirect to GitHub
    https://github.com/login/oauth/authorize?client_id=78a2bb    #1  
    &redirect_uri=https://circleci.com/auth/github?return-to=%2F    #2  
    &scope=repo,user:email    #3  
    &state=-1LihwQWDoFd    #4  
    
    #1   Location of the oauth authentication endpoint at GitHub
    #2   URL that users are redirected to after authenticating with GitHub
    #3   Scope of permissions requested by CircleCI
    #4   CSRF token

    You may recognize the client_id, redirect_uri, scope, and state fields we discussed in chapter 3. Take a closer look at the scope field and its value: repo,user:email. The list of requested scope is comma-separated, and CircleCI is requesting access to repo and user:email. The documentation over at GitHub tell us the following about these scopes: user:email grants read access to a user’s email addresses. repo grants read/write access to code, commit statuses, repository invitations, collaborators, and deployment statuses for public and private repositories and organizations (https://developer.github.com/v3/oauth/).

    By logging in to CircleCI, Sam delegated to it a set of permissions that grant full control over her repositories. Should the oauth token stored by CircleCI leak, an attacker could use it to take control and modify Sam’s applications on GitHub. This is obviously worrisome.