T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:83
- Finding
- OAuth Access and Refresh Tokens Exposed in Console Output<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 83-89 and 111-117 **Vulnerability Type**: Plaintext credential disclosure through process output **Risk Level**: High ### Vulnerable Code ```python req = urllib.request.Request('https://oauth2.googleapis.com/token', data=data) response = json.load(urllib.request.urlopen(req)) print(f"\nRefresh Token: {response['refresh_token']}") print(f"Access Token: {response['access_token']}") print(f"\nSet your refresh token:") print(f"export GOOGLE_REFRESH_TOKEN=\"{response['refresh_token']}\"") ``` The access-token example repeats the exposure: ```python req = urllib.request.Request('https://oauth2.googleapis.com/token', data=data) response = json.load(urllib.request.urlopen(req)) return response['access_token'] # Store for reuse access_token = get_access_token() print(f"Access Token: {access_token}") ``` ### Technical Analysis The documented OAuth workflow prints both the short-lived access token and long-lived refresh token in plaintext. Although sending credentials to Google's official OAuth token endpoint is necessary for the declared functionality, displaying the returned credentials is not necessary. Console output can be retained by shell capture, CI/CD logs, agent transcripts, terminal session recording, debugging systems, or centralized log collectors. The refresh token is especially sensitive because it can repeatedly generate new access tokens until it is revoked or expires. The requested OAuth scope is `https://www.googleapis.com/auth/documents`, so a compromised token may authorize access to Google Docs resources available under that scope. ### Attack Path 1. A user follows the instructions and runs the OAuth setup or access-token example. 2. The script prints the access token and refresh token to standard output. 3. The output is retained in a terminal transcript, automation log, screen recording, support bundle, or agent conversation. 4. An attacker with access to that outpu ...[truncated 779 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove every statement that prints access tokens or refresh tokens. - Store refresh tokens in an operating-system credential manager or managed secret store rather than displaying them for manual copying. - If a local token file is unavoidable, restrict it to the owning user and document its sensitivity. - Redact authorization headers, token responses, and environment-variable values from logs and exception reports. - Keep access tokens only in memory for the minimum required duration. - Revoke and regenerate tokens if they may already have appeared in retained logs. - Prefer Google's maintained OAuth libraries, which provide safer token persistence and refresh behavior. - Update the example to print only a success message, such as `OAuth authorization completed successfully`. ]]>
