Skip to main content
HighSecretsOWASP A07:2021CWE-798

How to fix: GitLab deploy token in source

GitLab deploy tokens grant push/pull to the project registry and package registry. Long-lived and project-scoped - very useful to attackers.

Why it matters

An exposed GitLab deploy token lets an attacker pull private container images and packages, or push malicious versions, compromising your container supply chain and any system that pulls from your registry.

GitLab deploy tokens grant push/pull to the project registry and package registry. Long-lived and project-scoped - very useful to attackers.

How to fix it

  1. 1Revoke the token: GitLab Project → Settings → Repository → Deploy tokens → Revoke
  2. 2Switch to CI/CD job tokens (per-job TTL, automatically expires after the job)
  3. 3For CI/CD, use group-level access tokens with minimum required scopes

Code examples

Use CI/CD job token instead of deploy token

YAML
# .gitlab-ci.yml
docker_pull:
  script:
    # Use the automatically-provided CI_JOB_TOKEN (expires after the job)
    - docker login -u $CI_REGISTRY_USER \
        -p $CI_JOB_TOKEN \
        $CI_REGISTRY
    - docker pull $CI_REGISTRY_IMAGE:latest
    # Never use a hard-coded deploy token here

References

Detected automatically by VulnRadar. The check id is secret-gitlab-deploy-token, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is GitLab deploy token in source?
VulnRadar rates this high severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id secret-gitlab-deploy-token, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does GitLab deploy token in source map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for gitlab deploy token in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: GitLab deploy token in source | VulnRadar