SKY-D322 · CI/CD pipelines
GitLab CI runner tag set from a variable
GitLab sends a job to a runner whose tags match the job's tags: list. SKY-D322 reports a tag built from a CI/CD variable, such as $RUNNER_TAG, because the variable decides at run time which machine runs the job.
- Languages
- GitLab CI
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitLab CI dynamic runner tag
Why it matters
Variables can be set by whoever starts a pipeline with variables or a trigger token. Setting RUNNER_TAG=prod-deployer can move a job onto a privileged runner that holds production credentials or keeps state between jobs, where its script then runs.
What Skylos flags
stages: [deploy] variables: RUNNER_TAG: shared-small deploy-staging: stage: deploy image: bitnami/kubectl:1.31.2 timeout: 20 minutes tags: - $RUNNER_TAG script: - kubectl apply -f k8s/What Skylos leaves alone
stages: [deploy] variables: KUBE_NAMESPACE: staging deploy-staging: stage: deploy image: bitnami/kubectl:1.31.2 timeout: 20 minutes tags: - shared-small script: - kubectl apply -n "$KUBE_NAMESPACE" -f k8s/Why Skylos leaves it alone
A variable still steers the job, but only inside the script. The runner tag is a fixed word, so the variable cannot pick the machine.
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. - Reads the
tagsunderdefault:and each job's owntags, hidden.templatejobs included. Tags a job gets throughextends:are not looked up. - Reports every tag that contains
$, which covers$NAME,${NAME}and tags with a variable inside a longer word. - One MEDIUM finding per tag, on the first line of the file that contains the tag's text.
How to fix it
Write the runner tag as a fixed word. To use different runners for different targets, write one job per target, each with its own fixed tags and its own rules:.
stages: [deploy] Removed: variables:Removed: RUNNER_TAG: shared-smallRemoved: deploy-staging: stage: deploy image: bitnami/kubectl:1.31.2 timeout: 20 minutes tags:Removed: - $RUNNER_TAGAdded: - shared-small script: - kubectl apply -f k8s/When it can be wrong
- A tag from a
parallel: matrix:value that the file itself lists is reported, although only those listed values can be used. - A variable only maintainers can set, such as a protected project variable, is reported the same as one anyone can pass in.
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-D322]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 tags: # skylos: ignore[SKY-D322] values come from the matrix below - $RUNNER_TAG[tool.skylos] ignore = ["SKY-D322"]turns the rule off for the whole project.