Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ on:
push:
branches:
- main
# Publish an existing release tag to npm, e.g. when the publish step failed after
# release-please had already cut the release (a re-run then skips publishing).
workflow_dispatch:
inputs:
tag:
description: 'Release tag to publish, e.g. defender-v0.9.6'
required: true

name: release-please

Expand All @@ -11,6 +18,7 @@ permissions:

jobs:
release-please:
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
released: ${{ steps.release.outputs.paths_released != '[]' }}
Expand Down Expand Up @@ -62,3 +70,39 @@ jobs:
version: ${{ needs.release-please.outputs.version }}
secrets:
REPO_GH_PAT: ${{ secrets.REPO_GH_PAT }}

publish-tag:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
env:
TAG: ${{ inputs.tag }}
steps:
- name: Check tag
run: |
[[ "$TAG" =~ ^defender-v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Not a release tag: $TAG"; exit 1; }
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: refs/tags/${{ inputs.tag }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High - Manual publish accepts attacker-created release tags

A repository user with write access can create an unprotected defender-vX.Y.Z tag on an arbitrary commit, set its package.json version to match, and dispatch this workflow. The job then runs that tag's package-defined build and publish scripts with NPM_TOKEN, allowing unauthorized publication of attacker-controlled package contents and potentially disclosure or misuse of the npm credential.

Show fix

Restrict this recovery path to release tags whose commits are authenticated and reachable from the protected release history, or require an approval-gated environment and an explicit allowlist of release actors. Do not rely only on the tag spelling and package version; independently verify tag provenance/immutability and consider replacing the long-lived npm token with a narrowly scoped, approval-protected publishing credential.

More info - Reply on this comment to give feedback or ignore the issue.

lfs: true
- name: Check version matches tag
run: |
version=$(node -p "require('./package.json').version")
[[ "defender-v$version" == "$TAG" ]] || { echo "package.json is $version, tag is $TAG"; exit 1; }
- name: Setup pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22.23.5'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Build
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Publish
run: |
pnpm publish-release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading