Skip to main content

SKY-D321 · CI/CD pipelines

GitLab CI release or OIDC job without a timeout

Medium

The catalog lists MEDIUM, but the detector reports every finding as LOW.

A GitLab job's timeout: says how long it may run before GitLab stops it. SKY-D321 reports a job that releases, deploys or receives OIDC tokens and sets no timeout, neither on the job nor under default:.

Languages
GitLab CI
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Catalog name
GitLab CI privileged job missing timeout
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Such a job then runs until the project's limit, which is one hour unless someone raised it. A deploy that hangs, or a job an attacker has taken over, keeps its deploy credentials and tokens usable for that whole time, and holds back the next release.

What Skylos flags

.gitlab-ci.yml · YAMLReported on line 3
stages: [deploy] deploy-production:  stage: deploy  image: bitnami/kubectl:1.31.2  environment: production  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH  script:    - kubectl apply -f k8s/    - kubectl rollout status deployment/web

What Skylos leaves alone

.gitlab-ci.yml · YAML
stages: [deploy] default:  timeout: 20 minutes deploy-production:  stage: deploy  image: bitnami/kubectl:1.31.2  environment: production  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH  script:    - kubectl apply -f k8s/    - kubectl rollout status deployment/web

Why Skylos leaves it alone

The job sets no timeout of its own, but it inherits the 20 minutes from default:, and Skylos reads that.

How Skylos decides

  1. Runs with --danger (and -a). Reads every file named exactly .gitlab-ci.yml in the scanned folder, skipping .git, node_modules, .venv, venv, build, dist and cache folders. Files pulled in with include: are not read, and a file PyYAML's safe loader cannot read (for example one that uses !reference) is skipped.
  2. Checks jobs that are release-like or have id_tokens / identity (their own or from default:), hidden .template jobs excluded. A job is release-like when its name contains deploy, release or publish, its stage is deploy, deployment, release, publish or production, its environment is prod or production, it has release, or a command starts with a publish or deploy tool such as kubectl apply, helm upgrade, terraform apply or npm publish.
  3. Reports the job when neither it nor default: sets timeout. Any value counts, however long; a top-level timeout: key is not read.
  4. One LOW finding per job, on the first line that contains the job name followed by :.

How to fix it

Give the job a timeout a little longer than its slowest normal run, or set one for every job under default:.

.gitlab-ci.yml · YAML · the fix, against the flagged file
stages: [deploy] deploy-production:  stage: deploy  image: bitnami/kubectl:1.31.2  environment: productionAdded:   timeout: 15 minutes  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH  script:    - kubectl apply -f k8s/Removed:     - kubectl rollout status deployment/webAdded:     - kubectl rollout status deployment/web --timeout=10m

When it can be wrong

  • A project whose CI/CD settings set a short timeout is still reported; Skylos reads only the file.
  • A job is release-like by name alone, so release-notes-preview without a timeout is reported.

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-D321] 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
    # skylos: ignore[SKY-D321] project timeout is 15 minutesdeploy-production:
  • [tool.skylos] ignore = ["SKY-D321"] turns the rule off for the whole project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.