T09 · Insecure Skill Coding Practices
- Location
scripts/runtime/tonghuashun_ifind_skill/auth.py:80- Finding
Caller-Controlled API Base URL Can Exfiltrate iFinD Credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ifind_cli.py:107-114,scripts/ifind_cli.py:180-183,scripts/ifind_cli.py:218-242,scripts/runtime/tonghuashun_ifind_skill/auth.py:80-92, andscripts/runtime/tonghuashun_ifind_skill/client.py:25-44
Vulnerability Type: Unrestricted credential transmission to a caller-controlled network destination
Risk Level: HighVulnerable Code
scripts/ifind_cli.py:107-114:python auth_refresh = subparsers.add_parser("auth-set-refresh-token") auth_refresh.add_argument("--refresh-token", required=True) auth_refresh.add_argument("--base-url", default=DEFAULT_BASE_URL) api_common = argparse.ArgumentParser(add_help=False) api_common.add_argument("--base-url", default=DEFAULT_BASE_URL) api_common.add_argument("--payload", default="{}")scripts/ifind_cli.py:180-183:python bundle = exchange_refresh_token( args.refresh_token, base_url=args.base_url, )scripts/runtime/tonghuashun_ifind_skill/auth.py:80-92:python def exchange_refresh_token( refresh_token: str, *, base_url: str, timeout: float = 10.0, now: Callable[[], datetime] | None = None, ) -> TokenBundle: response = requests.post( f"{base_url.rstrip('/')}/get_access_token", json={}, headers={"Content-Type": "application/json", "refresh_token": refresh_token}, timeout=timeout, ) response.raise_for_status()scripts/runtime/tonghuashun_ifind_skill/client.py:25-44:python def api_call( self, endpoint: str, payload: dict[str, object], access_token: str, token_source: str, ) -> dict[str, object]: normalized_endpoint = self._normalize_endpoint(endpoint) url = f"{self.base_url}{normalized_endpoint}" headers = {"Content-Type": "application/json", "access_token": access_token} timestamp = format_timestamp(self._now()) ...[truncated 2373 chars]- Remediation
View remediation
Remediation Suggestions
- Remove
--base-urlfrom production authentication and data-query commands. Use a fixed official iFinD HTTPS origin. - If endpoint configurability is operationally required, parse the URL and strictly allowlist approved hostnames, schemes, and ports.
- Require HTTPS and reject plaintext HTTP, URL-embedded credentials, fragments, unexpected ports, and malformed hostnames.
- Disable redirects for credential-bearing requests or validate every redirect target and reject cross-origin redirects.
- Separate test and production modes. A test mode that permits custom endpoints must use test credentials and require an explicit development-only setting.
- Add security tests proving that unapproved hosts, HTTP URLs, deceptive subdomains, and cross-origin redirects cannot receive tokens.
- Rotate any credentials that may already have been sent to an untrusted endpoint.
- Remove
