T09 · Insecure Skill Coding Practices
- Location
scripts/kb_execute.py:58- Finding
Credentials and sensitive content can be transmitted to an unrestricted or plaintext destination
- Content
View full analysis
str: parsed = urllib.parse.urlparse(raw_url) if not parsed.scheme or not parsed.netloc: raise ValueError(f"invalid KB execute URL: {raw_url!r}") if parsed.path == EXECUTE_PATH: return urllib.parse.urlunparse(parsed) if parsed.path in ("", "/"): return urllib.parse.urlunparse(parsed._replace(path=EXECUTE_PATH, params="", query="", fragment="")) return urllib.parse.urlunparse(parsed) ``` ```python parser.add_argument( "--url", default=os.environ.get("KB_EXECUTE_URL"), help="AIS site URL or full KB execute endpoint. Defaults to env KB_EXECUTE_URL.", ) parser.add_argument( "--token", default=os.environ.get("KB_TOKEN"), help="KB token header value. Defaults to env KB_TOKEN.", ) ``` ```python headers = {"Content-Type": "application/json", **build_auth_headers(args.token), **headers} payload = json.dumps({"command": command}, ensure_ascii=False).encode("utf-8") request = urllib.request.Request( url=args.url, data=payload, headers=headers, method="POST", ) return send_request(request, args.timeout) ``` The same destination is also used by the upload and download operations, which attach authentication headers through `build_auth_headers(token)`. ### Technical Analysis The URL validation only requires a parsed scheme and network location. It does not require HTTPS, constrain the hostname to a trusted KB service, reject embedded URL credentials, or otherwise establish that the destination is authorized to receive the KB token and payload. Consequently, a value such as `http://attacker.example` is accepted. The script then sends an authentication token together with KB ...[truncated 1654 chars]- Remediation
View remediation
