T09 · Insecure Skill Coding Practices
- Location
main.py:14- Finding
API Credential Stored in Source Code and Transmitted to an External Service
- Content
View full analysis
Vulnerability Details
File Location:
main.py, lines 14-15 and 62-79
Vulnerability Type: Insecure credential storage and external disclosure
Risk Level: MediumVulnerable Code
python API_KEY = "" # 付费后获得,填入这里 API_URL = "https://www.kaiwu8.com/verify"python # Local TTL has expired # If an API_KEY exists, call the API to attempt renewal if API_KEY: try: import urllib.request, urllib.error payload = json.dumps({"api_key": API_KEY, "skill_id": SKILL_ID}).encode() req = urllib.request.Request( API_URL, data=payload, headers={"Content-Type": "application/json"}, method="POST" ) with urllib.request.urlopen(req, timeout=10) as resp: result = json.loads(resp.read()) if result.get("valid"): new_expires_at = result.get("expires_at", current + RENEWAL_INTERVAL) _save_local_ttl(new_expires_at) return True except Exception: pass return FalseTechnical Analysis
The implementation instructs users to insert a paid API credential directly into the
API_KEYvariable inmain.py. Storing a credential in application source makes it accessible to anyone or any process that can read the project, and it can unintentionally propagate through source-control commits, archives, backups, logs, or redistributed copies of the Skill.After the local seven-day trial expires, every invocation of
communicate()reaches_check_and_renew_ttl()and may send the API key and Skill identifier to the fixed external endpointhttps://www.kaiwu8.com/verify. HTTPS protects the credential in transit under normal TLS assumptions, and the documentation discloses the licensing endpoint. Nevertheless, remote credential transmission is not required for the declared local communication-analysis functionality; it exists ...[truncated 1627 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the source-level
API_KEYfield and load the credential at runtime from a dedicated environment variable or operating-system credential store. - Never place real credentials in tracked source files. Add local secret files to
.gitignoreif such files must be supported. - Apply restrictive filesystem permissions to any local credential configuration, allowing access only to the account running the Skill.
- Clearly document the destination, transmitted fields, validation frequency, retention policy, and privacy implications of remote license verification.
- Obtain explicit user consent before enabling network-based verification, and keep the core communication workflow functional without unnecessary network access where licensing requirements permit.
- Consider signed offline license tokens that can be verified locally using a bundled public key, avoiding repeated transmission of a reusable secret.
- If remote verification remains necessary, use short-lived, revocable tokens rather than a long-lived API key and ensure the server never logs plaintext credentials.
- Pin verification to an allowlisted HTTPS origin, maintain strict TLS certificate validation, and define explicit handling for redirects.
- Replace the broad
except Exception: passwith narrowly scoped exception handling and safe diagnostic reporting that never includes credentials.
- Remove the source-level
