T09 · Insecure Skill Coding Practices
- Location
scripts/generate_podcast.py:16- Finding
Bearer Token and User Content Transmitted over Plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_podcast.py:16-42
Vulnerability Type: Cleartext transmission of sensitive information
Risk Level: HighComplete Code Snippet
python BASE_URL = os.environ.get( "TINGDONG_API_URL", "http://111.229.22.145:8092/api/v1" ).rstrip("/") API_TOKEN = os.environ.get("TINGDONG_API_TOKEN", "") def api_post(endpoint: str, payload: dict, timeout: int = 30) -> dict: """POST request""" url = f"{BASE_URL}{endpoint}" data = json.dumps(payload).encode("utf-8") headers = {"Content-Type": "application/json"} if API_TOKEN: headers["Authorization"] = f"Bearer {API_TOKEN}" req = urllib.request.Request(url, data=data, headers=headers, method="POST") with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8")) def api_get(endpoint: str, timeout: int = 30) -> dict: """GET request""" url = f"{BASE_URL}{endpoint}" headers = {} if API_TOKEN: headers["Authorization"] = f"Bearer {API_TOKEN}" req = urllib.request.Request(url, method="GET", headers=headers) with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8"))The same insecure default is used by the monitoring client:
python API_BASE = os.environ.get( "TINGDONG_API_URL", "http://111.229.22.145:8092/api/v1" ).rstrip("/") API_TOKEN = os.environ.get("TINGDONG_API_TOKEN", "") def api_get(endpoint: str, timeout: int = 10): url = f"{API_BASE}{endpoint}" headers = {} if API_TOKEN: headers["Authorization"] = f"Bearer {API_TOKEN}" return requests.get(url, headers=headers, timeout=timeout)The plaintext endpoint is also explicitly prescribed in
SKILL.md:48-72and documented inreferences/api_docs.md:5-8.Technical Analysis
The default API endpoint uses HTTP rather than HTTPS. When
TINGDONG_API_TOKENis configured, both clients at ...[truncated 2270 chars]- Remediation
View remediation
Remediation Suggestions
- Replace the default endpoint with an HTTPS URL backed by a valid, trusted certificate.
- Reject non-HTTPS API URLs whenever
TINGDONG_API_TOKENis present. - Apply the transport check in both
generate_podcast.pyandmonitor.py, before constructing or sending an authenticated request. - Update
SKILL.mdandreferences/api_docs.mdso all authenticated examples and returned audio links use HTTPS. - If plaintext access is required for isolated development environments, require an explicit insecure-development option, display a prominent warning, and refuse to attach bearer credentials over HTTP.
- Rotate tokens previously used with the plaintext public endpoint because they may have been exposed in transit.
- Use short-lived, narrowly scoped tokens and implement server-side revocation and quota controls to reduce the impact of credential interception.
