T09 · Insecure Skill Coding Practices
- Location
skill.js:4- Finding
Bearer Credential Transmission to an Unrestricted Configurable Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
skill.js, lines 4–17
Vulnerability Type: Unrestricted credential-bearing network request
Risk Level: HighVulnerable Code
javascript const API_KEY = env.API_KEY; const API_BASE = env.API_BASE; const MODEL_NAME = env.MODEL_NAME; const res = await fetch(`${API_BASE}/img2video`, { method: "POST", headers: { "Authorization": "Bearer " + API_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ model: MODEL_NAME, image_url: image_url }) });Technical Analysis
The Skill constructs its request destination directly from the configurable
API_BASEvalue and transmitsAPI_KEYin theAuthorizationheader. It does not parse or validate the URL, require HTTPS, restrict the destination to approved provider hosts, reject embedded credentials, or constrain ports.Although an outbound request is necessary for the declared image-to-video functionality, sending a secret to an arbitrary configured destination exceeds safe least-privilege boundaries. A malicious or incorrectly configured
API_BASEcan direct the request to an attacker-controlled server. A plaintext HTTP endpoint can also expose the credential and submitted data to network interception.The request additionally discloses
MODEL_NAMEand the user-suppliedimage_urlto the selected endpoint. Depending on the URL, the image address may itself contain sensitive identifiers, signed query parameters, or access tokens.Attack Path
- An attacker, compromised deployment process, or configuration error changes
API_BASEto an attacker-controlled URL or a plaintext HTTP endpoint. - A user invokes the Skill with an
image_url. - The Skill appends
/img2videoto the unvalidated base URL. - It sends
Authorization: Bearer <API_KEY>,MODEL_NAME, andimage_urlto that endpoint. - The attacker captures the API credential and subm ...[truncated 779 chars]
- An attacker, compromised deployment process, or configuration error changes
- Remediation
View remediation
Remediation Suggestions
- Parse
API_BASEwithnew URL()before constructing the request. - Require the
https:protocol and reject plaintext HTTP. - Enforce an explicit allowlist of approved image-to-video provider hostnames rather than accepting an arbitrary network destination.
- Reject URLs containing embedded usernames or passwords, unexpected ports, fragments, or unsupported schemes.
- Build the endpoint using URL APIs rather than direct string interpolation.
- Scope the API key to only the required image-to-video operation, with minimal quotas and no unrelated resource permissions.
- Use separate credentials for different providers or environments and rotate the key if it may have been exposed.
- Validate
image_urlaccording to provider requirements and warn users not to submit URLs containing reusable credentials or sensitive signed parameters. - Fail closed when endpoint validation fails and avoid including secrets in error messages or logs.
Example hardening pattern:
javascript const approvedHosts = new Set(["api.example-provider.com"]); const base = new URL(env.API_BASE); if ( base.protocol !== "https:" || !approvedHosts.has(base.hostname) || base.username || base.password || (base.port && base.port !== "443") ) { throw new Error("Invalid API endpoint configuration"); } const endpoint = new URL("/img2video", base);- Parse
