T09 · Insecure Skill Coding Practices
- Location
references/auth.md:35- Finding
GitLab Access Token Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
references/auth.md, lines 35–36
Vulnerability Type: Access-token exposure through command-line arguments
Risk Level: MediumVulnerable code snippet:
bash # Non-interactive login with explicit token glab auth login --hostname gitlab.example.org --token glpat-xxxxTechnical Analysis
The documentation recommends supplying a GitLab personal access token through the
--tokencommand-line argument. Althoughglpat-xxxxis only a placeholder, users following this example may replace it with a real token.Command-line secrets may be retained in shell history, terminal session logs, diagnostic output, or process telemetry. Depending on the operating system and local security configuration, process arguments may also be visible to other local users or monitoring services while the command is running. The safer stdin-based examples elsewhere in the same file do not eliminate the risk created by explicitly recommending this alternative.
Attack Path
- A user replaces
glpat-xxxxwith a valid GitLab access token. - The shell records the command in its history, or a terminal logger, process monitor, audit service, or diagnostic collector captures the command arguments.
- An attacker or unauthorized local principal obtains access to that record or observes the process arguments.
- The attacker extracts the token and authenticates to the corresponding GitLab instance.
- The attacker performs actions permitted by the token scopes and the associated user's project permissions.
Impact Assessment
A stolen token may allow access to private GitLab projects, repository content, issues, merge requests, pipelines, job logs, and API resources available to the token holder. The documented minimum scopes include
apiandwrite_repository, so compromise may permit repository writes and remote mutations in addition to data disclosure.The exact impact is bo ...[truncated 188 chars]
- A user replaces
- Remediation
View remediation
Remediation Suggestions
- Remove the example that places a token directly in the
--tokencommand-line argument. - Recommend
glab auth login --stdinand source the token from a protected secret manager or another mechanism that does not expose it in command history. - Avoid storing tokens in plaintext files. If a temporary token file is unavoidable, create it with owner-only permissions, keep it outside shared directories, and securely delete it immediately after use.
- Add an explicit warning that tokens must not be entered as command-line arguments, committed to repositories, included in scripts, or copied into logs.
- Use narrowly scoped, short-lived tokens and rotate or revoke any token suspected of appearing in shell history or telemetry.
- Ensure CI systems use masked and protected secret variables rather than literal command arguments.
- Remove the example that places a token directly in the
