T09 · Insecure Skill Coding Practices
- Location
scripts/openmath_env_config.py:197- Finding
Unvalidated API Endpoint Can Supply Executable Theorem Source
- Content
View full analysis
str: env_override = normalize_url(os.environ.get("OPENMATH_API_HOST")) if env_override: return env_override return default_openmath_api_host() ``` `scripts/openmath_api.py:73-84`: ```python def fetch_theorem_detail(theorem_id: int) -> TheoremRecord: try: api_host = resolve_openmath_api_host() except OpenMathEnvConfigError as exc: raise RuntimeError(str(exc)) from exc url = f"{api_host}/api/v1/theorems/{theorem_id}" result = fetch_json(url, "openmath-open-theorem/fetch_theorem_detail.py") ensure_success(result) theorem = result.get("data") if not theorem: raise RuntimeError(f"Theorem with ID {theorem_id} not found.") ``` `scripts/download_theorem.py:112-116`: ```python def scaffold_lean(project_dir: Path, theorem: TheoremRecord) -> str: module_name = lean_module_name(theorem.theorem_id) theorem_file = project_dir / f"{module_name}.lean" theorem_code = theorem.theorem_code or f"-- TODO: Fill in theorem {theorem.theorem_id}\n" theorem_file.write_text(theorem_code.rstrip() + "\n", encoding="utf-8") ``` The equivalent Rocq path writes remote theorem source verbatim at `scripts/download_theorem.py:132-135`. ### Technical Analysis The `OPENMATH_API_HOST` environment variable is accepted after only trimming whitespace and a trailing slash. The code does not: - Restrict the URL to HTTPS. - Verify that the hostname belongs to an approved OpenMath domain. - Require confirmation before using a custom endpoint. - Authenticate the returned ...[truncated 2605 chars]- Remediation
View remediation
