T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/curl.py:45
- Finding
- Basic Authentication Credentials Can Be Exposed Through Insecure Transport and Command-Line Arguments## Vulnerability Details **File Location**: `scripts/curl.py:45-52` and `scripts/curl.py:93` **Vulnerability Type**: Plaintext sensitive-data exposure **Risk Level**: Medium ### Vulnerable Code ```python # Basic auth if user: if ':' in user: username, password = user.split(':', 1) else: username, password = user, '' credentials = base64.b64encode(f'{username}:{password}'.encode()).decode() req.add_header('Authorization', f'Basic {credentials}') ``` ```python parser.add_argument('-u', '--user', help='Basic auth (user:password)') ``` ### Technical Analysis Base64 encoding is required by the HTTP Basic authentication scheme, but it does not encrypt credentials. Anyone who obtains the `Authorization` header can trivially recover the username and password. Basic authentication is part of the Skill's documented functionality, and the code sends credentials only to the caller-selected destination. Therefore, this is not evidence of a covert exfiltration channel. However, the implementation permits Basic credentials to be sent to an unencrypted `http://` URL without rejection or warning. On such connections, a network observer can capture and decode the Authorization header. The password is also accepted directly through the `--user user:password` command-line argument. Depending on the operating environment, command-line values can be exposed through process listings, shell history, diagnostic logs, audit records, or Agent execution transcripts. ### Attack Path 1. A user invokes the Skill with credentials, for example: ```bash curl-tool -u victim:secret http://example.test/private ``` 2. The complete credential string may be retained in shell history, process metadata, logs, or an Agent transcript. 3. The implementation Base64-encodes `victim:secret` and adds it to the HTTP `Authorization` header. 4. Because the destination uses unencrypted HTTP, an attacker capa ...[truncated 1261 chars]
- Remediation
- ## Remediation Suggestions 1. Reject Basic authentication for non-HTTPS URLs by default: ```python parsed = urllib.parse.urlparse(url) if user and parsed.scheme.lower() != 'https': raise ValueError('Basic authentication requires HTTPS') ``` 2. Apply the same HTTPS requirement when callers provide an `Authorization` header manually. 3. If insecure transport must be supported for exceptional development scenarios, require an explicit option such as `--allow-insecure-auth` and display a prominent warning. 4. Avoid accepting passwords directly on the command line. Accept only the username and retrieve the password with `getpass.getpass()`, or use a protected credential source such as a restricted file descriptor or operating-system secret store. 5. Ensure credentials are never included in normal output, exception messages, debug logs, or saved response files. 6. Document that HTTP Basic authentication is safe only when protected by properly validated TLS and that credentials should not be reused across services.
