T09 · Insecure Skill Coding Practices
- Location
typecho-cli:20- Finding
Bearer Token and Blog Content Can Be Transmitted over Unencrypted HTTP
- Content
View full analysis
环境变量 > 配置文件""" domain = None token = None # 1. 配置文件 if os.path.exists(DEFAULT_CONFIG_PATH): try: with open(DEFAULT_CONFIG_PATH, "r", encoding="utf-8") as f: cfg = json.load(f) domain = cfg.get("domain") token = cfg.get("token") except Exception: pass # 2. 环境变量 domain = os.environ.get("TYPECHO_DOMAIN", domain) token = os.environ.get("TYPECHO_TOKEN", token) # 3. 命令行参数 if getattr(args, "domain", None): domain = args.domain if getattr(args, "token", None): token = args.token if not domain or not token: print(json.dumps({ "success": False, "message": "缺少配置:请设置 domain 和 token。方式:\n" f"1. 写入配置文件 {DEFAULT_CONFIG_PATH}\n" "2. 环境变量 TYPECHO_DOMAIN / TYPECHO_TOKEN\n" "3. 命令行参数 --domain / --token" })) sys.exit(1) return domain.rstrip("/"), token def api_call(domain, token, payload): """发送 API 请求""" url = f"{domain}/index.php/action/openclaw-submit" data = json.dumps(payload).encode("utf-8") req = urllib.request.Request( url, data=data, headers={ "Content-Type": "application/json", "Authorization": f"Bearer {token}", }, method="POST", ) ``` ### Technical Analysis The CLI accepts the API domain from a configuration file, an environment variable, or a command-line argument without parsing the URL or requiring HTTPS. It then attaches the Typecho token as an HTTP bearer credential and sends the request payload to that domain. If the configured d ...[truncated 1875 chars]- Remediation
View remediation
