T09 · Insecure Skill Coding Practices
- Location
scripts/meshy_client.py:42- Finding
Unvalidated API Base URL Can Expose the Meshy API Key
- Content
View full analysis
Vulnerability Details
File Location:
scripts/meshy_client.py, lines 42-62
Vulnerability Type: Credential disclosure through an unvalidated endpoint override
Risk Level: MediumVulnerable Code
python def _headers_json() -> Dict[str, str]: api_key = _get_env("MESHY_API_KEY") return { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", "Accept": "application/json", } def _base_url() -> str: return os.environ.get("MESHY_BASE_URL", DEFAULT_BASE_URL).rstrip("/") def _request(method: str, path: str, *, body: Optional[dict] = None) -> Any: url = f"{_base_url()}{path}" data = None if body is not None: data = json.dumps(body).encode("utf-8") req = urllib.request.Request(url, method=method, headers=_headers_json(), data=data)Technical Analysis
The application allows
MESHY_BASE_URLto control the destination of authenticated API requests. It does not validate the URL scheme, hostname, port, user information, or other URL components before attaching theMESHY_API_KEYas a bearer token.Consequently, an attacker who can influence the process environment or configuration can redirect requests to an attacker-controlled server. Because plaintext HTTP is also accepted, the token could additionally be exposed through network interception. Prompt text and Base64-encoded local image content included in request bodies would be sent to the same unauthorized endpoint.
Attack Path
- An attacker gains the ability to influence the environment or configuration used to launch either generation script.
- The attacker sets
MESHY_BASE_URLto an endpoint under their control, such ashttp://attacker.example. - A user invokes
scripts/text_to_image.pyorscripts/image_to_3d_obj.py. _request()constructs the API URL from the attacker-controlled base URL._headers_json()attaches `A ...[truncated 766 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
MESHY_BASE_URLsupport if custom endpoints are not operationally necessary. - If an override is required, parse it with
urllib.parse.urlsplitand require thehttpsscheme. - Maintain an explicit allowlist of trusted Meshy API hostnames and reject all other destinations before constructing authenticated requests.
- Reject URLs containing user information, fragments, unexpected ports, or ambiguous host representations.
- Attach the
Authorizationheader only after the final request destination has passed validation. - Ensure redirects cannot forward the authorization header to a different origin. Disable redirects or validate every redirect destination before following it.
- Avoid logging the bearer token and rotate the Meshy API key immediately if it may have been exposed.
- Document the security implications of endpoint overrides and ensure untrusted users cannot modify the execution environment.
- Remove
