T09 · Insecure Skill Coding Practices
- Location
resources/latex_convert_project/services/api/app/main.py:45- Finding
Unauthenticated Cross-Origin API Key Disclosure
- Content
View full analysis
dict: return read_ai_config() ``` ```python def read_ai_config() -> dict: _load_dotenv(overwrite=True) return { "api_key": os.environ.get("OPENAI_API_KEY") or os.environ.get("API_KEY") or "", "base_url": os.environ.get("OPENAI_BASE_URL") or os.environ.get("BASE_URL") or "https://api.openai.com/v1", "model": os.environ.get("OPENAI_MODEL") or os.environ.get("MODEL") or "gpt-4.1-mini", "batch_size": _env_int("AI_BATCH_SIZE", 10), "max_workers": _env_int("AI_MAX_WORKERS", 5), "failure_fallback": os.environ.get("AI_FAILURE_FALLBACK") or "rule", } ``` ### Technical Analysis The local FastAPI service enables wildcard CORS for every origin, method, and request header. It also exposes an unauthenticated configuration endpoint that returns the complete AI API key rather than a redacted value or an indication that a key is configured. Binding the service to `127.0.0.1` does not, by itself, establish an authorization boundary. A malicious website loaded in the user's browser can attempt to access loopback services. Where the browser permits the loopback request, the wildcard `Access-Control-Allow-Origin` response allows the malicious origin to read the API response. No authentication token, origin validation, or user confirmation protects the endpoint. The ...[truncated 1517 chars]- Remediation
View remediation
