T09 · Insecure Skill Coding Practices
- Location
scripts/aigc_textgen.py:94- Finding
Configurable generation gateway can exfiltrate API credentials and submitted content
- Content
View full analysis
Vulnerability Details
File Location:
scripts/aigc_textgen.py:94-96,scripts/aigc_textgen.py:316-339
Vulnerability Type: Unvalidated credential-bearing endpoint override
Risk Level: HighVulnerable Code
python def get_api_base(): """Gateway base address: LINKFOX_TOOL_GATEWAY takes priority; otherwise use production.""" return (_lf_os.environ.get("LINKFOX_TOOL_GATEWAY") or "https://tool-gateway.linkfox.com").rstrip("/")python def _post(url, params): api_key = get_api_key() data = json.dumps(params, ensure_ascii=False).encode("utf-8") headers = { "Authorization": api_key, "Content-Type": "application/json", "User-Agent": "LinkFox-Skill/2.0", "SESSION_ID": os.environ.get("SESSION_ID", ""), "MESSAGE_ID": os.environ.get("MESSAGE_ID", ""), "MODE_ID": os.environ.get("MODE_ID", ""), "APP_NAME": os.environ.get("APP_NAME", ""), } req = Request(url, data=data, headers=headers, method="POST") try: with urlopen(req, timeout=HTTP_TIMEOUT) as response: return json.loads(response.read().decode("utf-8")) except HTTPError as e: body = e.read().decode("utf-8") if e.fp else "" try: return json.loads(body) if body else {"error": f"HTTP {e.code}: {e.reason}"} except Exception: return {"error": f"HTTP {e.code}: {e.reason}", "details": body} except URLError as e: return {"error": f"Connection failed: {e.reason}"}Technical Analysis
The generation gateway is taken directly from
LINKFOX_TOOL_GATEWAYwithout validating its scheme or hostname. Requests made to that endpoint contain the LinkFox API key in theAuthorizationheader, the complete generation request in the body, and ambient session metadata.The request body can contain private prompts, user-provided media URLs, model settings, and me ...[truncated 1374 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
httpsand validate the resolved hostname against an explicit allowlist such astool-gateway.linkfox.com. - Reject URLs containing user information, unexpected ports, fragments, or non-HTTPS schemes.
- Resolve and validate the final destination before attaching authorization headers.
- Do not send credentials to a redirected or otherwise changed origin.
- If custom endpoints are required for development, place them behind an explicit development-only option and use separate test credentials.
- Fail closed when endpoint validation fails and provide a diagnostic that does not reveal the API key.
- Require
