T09 · Insecure Skill Coding Practices
- Location
scripts/refinance.py:12- Finding
Authentication Key and Financial Data Transmitted over Plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/refinance.py, lines 12–25
Vulnerability Type: Plaintext transmission of sensitive information
Risk Level: HighComplete Code Snippet:
python API_BASE = os.environ.get(f"COZE_REFINANCE_API_URL_{SKILL_ID}", os.environ.get("REFINANCE_API_URL", "http://47.109.39.255:8765/api/v4") USER_KEY = os.environ.get("REFINANCE_USER_KEY", "") def api_call(endpoint, data=None, method="POST"): url = f"{API_BASE.rstrip('/')}/{endpoint}" h = {"Content-Type": "application/json"} if USER_KEY: h["X-User-Key"] = USER_KEY try: if method == "GET": resp = requests.get(url, headers=h, params=data or {}, timeout=30) else: resp = requests.post(url, headers=h, json=data or {}, timeout=60)Technical Analysis
The default API endpoint is a raw public IP address accessed through unencrypted HTTP. The script attaches
REFINANCE_USER_KEYto theX-User-Keyrequest header and sends refinancing information in request parameters or JSON bodies.HTTP does not provide transport confidentiality, integrity, or authenticated server identity. An attacker with a suitable network position—such as one controlling a Wi-Fi access point, local gateway, proxy, or upstream network segment—can inspect or modify requests and responses. Using a raw IP also prevents ordinary domain-based certificate identity validation if HTTPS is introduced without further configuration.
The affected request data can include the authentication key, loan balance, interest rates, remaining term, penalties, fees, and loan type.
Attack Path
- A user invokes a registration, account, service, or refinancing command without overriding the default API URL.
- The script constructs a URL under
http://47.109.39.255:8765/api/v4. - For authenticated operations, the script places the user key in the
X-User-Keyheader. - For calculati ...[truncated 885 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the raw-IP HTTP endpoint with an HTTPS endpoint on a controlled domain using a valid certificate.
- Reject API URLs whose scheme is not
https, except through an explicit development-only configuration. - Validate the destination against an allowlist of approved hostnames and ports.
- Do not silently fall back to an insecure production endpoint.
- Rotate user keys that may previously have been transmitted over plaintext HTTP.
- Consider using short-lived, revocable credentials rather than long-lived static user keys.
- Minimize the financial information sent to the backend and document the remote-processing and data-retention policy.
- Add integration tests verifying that production requests cannot use plaintext transport.
