T09 · Insecure Skill Coding Practices
- Location
feishu.py:267- Finding
Agent-Callable Tool Exposes a Tenant Access Token Fragment
- Content
View full analysis
Dict[str, Any]: """ Get Feishu tenant access token. Returns: Dictionary with token info """ client = _get_client() if not client: return {"success": False, "error": "Feishu not configured"} token = client.get_token(force_refresh=True) if token: return {"success": True, "token": token[:20] + "..."} else: return {"success": False, "error": "Failed to get token"} ``` The function is registered as an Agent-callable tool at lines 325-328: ```python { "name": "feishu_get_token", "description": "Get Feishu tenant access token" } ``` ### Technical Analysis Tenant access-token retrieval is an internal authentication operation. It is not necessary for an Agent to directly access token material to send messages, create chats, or list chats because those operations already acquire and apply the token internally. The function forces a token refresh and returns the first 20 characters of the live token. Although the token is truncated, the returned value is still credential material and may be retained in Agent context, execution traces, telemetry, application logs, or user-visible output. Truncation reduces the likelihood of immediate account compromise but does not make disclosure safe. Exposing authentication internals also violates least privilege by allowing arbitrary tool callers to trigger credential operations unrelated to the declared end-user functionality. ### Attack Path 1. Untrusted content or a user request causes the Agent to invoke `feishu_get_token`. 2. The tool calls `get_token(force_refresh=True)`. 3. The client transmits the configured application credentials to Feishu and obtains a live tenant access token. 4. The f ...[truncated 846 chars]- Remediation
View remediation
Dict[str, Any]: client = _get_client() if not client: return { "success": False, "configured": False, "token_valid": False } token = client.get_token() return { "success": bool(token), "configured": True, "token_valid": bool(token) } ``` 6. Ensure logs and telemetry redact authorization headers, application secrets, and token values. 7. Avoid forced token refreshes unless an actual API operation requires a refreshed token. ]]>
