SKY-D364 · CI/CD pipelines
Long-lived publish token where trusted publishing exists
PyPI and npm offer trusted publishing: the workflow proves who it is with a short-lived OpenID Connect (OIDC) token from GitHub, so no registry password is stored. SKY-D364 reports a workflow that still uploads to PyPI or npm with a token kept in repository secrets.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions long-lived publish token where trusted publishing exists
Why it matters
A stored publish token works from anywhere until someone revokes it. If it leaks, through a log, a compromised action or a fork, the holder can push a new version of your package to every user. A trusted-publishing token lasts minutes and works only for the workflow you registered.
What Skylos flags
name: Releaseon: release: types: [published]permissions: contents: readjobs: pypi: runs-on: ubuntu-latest environment: pypi steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - run: python -m pip install build==1.2.2 && python -m build - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc with: password: ${{ secrets.PYPI_API_TOKEN }}What Skylos leaves alone
name: Releaseon: release: types: [published]permissions: contents: readjobs: internal-index: runs-on: ubuntu-latest environment: internal-index steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - run: python -m pip install build==1.2.2 && python -m build - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc with: repository-url: https://pypi.acme.example/legacy/ password: ${{ secrets.ACME_INDEX_TOKEN }}Why Skylos leaves it alone
The same action with a stored token, but it uploads to a company index. Only PyPI and TestPyPI offer trusted publishing, so a token is the only way to log in there.
More languages
YAML
Flagged
name: Releaseon: release: types: [published]permissions: contents: readjobs: npm: runs-on: ubuntu-latest environment: npm steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci --ignore-scripts - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}Not flagged
name: Releaseon: release: types: [published]permissions: contents: read packages: writejobs: github-packages: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://npm.pkg.github.com - run: npm ci --ignore-scripts - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Why Skylos leaves it alone
This job publishes to GitHub Packages, which has no trusted publishing, and logs in with the job's own GITHUB_TOKEN, which expires when the job ends. Skylos checks npm uploads only to registry.npmjs.org.
How Skylos decides
- Reads workflow files under
.github/workflows. A workflow needs at least one trigger. PyPI uploads are skipped when every trigger ispull_request_target,issue_commentorworkflow_call. - Finds publish steps:
pypa/gh-action-pypi-publishwith apasswordinput, and commands inrun:(and inchangesets/action'spublishinput) such astwine upload,uv publish,poetry,pdm,hatchorflit publish,maturin publish,npm,pnpm,yarnorbun publish,semantic-releaseandchangeset publish, also throughnpxand similar runners. Commands with--dry-runor--helpare skipped. - Needs a stored token: the
passwordinput, a token variable such asTWINE_PASSWORD,UV_PUBLISH_TOKEN,NODE_AUTH_TOKENorNPM_TOKENin step, job or workflowenv:, a--passwordor--tokenoption, or an earlier step that writes.pypircor_authToken, each made from asecrets.Xvalue.secrets.GITHUB_TOKENdoes not count. - Needs a registry with trusted publishing: PyPI or TestPyPI (no other
repository-url,--repositoryorTWINE_REPOSITORY_URL), orregistry.npmjs.orgfrom a GitHub-hosted runner (checked against--registry,NPM_CONFIG_REGISTRYandactions/setup-node'sregistry-url). - Reports each such step once, on the
passwordline or the command's line: MEDIUM, or LOW for npm when the job grantsid-token: write.
How to fix it
Register the workflow as a trusted publisher on PyPI (or npm), grant id-token: write to the publish job only, drop the password input and revoke the old token. Keep the environment: so a reviewer can require approval before each release.
name: Releaseon: release: types: [published]permissions: contents: readjobs: pypi: runs-on: ubuntu-latest environment: pypiAdded: permissions:Added: id-token: write steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - run: python -m pip install build==1.2.2 && python -m build - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfcRemoved: with:Removed: password: ${{ secrets.PYPI_API_TOKEN }}When it can be wrong
- A token kept on purpose as a fallback while trusted publishing is set up is reported until it is removed (LOW for npm in a job with
id-token: write). - Uploads from a self-hosted runner to npm are not reported, because npm offers trusted publishing only to GitHub-hosted runners.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put
# skylos: ignore[SKY-D364]and a reason on the reported line or on the line directly above it, one rule per marker.YAML with: # skylos: ignore[SKY-D364] trusted publisher pending, see #412 password: ${{ secrets.PYPI_API_TOKEN }}[tool.skylos] ignore = ["SKY-D364"]turns the rule off for the whole project.