T09 · Insecure Skill Coding Practices
- Location
scripts/brickset.py:56- Finding
Brickset API Key Exposure Through Command-Line Arguments and URL Query Strings
- Content
View full analysis
dict[str, Any]: params: dict[str, Any] = {"apiKey": api_key} if extra_params: for key, value in extra_params.items(): if value is None: continue params[key] = value url = f"{API_BASE}/{method}" headers = {"Accept": "application/json"} try: if post: body = urlencode(params).encode("utf-8") request = Request(url, data=body, headers=headers, method="POST") else: request = Request(f"{url}?{urlencode(params)}", headers=headers, method="GET") ``` ```python parser.add_argument("--api-key", help="Brickset API key. Defaults to BRICKSET_API_KEY env/.env") ``` ### Technical Analysis The CLI accepts a secret API key through the `--api-key` command-line option. Command-line arguments may be retained in shell history and may be visible to local users or monitoring software through process inspection facilities. For requests where `post` is false, `call_api()` places the API key directly in the URL query string. Although the fixed endpoint uses HTTPS, query strings can still be recorded by the destination server, reverse proxies, observability platforms, debugging tools, and URL-based access logs. TLS protects the request in transit but does not prevent either endpoint or authorized intermediary infrastructure from logging the complete URL. The network transmission itself is necessary for the declared Brickset API functionality and is restricted to the hard-coded official HTTPS endpoint: ```python API_BASE = "https://brickset.com/api/v3.asmx" ``` However, exposing the credential through process arguments and request URLs exceeds t ...[truncated 1458 chars]- Remediation
View remediation
