GitLab adds AI-assisted rotation for leaked access tokens

GitLab is adding a beta workflow that rotates leaked personal access tokens and uses GitLab Duo to update the affected CI/CD code. The feature revokes the exposed token, stores a replacement in GitLab Secrets Manager, and opens a merge request for review.
- GitLab 19.6 beta can rotate leaked PATs from a vulnerability page.
- GitLab Secrets Manager stores the replacement token.
- GitLab Duo opens a merge request to update CI/CD jobs.
- The replacement value is not exposed to users or agents.
- A Python tool can batch-rotate tokens across a group.
A single workflow for detection and remediation
Starting in GitLab 19.6, GitLab Ultimate users can remediate an active GitLab personal access token, or PAT, directly from a vulnerability page. After opening an active PAT finding, users select AI actions > Fix with AI > Rotate and fix.
GitLab says the workflow revokes the leaked token and creates a replacement with the same name, scopes, and duration, with the duration reset from the rotation date. The replacement is stored as a project secret in GitLab Secrets Manager and is available to all branches and environments. The vulnerability marks the old token as inactive.
GitLab Duo Agent Platform then starts a Developer Flow session that opens a merge request. The proposed changes remove the hardcoded token and configure CI/CD jobs to read the replacement from Secrets Manager. Users review and merge the request before resolving the vulnerability.
The replacement value stays hidden
Rotation happens before the GitLab Duo agent starts, so the agent does not see the new token. GitLab says the agent receives the vulnerability and its file location, the new secret's name, and the user's name so it can assign the merge request.
The resulting pipeline configuration can reference the secret by name while continuing to use the existing GITLAB_TOKEN variable in the deployment script. Secrets Manager injects the value at runtime. GitLab says this design avoids exposing the replacement token to users or their agents.
The workflow addresses a common problem with manual remediation. Revoking a token immediately can break dependent pipelines, while delaying rotation leaves the leaked credential active. Manual replacement also requires tracking down the owner, matching scopes, storing the new value securely, and updating scripts and CI/CD jobs.
Beta limits and ownership rules
The beta requires GitLab Ultimate 19.6 or later. It is enabled by default on GitLab.com and is available on GitLab Self-Managed behind the secrets_manager_pat_rotation feature flag. It is not yet available on GitLab Dedicated.
Rotation supports GitLab PATs, including fine-grained PATs, but does not yet cover other secrets detected by the system, such as cloud provider keys. The leaked token stops working immediately, and the rotation cannot be undone. The new secret is scoped to the current project, so scripts outside GitLab CI/CD and jobs in other projects that used the old token need a new token.
On GitLab.com, users can rotate only their own tokens. On GitLab Self-Managed, administrators can also rotate tokens belonging to other users. If the GitLab Duo session cannot start, GitLab still rotates the old token and stores the replacement, allowing the code update to be completed manually.
Batch rotation for groups
GitLab also describes leaked-token-rotation-automation, a dependency-free Python CLI and CI/CD component for rotating tokens across a group. It combines the projectSecretCreateFromLeakedToken GraphQL mutation with a request that starts the GitLab Duo Developer Flow.
The tool can rotate active leaked PATs across a group's repositories and open a merge request for each finding. It can also find GitLab PATs in project CI/CD variables, rotate them, store replacements in Secrets Manager, and ask GitLab Duo to update jobs that use those variables. It skips group, instance, file-type, and hidden variables.
Each run starts in dry-run mode, requires --apply to execute, stops after 10 rotations by default, and can be adjusted with --limit. GitLab says reports never include token values. The feature and automation tool require GitLab Duo Agent Platform and Secrets Manager, and rotations consume GitLab Credits for the Developer Flow session, the stored secret, and each CI/CD job that reads it.


