Invental/Review lessons/Trust boundaries the server must hold

Trust boundaries the server must hold

Give the CI push token to one step only

A token persisted by checkout is readable by every later step, including install scripts from the code under review; give the credential only to the one step that pushes.

01 · Before and afterThe pattern

YAML
- uses: actions/checkout@<sha>
  with: { persist-credentials: false }
- run: npm ci            # PR-controlled postinstall scripts see no token
- run: |
    git add "$OUT"
    git diff --staged --quiet -- "$OUT" && exit 0   # also catches new files
    git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" push origin HEAD:"$REF"
  env: { TOKEN: ${{ secrets.GITHUB_TOKEN }} }

02 · Run it on your appThe check

In your CI, does any step that installs or runs PR code run after a checkout that persisted a write token?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.