T09 · Insecure Skill Coding Practices
- Location
tools/run-security-tests.py:188- Finding
API Credentials and System Prompts Can Be Transmitted to an Untrusted Endpoint
- Content
View full analysis
str: """Send a single prompt to an OpenAI-compatible chat completions endpoint.""" headers = { "Content-Type": "application/json", } if api_key: headers["Authorization"] = f"Bearer {api_key}" messages = [] if system_prompt: messages.append({"role": "system", "content": system_prompt}) messages.append({"role": "user", "content": prompt}) payload = { "model": model, "messages": messages, "max_tokens": 500, "temperature": 0, } try: resp = requests.post(endpoint, headers=headers, json=payload, timeout=timeout) ``` The endpoint and API key are accepted directly from command-line arguments or environment variables: ```python parser.add_argument( "--endpoint", default=os.environ.get("AGENT_TEST_ENDPOINT"), help="OpenAI-compatible chat completions URL (or set AGENT_TEST_ENDPOINT)", ) parser.add_argument( "--api-key", default=os.environ.get("AGENT_TEST_API_KEY", ""), help="API key (or set AGENT_TEST_API_KEY). Optional for local endpoints.", ) ``` A complete system prompt can also be read from a local file and sent to that endpoint: ```python system_prompt = None if args.system_prompt_file: with open(args.system_prompt_file) as f: system_prompt = f.read().strip() success = run_tests( endpoint=args.endpoint, api_key=args.api_key, model=args.model, owner_name=args.owner_name, agent_name=args.agent_name, system_prompt=system_prompt, output_js ...[truncated 2586 chars]- Remediation
View remediation
