T09 · Insecure Skill Coding Practices
- Location
scripts/generate_doc_illustration.py:118- Finding
Arbitrary API Endpoint Can Receive Credentials and Sensitive User Content
- Content
View full analysis
tuple[str | None, str | None]: api_key = os.getenv("OPENAI_API_KEY") base_url = os.getenv("OPENAI_BASE_URL") if api_key: return api_key, base_url ``` At `scripts/generate_doc_illustration.py:242-248`, both the credential and unrestricted endpoint are passed to the OpenAI client: ```python def build_client(api_key: str | None, base_url: str | None) -> OpenAI: kwargs: dict[str, Any] = {} if api_key: kwargs["api_key"] = api_key if base_url: kwargs["base_url"] = base_url return OpenAI(**kwargs) ``` At `scripts/generate_doc_illustration.py:326-328`, the resulting client is used for live generation: ```python api_key, base_url = get_api_settings(require_key=True) model_name = resolve_model_name(base_url) client = build_client(api_key, base_url) ``` The documented policy also permits unknown providers. At `references/openai-image-workflow.md:27-31`: ```markdown ## Provider-specific model mapping - Official OpenAI base URL: use `gpt-image-2` - `https://aihubmix.com/v1`: use `gpt-image-2` - `https://api.ofox.ai/v1`: use `openai/gpt-image-2` - Unknown providers: default to `gpt-image-2` unless the provider documents a namespaced variant ``` ### Technical Analysis `OPENAI_BASE_URL` crosses a security trust boundary because it determines which remote server receives authenticated image-generation requests. The script does not validate the URL scheme, hostname, port, or provider identity before combining t ...[truncated 2819 chars]- Remediation
View remediation
