T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:139
- Finding
- API Key Exfiltration Through an Unvalidated Configurable Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 139-149 **Vulnerability Type**: Arbitrary credential destination / unvalidated API endpoint **Risk Level**: High ### Complete Code Snippet ```bash ## 2. Set the API URL (Optional) Defaults to production. For local development: export KARMA_API_URL="http://localhost:3002" ## 3. Verify Configuration curl -s "${KARMA_API_URL:-https://gapapi.karmahq.xyz}/v2/agent/info" \ -H "x-api-key: ${KARMA_API_KEY}" \ -H "X-Source: skill:setup-agent" -H "X-Invocation-Id: $INVOCATION_ID" -H "X-Skill-Version: 0.2.0" \ | python3 -m json.tool ``` The same configurable base URL is also used when registering a new agent: ```bash BASE_URL="${KARMA_API_URL:-https://gapapi.karmahq.xyz}" INVOCATION_ID=$(uuidgen) curl -s -X POST "${BASE_URL}/v2/agent/register" \ -H "Content-Type: application/json" \ -H "X-Source: skill:setup-agent" -H "X-Invocation-Id: $INVOCATION_ID" -H "X-Skill-Version: 0.2.0" \ -d '{}' ``` ### Technical Analysis The verification request sends `KARMA_API_KEY` in an HTTP header to a destination controlled by the inherited `KARMA_API_URL` environment variable. The Skill does not validate the URL scheme, hostname, port, or resolved destination before transmitting the credential. Although endpoint configurability can be legitimate for local development, accepting an arbitrary inherited URL for authenticated requests exceeds the minimum privileges necessary for normal production setup. In particular, the documented configuration permits plaintext HTTP and does not distinguish loopback development services from arbitrary remote hosts. An attacker able to influence the process environment, shell configuration, workspace configuration, or agent execution context can redirect the verification request to a server under the attacker's control. ### Attack Path 1. The attacker causes `KARMA_API_URL` to be set to an attacker-controlled endpoint. 2. The Skill obtains or loads a valid `KA ...[truncated 768 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Restrict authenticated production requests to an explicit allowlist of approved HTTPS hostnames. 2. Parse and validate `KARMA_API_URL` before use, including its scheme, hostname, port, and user-information component. 3. Reject plaintext HTTP except when the destination is an explicitly permitted loopback address used for local development. 4. Require informed user confirmation before sending a credential to any non-production endpoint. 5. Display the resolved destination without exposing the key before making an authenticated request. 6. Avoid inheriting security-sensitive endpoint overrides silently. Prefer an explicit command option or trusted configuration file with restrictive permissions. 7. Consider separating production and development flows so production credentials cannot be sent to development endpoints. ]]>
