SKY-D316 · CI/CD pipelines
GitLab CI literal secret variable
GitLab CI files can set environment variables for jobs. SKY-D316 reports a variable whose name says it is a secret, such as DEPLOY_TOKEN or DB_PASSWORD, when its value is written into the file itself instead of coming from a CI/CD variable stored in GitLab's settings.
- Languages
- GitLab CI
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
Anyone who can read the repository, its forks or an old clone has the secret, and it stays in Git history after it is removed. GitLab does not mask a value written in the file, so it can also appear in job logs.
What Skylos flags
variables: PIP_INDEX_URL: https://pypi.org/simple SENTRY_ORG: acme SENTRY_AUTH_TOKEN: "sntryu_0handbook0demo0only0not0a0real0token0" stages: [build] upload-sourcemaps: stage: build image: getsentry/sentry-cli:2.33.1 script: - sentry-cli releases new "$CI_COMMIT_SHA"What Skylos leaves alone
variables: PIP_INDEX_URL: https://pypi.org/simple SENTRY_ORG: acme TOKEN_TTL_SECONDS: "3600" stages: [test] integration-tests: stage: test image: python:3.12-slim services: - postgres:16.4 variables: POSTGRES_PASSWORD: postgres DATABASE_PASSWORD: $STAGING_DB_PASSWORD script: - pytest tests/integrationWhy Skylos leaves it alone
DATABASE_PASSWORD only refers to a variable stored in GitLab. postgres is on Skylos's list of placeholder values, as the password of a throwaway test database usually is. TOKEN_TTL_SECONDS matches the name pattern, but 3600 is too short to be a secret.
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. A subfolder scan of a Git repository also reads the repository's top-level.gitlab-ci.yml. Files pulled in withinclude:are not read. - Skips a file that PyYAML's safe loader cannot read, without a warning. That includes every file that uses GitLab's
!referencetag. - Reads the top-level
variables:and thevariables:of every job, hidden.templatejobs included. - The name must contain one of
SECRET,TOKEN,PASSWORD,PASS,API_KEY,PRIVATE_KEY,ACCESS_KEY,CREDENTIALorCREDENTIALSas a whole underscore-separated part, in any case.DB_PASSmatches;APIKEYandPASSWDdo not. - Skips values that are empty, start with
$or contain${(references to other variables), are YAML booleans, or are a placeholder:changeme,change-me,dummy,example,fake,none,password,placeholder,postgres,root,testortodo. - Skips the long form
NAME: {value: …, description: …}: only plain values are read. - Reports what is left when it is at least 8 characters long or contains
-,_,=,:or/: HIGH at the top level, MEDIUM in a job, on the first line of the file that defines that name.
How to fix it
Revoke the token first: it is already in Git history. Then create a new one as a masked, protected CI/CD variable under Settings > CI/CD > Variables, and delete the line from the file. Jobs receive the stored variable under the same name without any mention in .gitlab-ci.yml.
variables: PIP_INDEX_URL: https://pypi.org/simple SENTRY_ORG: acmeRemoved: SENTRY_AUTH_TOKEN: "sntryu_0handbook0demo0only0not0a0real0token0" stages: [build] upload-sourcemaps: stage: build image: getsentry/sentry-cli:2.33.1 script: - sentry-cli releases new "$CI_COMMIT_SHA"When it can be wrong
- Settings that are not secrets but have a matching name are reported when the value is long or has a
/, such asAWS_WEB_IDENTITY_TOKEN_FILE: /tmp/web-identity-tokenorTOKEN_TTL: "86400000". - A secret in the long form (
value:anddescription:) is not reported at all. - When two jobs use the same variable name, every finding points at the first line that defines it.
- This rule judges names and value shapes only. The secrets scan (SKY-S101) is a separate check that looks at the values themselves.
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-D316]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 variables: # skylos: ignore[SKY-D316] path to a file, not a secret AWS_WEB_IDENTITY_TOKEN_FILE: /tmp/web-identity-tokenA baseline hides the findings that exist today. Each entry records the rule, the absolute file path and the line, so it stops matching when the line moves or the checkout is at another path. Do not baseline a real secret: revoke it.
[tool.skylos] ignore = ["SKY-D316"]turns the rule off for the whole project.