T09 · Insecure Skill Coding Practices
- Location
SKILL.md:141- Finding
Unrestricted API Endpoint Enables Server-Side Request Forgery and Credential Forwarding
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:141-148
Vulnerability Type: Unrestricted outbound request target
Risk Level: HighVulnerable Code
python import requests # ... def call_api(endpoint, method='GET', data=None, headers=None): response = requests.request( method=method, url=endpoint, json=data, headers=headers ) response.raise_for_status() return response.json()Technical Analysis
The generic API wrapper sends a request to the caller-controlled
endpointwithout validating its scheme, hostname, resolved address, port, or redirect destination. If untrusted input can influence this parameter, the function becomes a server-side request forgery primitive.An attacker could direct the agent toward loopback addresses, private network services, link-local addresses, or cloud instance metadata endpoints. Because the function also accepts arbitrary
headers, authentication credentials intended for a legitimate API may be forwarded to an attacker-controlled destination.URL validation based only on the original hostname would be insufficient because redirects and DNS resolution could still lead to prohibited addresses. Validation must cover both the initial URL and every redirect destination.
Attack Path
- An attacker supplies an API integration request containing an internal or attacker-controlled URL.
- The agent passes that URL to
call_api()asendpoint. - The function invokes
requests.request()without destination validation. - The request reaches an internal service, cloud metadata endpoint, or attacker-operated server.
- If authorization headers were supplied, they are transmitted to the selected destination.
- The response may expose internal service data or credentials to the attacker through the agent's output.
Impact Assessment
Successful exploitation may permit access to network reso ...[truncated 552 chars]
- Remediation
View remediation
Remediation Suggestions
- Accept only HTTPS URLs unless another protocol is explicitly required.
- Maintain an explicit allowlist of permitted API hostnames and ports.
- Resolve hostnames before connecting and reject loopback, link-local, private, multicast, and reserved IP ranges.
- Revalidate the resolved address at connection time to reduce DNS rebinding risk.
- Disable redirects where possible. Otherwise, validate every redirect destination before following it.
- Do not accept arbitrary caller-provided authentication headers. Construct credentials internally for the approved destination.
- Bind each credential to a specific hostname and never forward it when the destination host changes.
- Apply outbound firewall or proxy rules so the agent cannot reach metadata services or unrelated internal networks.
- Sanitize response data before returning it to prevent inadvertent disclosure of credentials or internal information.
