T09 · Insecure Skill Coding Practices
- Location
scripts/coze_image_skill.py:153- Finding
Bearer Token Disclosure Through a Caller-Controlled API Endpoint
- Content
View full analysis
None: self.url = url self.project_id = project_id self.session_id = session_id self.timeout = timeout self.headers = { "Authorization": f"Bearer {api_token}", "Content-Type": "application/json", "Accept": "text/event-stream", } ``` ```python response = requests.post( self.url, headers=self.headers, json=self._build_payload(prompt), stream=True, timeout=self.timeout, ) response.raise_for_status() ``` ```python def run(params: Dict[str, Any]) -> Dict[str, Any]: prompt = params.get("text") or params.get("prompt") or "" api_token = params.get("api_token") or os.environ.get("IMAGE_API_TOKEN") api_url = params.get("api_url") or os.environ.get("IMAGE_API_URL", "https://6fj9k4p9x3.coze.site/stream_run") project_id = params.get("project_id") or os.environ.get("IMAGE_API_PROJECT_ID", "7621854258107039796") session_id = params.get("session_id") or os.environ.get("IMAGE_API_SESSION_ID", "mT8SQeCGgTMZNBsJEiRuN") timeout = int(params.get("timeout") or os.environ.get("IMAGE_API_TIMEOUT", "60")) include_debug = _bool_param(params.get("include_debug")) strict_mode = _bool_param(params.get("strict")) try: if not api_token: raise RuntimeError("Missing IMAGE_API_TOKEN environment variable or params['api_token']") if not project_id: raise RuntimeError("Missing IMAGE_API_PROJECT_ID environment variable or params['project_id']") if not session_id: raise RuntimeError("Missing IMAGE_API_SESSION_ID environment variable or params['session_id']") client = Coz ...[truncated 2245 chars]- Remediation
View remediation
