T09 · Insecure Skill Coding Practices
- Location
scripts/generate.mjs:32- Finding
Unrestricted Endpoint Allows API Credential Exfiltration and Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.mjs, lines 32–58
Vulnerability Type: Unvalidated outbound request destination and credential forwarding
Risk Level: MediumVulnerable Code
javascript const endpoint = env.FLUX_ENDPOINT; const apiKey = env.FLUX_API_KEY; if (!endpoint || !apiKey) { console.error("Error: Set FLUX_ENDPOINT and FLUX_API_KEY environment variables"); exit(1); } if (!args.prompt) { console.error("Error: --prompt is required"); exit(1); } const body = { prompt: args.prompt, width: args.width || 1024, height: args.height || 1024, n: 1, model: "FLUX.2-pro", }; if (args.seed !== undefined) body.seed = args.seed; console.error(`Generating: "${args.prompt}" (${body.width}x${body.height})...`); const res = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, },Technical Analysis
The script obtains the destination URL directly from the
FLUX_ENDPOINTenvironment variable and uses it without parsing or validating it. It does not require HTTPS, verify that the hostname belongs to Azure AI Foundry, reject embedded URL credentials, or restrict requests to an explicit allowlist.The request includes
FLUX_API_KEYin theAuthorizationheader. Consequently, the bearer credential and image-generation prompt are transmitted to any destination selected throughFLUX_ENDPOINT. This creates a credential-forwarding vulnerability when an attacker can influence the skill configuration, deployment environment, shell profile, or process environment.The same behavior can be used as a server-side request forgery primitive. The script may issue a POST request to loopback, private-network, link-local, or other internal addresses reachable from the agent environment. Although the fixed JSON request format limits arbitrary interaction, the request ...[truncated 1730 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse
FLUX_ENDPOINTwith the standardURLclass before making any request. - Require the
https:protocol and reject plaintext HTTP or unsupported schemes. - Enforce an explicit allowlist of trusted Azure AI Foundry hostnames. Do not rely on substring or suffix checks that can accept deceptive domains.
- Verify the expected endpoint path and API version where practical.
- Reject URLs containing a username, password, unexpected port, fragment, or other unnecessary components.
- Resolve and reject loopback, link-local, private, and reserved network destinations if custom hosts must be supported.
- Keep the API key scoped to only the required Azure resource and rotate it if it may have been exposed.
- Apply outbound network controls so the runtime can communicate only with approved Azure endpoints.
- Document that
FLUX_ENDPOINTis security-sensitive configuration and must not be influenced by untrusted users.
A basic validation pattern should resemble:
javascript const endpointUrl = new URL(env.FLUX_ENDPOINT); const allowedHosts = new Set([ "expected-resource.services.ai.azure.com", ]); if ( endpointUrl.protocol !== "https:" || !allowedHosts.has(endpointUrl.hostname) || endpointUrl.username || endpointUrl.password ) { throw new Error("Untrusted FLUX endpoint"); }- Parse
