T09 · Insecure Skill Coding Practices
Warning
- Location
- gitlab_weekly_report.py:16
- Finding
- GitLab Personal Access Token Exposed Through Process Arguments<![CDATA[ ## Vulnerability Details **File Location**: `gitlab_weekly_report.py:16-19`, `gitlab_weekly_report.py:132`; documented usage in `SKILL.md:38` and `SKILL.md:51-55` **Vulnerability Type**: Credential exposure through command-line and child-process arguments **Risk Level**: Medium ### Vulnerable Code ```python def curl_request(url, token=None): """使用 curl 请求 API(更稳定),绕过代理""" cmd = ["curl", "-s", "-k", "--noproxy", "*"] # --noproxy 绕过代理 if token: cmd.extend(["-H", f"PRIVATE-TOKEN: {token}"]) ``` ```python parser.add_argument("--token", required=True, help="GitLab Personal Access Token") ``` The documented invocation also instructs users to place the credential directly on the command line: ```bash python3 gitlab_weekly_report.py --token 你的token --user-id 46 --after 2026-03-09 --before 2026-03-13 ``` ### Technical Analysis The application requires the GitLab personal access token as a command-line argument. This can record the secret in shell history and expose it through process inspection, command auditing, diagnostic collection, or process-monitoring systems. The script then embeds the same token in the arguments of a spawned `curl` process using `-H "PRIVATE-TOKEN: ..."`. Consequently, the secret may be visible in both the Python process invocation and the child process command line. Although process visibility depends on the operating system and local security configuration, command-line arguments are not an appropriate secret transport mechanism. ### Attack Path 1. A user follows the documented command and supplies a valid GitLab personal access token through `--token`. 2. The command may be retained in shell history, terminal logging, job metadata, or operating-system audit records. 3. During execution, the script creates a `curl` command whose argument list contains the token in plaintext. 4. A local user, process-monitoring service, diagnostic collector, or compromised account with process-inspection access retrieves ...[truncated 841 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the required `--token` command-line option as the primary credential mechanism. 2. Read the token from a protected environment variable, permission-restricted configuration file, operating-system credential store, or an interactive stdin prompt that does not echo input. 3. Prefer a Python HTTP client so the authorization header is transmitted directly without creating a child process containing the token in its argument list. 4. If `curl` must be retained, provide the header through a protected temporary configuration or stdin mechanism that does not expose it in process arguments. Ensure any temporary resource has restrictive permissions and is deleted reliably. 5. Update `SKILL.md` so its examples do not place real tokens directly in command lines. 6. Recommend narrowly scoped, short-lived tokens and document prompt token revocation and rotation if exposure is suspected. 7. Avoid printing credentials in errors, debug logs, generated reports, or exception traces. ]]>
