Shopify / Shopify/shipit-engine

Users can impersonate Shipit on github using the GITHUB_TOKEN env var

Open
#904 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.5k
Forks
154
Avg merge
2h 26m
Merged PRs (30d)
3

Description

GITHUB_TOKEN is provided in the environment to authenticate git clones. However as it remains in the environment after the initial clone, users can consume this token in their own scripts to impersonate Shipit on Github through the API. This is not ideal because:

  • The token is only designed to be valid at the start of a task to facilitate git cloning (can potentially only be valid for 10 minutes) - if people are relying on it later on in a longer task, it will break unexpectedly from their point of view
  • The unexpected use of the token by users creates an unreliable 'feature' from their perspective
  • Shipit is already a highly privileged entity - lots of access to Github and lots of credentials for production - allowing custom code to impersonate Shipit makes reasoning about its access even harder. We want to be limiting Shipit's access where possible, letting people hit the API on their own means we're likely to break something without realising it

I consider this a bug and would like to fix it. Some options:

  • Can we limit the access of the token itself to only repo read(/write?)?
  • Can we only set the variable for git commands?
  • Obfuscation: move the token into a file or expose it via an endpoint
  • Consider unsetting the variable after the git clone has finished. One big issue with that I see is it would break any user supplied git commands at the start of a task - e.g. fetching tags/submodules.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading lib/shipit/commands.rb at the GITHUB_TOKEN setup and lib/snippets/git-askpass to understand how the token reaches git clones. Define completion as preserving the required clone authentication while preventing user-supplied task scripts from using the token to impersonate Shipit, and add or update coverage for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
authentication, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.