T09 · Insecure Skill Coding Practices
Error
- Location
- feishu_publisher.py:152
- Finding
- Feishu Credentials and Access Tokens Can Be Sent to an Arbitrary or Plaintext Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `feishu_publisher.py:152-173, 206-219, 228-236` **Vulnerability Type**: Arbitrary authentication endpoint and missing HTTPS enforcement **Risk Level**: High ### Complete Code Snippet ```python def _resolve_credentials(self) -> FeishuCredentials: """Resolve app credentials from args > env > openclaw.json.""" app_id = self.app_id or os.getenv("FEISHU_APP_ID", "").strip() app_secret = self.app_secret or os.getenv("FEISHU_APP_SECRET", "").strip() domain = self.domain or os.getenv("FEISHU_DOMAIN", "").strip() if not app_id or not app_secret or not domain: ocfg = self._read_openclaw_feishu_config() app_id = app_id or str(ocfg.get("appId") or "").strip() app_secret = app_secret or str(ocfg.get("appSecret") or "").strip() domain = domain or str(ocfg.get("domain") or "").strip() if not app_id or not app_secret: raise FeishuPublishError( "Missing Feishu app credentials. Set FEISHU_APP_ID/FEISHU_APP_SECRET " "or configure channels.feishu.appId/appSecret in openclaw.json" ) return FeishuCredentials( app_id=app_id, app_secret=app_secret, domain=domain or "feishu", ) @staticmethod def _default_openclaw_config_path() -> Path: openclaw_home = os.getenv("OPENCLAW_HOME", "").strip() if openclaw_home: return Path(openclaw_home).expanduser().resolve() / "openclaw.json" return Path.home().resolve() / ".openclaw" / "openclaw.json" @staticmethod def _domain_to_api_base(domain: str) -> str: value = (domain or "feishu").strip().lower().rstrip("/") if value.startswith("http://") or value.startswith("https://"): return value if value == "lark": return "https://open.larksuite.com" return "https://open.feishu.cn" def _get_tenant_access_token( self, *, api_base: str, app_id: str, app_secret: str ) -> str: if self._tenant_access_token: ret ...[truncated 2005 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace arbitrary domain handling with a strict allowlist: - `https://open.feishu.cn` - `https://open.larksuite.com` 2. Reject all `http://` URLs and any URL containing user information, unexpected ports, fragments, or nonstandard paths. 3. Do not allow environment variables or general channel configuration to provide an unrestricted API base URL. 4. Disable or strictly validate redirects so credentials cannot be redirected to another hostname. 5. Resolve the hostname and apply egress controls where possible. 6. Keep credentials in a dedicated secret manager and grant the Feishu application only the document and wiki scopes required for publishing. 7. Add tests confirming that arbitrary hosts and plaintext endpoints are rejected before credentials are loaded or transmitted. ]]>
