T09 · Insecure Skill Coding Practices
- Location
scripts/medo_api.py:786- Finding
Bearer API Key and User Data Can Be Sent to an Arbitrary Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/medo_api.py:35-43,scripts/medo_api.py:76-82, andscripts/medo_api.py:786-789
Vulnerability Type: Unrestricted authenticated API destination
Risk Level: HighVulnerable Code
python def auth_headers(api_key: str) -> dict: """Return HTTP headers with Bearer token authentication, JSON content type, and custom User-Agent.""" return { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", "User-Agent": f"medo-app-builder/{CLIENT}-{VERSION}", }python url = f"{base_url.rstrip('/')}/api/v1/app/list" payload = { "name": name, "page": page, "size": size, "sort": {"direction": "desc", "property": "updatedAt"}, } resp = requests.post(url, json=payload, headers=auth_headers(api_key), timeout=30)python parser.add_argument( "--base-url", default=os.environ.get("MEDO_BASE_URL", DEFAULT_BASE_URL), help=f"Platform host URL (default: {DEFAULT_BASE_URL})", )The same authenticated-request pattern is also used at lines 114, 236, 284, 371, 446, 535, 715, and 727.
Technical Analysis
The CLI accepts the API base URL from either the
MEDO_BASE_URLenvironment variable or the--base-urlcommand-line option. This value is used without scheme validation, hostname validation, or an allowlist. The CLI then attaches the Medo bearer token to requests made to the resulting URL.Network access and bearer authentication are necessary for the Skill's declared app-building functionality. However, allowing unrestricted control over the destination of authenticated requests exceeds the minimum privilege required to communicate with the declared Medo service.
In addition to the API key, affected requests can disclose user prompts, app identifiers, conversation identifiers, release identifiers, and app-management operations. Chat requests can co ...[truncated 1646 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
--base-urlandMEDO_BASE_URLsupport if custom endpoints are not required. - If endpoint overrides are necessary for testing, validate the normalized URL before attaching credentials:
- Require HTTPS.
- Reject embedded user information.
- Reject unexpected ports.
- Permit only an explicit allowlist of trusted Medo hostnames.
- Resolve and compare the final hostname rather than using substring or suffix checks that can be bypassed.
- Separate production and development credentials, and require explicit user confirmation before sending a credential to a non-production endpoint.
- Configure redirect handling so authorization headers are never forwarded to a different origin. Prefer disabling redirects for authenticated API calls unless they are explicitly required.
- Avoid accepting security-sensitive endpoint configuration from an ambient environment where untrusted launchers or inherited variables can alter it.
- Add tests confirming that HTTP URLs, lookalike domains, subdomain tricks, unexpected ports, and cross-origin redirects are rejected.
- Rotate any API key suspected of having been used while
MEDO_BASE_URLor--base-urlwas controlled by an untrusted party.
- Remove
