T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/weibo_cli.sh:4
- Finding
- Configurable API Base URLs Allow Credential Exfiltration## Vulnerability Details **File Location**: `scripts/weibo_cli.sh:4-5, 149-153, 167-168, 183-187` **Vulnerability Type**: Unrestricted credential destination / sensitive-data exposure **Risk Level**: High ### Vulnerable Code ```bash REST_BASE="${WEIBO_REST_BASE:-https://api.weibo.com/2}" OAUTH_BASE="${WEIBO_OAUTH_BASE:-https://api.weibo.com/oauth2}" ``` ```bash api_request POST "${OAUTH_BASE}/access_token" \ --data-urlencode "client_id=${WEIBO_APP_KEY}" \ --data-urlencode "client_secret=${WEIBO_APP_SECRET}" \ --data-urlencode "grant_type=authorization_code" \ --data-urlencode "redirect_uri=${redirect_uri}" \ --data-urlencode "code=${code}" ``` ```bash api_request POST "${OAUTH_BASE}/get_token_info" \ --data-urlencode "access_token=${token}" ``` ```bash api_request GET "${REST_BASE}/statuses/public_timeline.json" \ --get \ --data-urlencode "access_token=${token}" \ --data-urlencode "count=${count}" \ --data-urlencode "page=${page}" ``` The same `REST_BASE` behavior also affects the user-timeline and topic-search commands. ### Technical Analysis The script permits `WEIBO_REST_BASE` and `WEIBO_OAUTH_BASE` to override the documented official Weibo endpoints. It does not validate the resulting scheme, hostname, port, or origin before attaching sensitive credentials. Consequently, ordinary documented operations may transmit the following secrets to a caller-selected server: - `WEIBO_APP_SECRET` - OAuth authorization code - `WEIBO_ACCESS_TOKEN` - OAuth and request metadata This behavior is not necessary for the declared functionality, which identifies `https://api.weibo.com` as the intended provider. It therefore exceeds the minimum network trust boundary required by the skill. It also permits plaintext HTTP endpoints if an override uses `http://`. ### Attack Path 1. An attacker gains influence over the process environment, deployment configuration, or an agent- ...[truncated 1154 chars]
- Remediation
- ## Remediation Suggestions 1. Remove runtime base-URL overrides from production builds and use fixed official endpoints: ```bash readonly REST_BASE="https://api.weibo.com/2" readonly OAUTH_BASE="https://api.weibo.com/oauth2" ``` 2. If overrides are required for controlled testing, disable them by default and require an explicit test mode that never uses production credentials. 3. Parse and validate every endpoint before sending secrets: - Require HTTPS. - Allow only the exact hostname `api.weibo.com`. - Reject embedded credentials, unexpected ports, fragments, and alternate origins. 4. Add `curl --proto '=https'` and fail closed when endpoint validation fails. 5. Ensure credentials are not forwarded across redirects to another origin. Prefer rejecting redirects entirely for OAuth and authenticated API calls. 6. Add automated tests proving that HTTP URLs, unapproved hosts, deceptive subdomains, and malformed origins are rejected before request execution. 7. Document any test-only endpoint customization and warn that production secrets must never be used with custom endpoints.
