SKY-D319 · CI/CD pipelines
GitLab CI OIDC token in a job that runs repository scripts
A GitLab job with id_tokens: (or identity:) receives OpenID Connect (OIDC) tokens it can trade for cloud or registry credentials. SKY-D319 reports such a job when it also runs scripts kept in the repository, such as ./scripts/release.sh, make or npm run build.
- Languages
- GitLab CI
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitLab CI OIDC local-script exposure
Why it matters
Anyone who can change those scripts, including a merge request author on a branch that runs this job, decides what runs next to the token. A changed build script can send the token to an outside server, which can then publish a package or deploy as your project.
What Skylos flags
stages: [release] release-pypi: stage: release image: python:3.12-slim environment: pypi timeout: 15 minutes id_tokens: PYPI_ID_TOKEN: aud: pypi rules: - if: $CI_COMMIT_TAG script: - ./scripts/build-and-publish.shWhat Skylos leaves alone
stages: [build, release] build: stage: build image: python:3.12-slim script: - ./scripts/build.sh artifacts: paths: [dist/] release-pypi: stage: release image: python:3.12-slim environment: pypi timeout: 15 minutes needs: [build] id_tokens: PYPI_ID_TOKEN: aud: pypi rules: - if: $CI_COMMIT_TAG script: - python -m pip install twine==6.1.0 id==1.5.0 - python -m twine upload dist/*Why Skylos leaves it alone
The repository script still runs, but in the build job, which gets no OIDC token. The job that holds the token only installs pinned tools and uploads the files the build job left behind.
How Skylos decides
- Runs with
--danger(and-a). Reads every file named exactly.gitlab-ci.ymlin the scanned folder, skipping.git,node_modules,.venv,venv,build,distand cache folders. Files pulled in withinclude:are not read, and a file PyYAML's safe loader cannot read (for example one that uses!reference) is skipped. - Looks at every job except hidden
.templatejobs. A job counts when it hasid_tokensoridentity, its own or fromdefault:. - Reads the job's
before_script,scriptandafter_script(its own, else fromdefault:, else top-level) andhooks:pre_get_sources_script. - Reports the job when a command line starts with
./scripts/,./ci/,./build/,./tools/,./release/or./deploy/, runs a file in those folders withbash,sh,python,node,rubyorpwsh, or runsnpm,pnpm,yarnorbun run, ormake. - One HIGH finding per job, on the first line of the file that holds the first matching command.
How to fix it
Split the job. Build in a job without id_tokens, pass the result on as artifacts, and give the token only to a small publish job that runs pinned tools on those files.
Removed: stages: [release]Added: stages: [build, release] Added: build:Added: stage: buildAdded: image: python:3.12-slimAdded: script:Added: - ./scripts/build.shAdded: artifacts:Added: paths: [dist/]Added: release-pypi: stage: release image: python:3.12-slim environment: pypi timeout: 15 minutesAdded: needs: [build] id_tokens: PYPI_ID_TOKEN: aud: pypi rules: - if: $CI_COMMIT_TAG script:Removed: - ./scripts/build-and-publish.shAdded: - python -m pip install twine==6.1.0 id==1.5.0Added: - python -m twine upload dist/*When it can be wrong
- Any
makeornpm runcounts, also a short, reviewed target that only calls a pinned tool. - Missed: a script outside the listed folders (
./publish.sh,bash release.sh) or one called through a variable. - If the same command text appears earlier in the file, the finding points at that earlier line.
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-D319]and a reason on the reported line, or on the line directly above it. Skylos looks for that exact text, so write one rule per marker, with the ID in upper case.YAML script: # skylos: ignore[SKY-D319] script is protected by CODEOWNERS - ./scripts/build-and-publish.sh[tool.skylos] ignore = ["SKY-D319"]turns the rule off for the whole project.