SKY-D373 · CI/CD pipelines
OIDC publish job without an environment
Trusted publishing lets a CI job publish to PyPI or npm with a short-lived OIDC token instead of a stored password. SKY-D373 reports a job that can mint such a token (id-token: write) and publishes, but does not run in a named deployment environment, so the registry cannot insist on one.
- Languages
- GitHub Actions workflows, GitLab CI
- Quality gate
- Full scan: listed, not counted by the gate. Diff scan: counted toward the gate limits. A diff scan counts a finding whose rule, file and job name are not among the merge base's findings. A baseline scan counts it like a diff scan when the baseline's
rule_coveragelists it. - Finding type
- review
Why it matters
Without an environment, every branch and tag that can run the workflow gets the same token. Someone who can push a branch, or start the workflow, can publish a release; the Red Hat npm and TanStack incidents in 2026 worked this way. An environment with required reviewers or branch rules is the gate the registry can check.
What Skylos flags
name: Publish to PyPIon: push: tags: ["v*"]permissions: contents: readjobs: publish: runs-on: ubuntu-latest permissions: id-token: write steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 with: python-version: "3.12" - run: python -m pip install build==1.2.2 - run: python -m build - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfcWhat Skylos leaves alone
name: Publish to PyPIon: push: tags: ["v*"]permissions: contents: readjobs: publish: runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/p/acme-sdk permissions: id-token: write steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 with: python-version: "3.12" - run: python -m pip install build==1.2.2 - run: python -m build - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfcWhy Skylos leaves it alone
The same job still mints an OIDC token and publishes, but it runs in the fixed environment pypi. The PyPI trusted publisher can name that environment, and the environment's protection rules decide who may release.
More languages
YAML
Flagged
stages: [publish] publish-pypi: stage: publish image: python:3.12-slim id_tokens: PYPI_ID_TOKEN: aud: pypi rules: - if: $CI_COMMIT_TAG script: - python -m pip install build==1.2.2 twine==6.1.0 - python -m build - twine upload dist/*Not flagged
stages: [publish] publish-pypi: stage: publish image: python:3.12-slim environment: pypi id_tokens: PYPI_ID_TOKEN: aud: pypi rules: - if: $CI_COMMIT_TAG script: - python -m pip install build==1.2.2 twine==6.1.0 - python -m build - twine upload dist/*Why Skylos leaves it alone
The job runs in the GitLab environment pypi, which the PyPI trusted publisher for GitLab can require.
How Skylos decides
- Runs with
--danger(and-a). Theca9library reads every*.ymland*.yamlfile directly in.github/workflows, the local composite actions they call, and.gitlab-ci.ymlwith its local includes. - Picks jobs that get an OIDC token:
id-token: writein the job'spermissions, or in the workflow's when the job sets none, orwrite-all; in GitLab, a job withid_tokens:(also fromdefault:). - Keeps those that publish: a publish command (
twine upload,npm publish,uv publishand others),pypa/gh-action-pypi-publishorjs-devtools/npm-publish, a publish credential, or a script that asks for an OIDC token and callsregistry.npmjs.orgorupload.pypi.org. - Skips the job when it names a fixed environment (
environment: pypiorenvironment: {name: pypi}). A name built from an expression (${{ … }}, or a$VARIABLEin GitLab) is reported, because whoever starts the run chooses it. The environment's reviewers and branch rules are server settings and are not checked. - Reports one HIGH finding per job, on the job's name.
How to fix it
Run the publish job in a named environment, give that environment required reviewers or deployment-branch rules in the repository settings, and enter the same environment name in the PyPI or npm trusted publisher, so tokens minted outside it are refused.
name: Publish to PyPIon: push: tags: ["v*"]permissions: contents: readjobs: publish: runs-on: ubuntu-latestAdded: environment: pypi permissions: id-token: write steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 with: python-version: "3.12" - run: python -m pip install build==1.2.2 - run: python -m build - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfcWhen it can be wrong
- Any fixed environment name clears the finding, even one that has no reviewers or branch rules configured, so an unprotected environment is missed.
- A job that holds
id-token: writefor something else, such as signing with Sigstore, and publishes with a stored token is reported too.
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
Skylos reads no inline marker for this rule; a
# skylos: ignorecomment on the job does not hide it.Accept a reviewed job with a baseline:
skylos baseline ., then--baseline. The entry matches the rule, file and job name, not the line. In pull-request CI (SKYLOS_POLICY_BASE), the entry must also be in the base commit's.skylos/baseline.json.[tool.skylos] ignore = ["SKY-D373"]turns the rule off for the whole project.