T09 · Insecure Skill Coding Practices
Error
- Location
- noya-message.sh:18
- Finding
- Unvalidated API Base URL Override Can Exfiltrate Credentials and Sensitive Financial Messages## Vulnerability Details **File Location**: `noya-message.sh`, lines 18 and 35–39 **Vulnerability Type**: Unvalidated destination override causing credential and data disclosure **Risk Level**: High ### Vulnerable Code ```bash BASE_URL="${NOYA_BASE_URL:-https://safenet.one}" ``` ```bash HTTP_CODE=$(curl -s -w '%{http_code}' -o "$TMPFILE" \ -X POST "${BASE_URL}/api/messages/stream" \ -H "Content-Type: application/json" \ -H "x-api-key: ${NOYA_API_KEY}" \ -H "x-timezone-name: ${TIMEZONE}" \ -d "$(jq -n --arg msg "$MESSAGE" --arg tid "$THREAD_ID" \ '{message: $msg, threadId: $tid}')") ``` ### Technical Analysis The script permits the `NOYA_BASE_URL` environment variable to replace the intended API origin, `https://safenet.one`, without validating the URL scheme or hostname. The resulting destination receives the `NOYA_API_KEY` header, the user-supplied message, and the thread identifier. An attacker who can influence the process environment, a wrapper script, shell initialization, CI configuration, or Skill runtime configuration can redirect the request to an attacker-controlled server. This behavior exceeds the minimum privilege needed for the declared functionality because normal operation only requires communication with the documented Noya API. The request data may include portfolio questions, wallet information, swap or bridge parameters, intended transfers, prediction-market orders, DCA instructions, and other sensitive financial intent. The remote response is also presented as trusted agent output, allowing an attacker-controlled endpoint to provide fabricated market information or deceptive transaction prompts. ### Attack Path 1. The attacker gains the ability to set or influence an environment variable used by the Skill. 2. The attacker sets `NOYA_BASE_URL` to an endpoint they control, such as `https://attacker.example`. 3. The user invokes `noya-message.sh` through the documented workflow. 4. The script sends an HTTPS request to `h ...[truncated 1308 chars]
- Remediation
- ## Remediation Suggestions 1. Remove the base URL override if custom API origins are not essential: ```bash readonly BASE_URL="https://safenet.one" ``` 2. If an override is operationally necessary, enforce HTTPS and an explicit hostname allowlist before sending credentials: ```bash BASE_URL="${NOYA_BASE_URL:-https://safenet.one}" case "$BASE_URL" in "https://safenet.one") ;; *) echo "Error: untrusted NOYA_BASE_URL" >&2 exit 1 ;; esac ``` 3. Reject URLs containing user information, fragments, query strings, unexpected ports, or path components. Prefer parsing and validating the URL with a robust URL parser rather than shell pattern matching if multiple trusted origins are supported. 4. Keep redirects disabled when transmitting the API key. If redirects are later enabled, never forward authentication headers across origins. 5. Document every approved API hostname and the data sent to it. Require explicit administrator configuration rather than accepting an ambient environment variable silently. 6. Use short-lived, narrowly scoped API keys and rotate the key immediately if exposure is suspected. Server-side authorization should independently enforce transaction confirmation and least privilege. 7. Clearly distinguish the trusted service origin in user-facing output so responses from development or alternate environments cannot be mistaken for production responses.
