T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/fgo_cli.py:82
- Finding
- Configurable API Base URL Allows Sensitive Invoice Data Exfiltration<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fgo_cli.py:82-84`, `scripts/fgo_cli.py:144-146`, and `scripts/fgo_cli.py:177` **Vulnerability Type**: Unrestricted destination for authenticated network requests **Risk Level**: High ### Complete Code Snippet ```python base_url_arg = getattr(args, "base_url", None) base_url = base_url_arg if base_url_arg is not None else os.getenv( "FGO_API_BASE", DEFAULT_BASE_URL ) ``` ```python url = f"{self.config.base_url}{path}" if query: compact_query = {k: v for k, v in query.items() if v is not None} if compact_query: url = f"{url}?{urlencode(compact_query)}" ``` ```python request = Request(url=url, data=payload, headers=headers, method=method) try: with urlopen(request, timeout=self.config.timeout_seconds) as response: response_body = response.read() ``` ### Technical Analysis The CLI permits the API base URL to be supplied through either the global `--base-url` argument or the `FGO_API_BASE` environment variable. It does not validate the URL scheme or restrict the destination hostname. Authenticated FGO operations send form-encoded bodies containing company identifiers, operation-specific authentication hashes, invoice numbers, and potentially customer PII and financial information. Invoice issuance may additionally transmit names, addresses, email addresses, phone numbers, bank details, line items, and pricing. Custom API destinations can be useful during development, but unrestricted production behavior exceeds the minimum network privileges required for the declared FGO functionality. The normal Skill only needs to communicate with the production and UAT FGO hosts. ### Attack Path 1. An attacker influences the process environment, command arguments, wrapper configuration, or agent-generated command. 2. The attacker sets `FGO_API_BASE` or `--base-url` to an attacker-controlled endpoint, such as `https://attacker.example/v1`. 3. A user or agent invokes `emit-invoic ...[truncated 1011 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse the configured URL and require the `https` scheme. 2. Allowlist the documented FGO hosts: - `api.fgo.ro` - `api-testuat.fgo.ro` 3. Reject embedded credentials, fragments, unexpected ports, and hostnames that only end with or resemble an allowed domain. 4. If custom development endpoints are required, place them behind a separate, conspicuous option such as `--allow-custom-api-host`. 5. Require explicit confirmation when a custom host is used and never enable it solely through an inherited environment variable. 6. Display the selected environment and hostname before high-impact operations. 7. Consider certificate pinning or additional server identity verification where operationally practical. ]]>
