GitLab check

Active project or group access token has no expiration or a broad scope

GL-SEC-005MediumSecurity

Trigger condition

A project or group access token is confirmed active, confirmed non-revoked, not already expired, and has an explicit expires_at of null or an exact api or write_repository scope. Covers the project's own access tokens and its immediate containing group's access tokens (never a more distant ancestor group's, and never a personal namespace's group tokens, since none exist).

Evidence

Lists every flagged token, distinguishing project tokens from group tokens, each naming its numeric ID and every confirmed reason (e.g. 'Project token ID 17: api scope. Group token ID 42: no expiration date.').

Impact

This finding examines each active, non-revoked token's own configured scopes and expiration metadata -- not confirmed misuse. The api scope grants complete read/write API access (also covering the container registry, dependency proxy, and package registry); write_repository grants Git push/pull access. An explicitly non-expiring token (expires_at: null) has no scheduled expiry and remains valid until manually revoked. This check covers only the project's own access tokens and its immediate containing group's access tokens -- it does not evaluate a more distant ancestor group's tokens. See the Project access tokens API (https://docs.gitlab.com/api/project_access_tokens/), Group access tokens API (https://docs.gitlab.com/api/group_access_tokens/), and GitLab's scope definitions (https://docs.gitlab.com/security/tokens/access_token_scopes/).

Recommendation

Confirm each listed token's actual purpose. When a narrower scope or a newly configured expiration date is needed, create a replacement token with that narrower scope or expiry, update and verify every consumer of the old token, then revoke the old token. GitLab's own token rotation preserves the token's existing scopes and immediately invalidates the old token -- see https://docs.gitlab.com/user/project/settings/project_access_tokens/#rotate-a-project-access-token.

Important limitations

Covers only the project's own access tokens and its immediate containing group's access tokens -- a more distant ancestor group's tokens are never evaluated. A token is flagged only when both its active and revoked fields are confirmed booleans (active=true, revoked=false); a missing or malformed value for either excludes that token from being flagged rather than assuming it safe. A missing or malformed expires_at value is different: it only means the no-expiration reason cannot be confirmed for that token -- a confirmed api or write_repository scope can still trigger the finding on its own. An already-expired token (evaluated as midnight UTC on its stated expiration date) is never flagged. A malformed individual token record (not an object, or missing a valid id) is skipped with a sanitized warning rather than aborting the check. Missing or malformed project namespace metadata skips only group-token collection (with a sanitized warning) rather than aborting the check; project-token collection is unaffected. If either the project or group access-tokens list is unavailable (e.g. a 403 or 404), this check still evaluates whichever list remains available.

← Back to the check catalogue