T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/test-agent.py:16
- Finding
- API Credentials Can Be Exposed Through Command-Line Arguments and Plaintext HTTP<![CDATA[ ## Vulnerability Details **File Location**: `scripts/test-agent.py:16-22, 47-52, 77-83, 154-157, 184-189` **Vulnerability Type**: Sensitive credential exposure over an insecure transport **Risk Level**: High ### Vulnerable Code ```python class AgentTester: def __init__(self, url: str, api_key: str = None): self.url = url.rstrip('/') self.headers = { 'Content-Type': 'application/json' } if api_key: self.headers['Authorization'] = f'Bearer {api_key}' ``` ```python response = requests.post( f"{self.url}/invoke", json=payload, headers=self.headers, timeout=30 ) ``` ```python response = requests.post( f"{self.url}/stream", json=payload, headers=self.headers, stream=True, timeout=30 ) ``` ```python parser.add_argument( "--api-key", "-k", help="API key for authentication" ) ``` ```python if not args.url.startswith(('http://', 'https://')): print("Error: URL must start with http:// or https://") sys.exit(1) tester = AgentTester(args.url, args.api_key) ``` The unsafe command-line usage is also recommended in: - `README.md:77,207` - `references/quick-reference.md:18` ```bash python scripts/test-agent.py https://api.example.com --api-key [YOUR-API-KEY] ``` ### Technical Analysis The tester accepts an API key as a command-line argument and inserts it into an `Authorization: Bearer` header. Command-line secrets may be retained in shell history and can be visible through process-inspection facilities to other users or monitoring software on the same system. The URL validation permits both HTTPS and plaintext HTTP. When an HTTP URL is supplied, the bearer credential is transmitted without transport encryption. The destination is otherwise user-controlled and unrestricted, so a typo, malicious endpoint, or untrusted testing target can receive the credential. Sending a credential to a selected agent endpoint is necessary for authenticated te ...[truncated 1369 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove or deprecate the `--api-key` argument. 2. Read credentials from a protected environment variable, operating-system credential store, or interactive `getpass.getpass()` prompt. 3. Reject plaintext HTTP for all non-loopback destinations. 4. If HTTP is required for local development, permit it only for verified loopback hosts such as `127.0.0.1`, `::1`, and `localhost`, behind an explicit development flag. 5. Warn before sending credentials to a new or untrusted hostname. 6. Explicitly control redirects and ensure authorization headers are never forwarded to a different origin. 7. Update all README and quick-reference commands so secrets do not appear in shell arguments. 8. Recommend narrowly scoped, revocable testing keys rather than production-wide credentials. ]]>
