T09 · Insecure Skill Coding Practices
- Location
scripts/weibo_cli.sh:4- Finding
Configurable API Base URLs Allow Credential Exfiltration
- Content
View full analysis
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: HighVulnerable 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_BASEbehavior also affects the user-timeline and topic-search commands.Technical Analysis
The script permits
WEIBO_REST_BASEandWEIBO_OAUTH_BASEto 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.comas the intended provider. It therefore exceeds the minimum network trust boundary required by the skill. It also permits plaintext HTTP endpoints if an override useshttp://.Attack Path
- An attacker gains influence over the process environment, deployment configuration, or an agent- ...[truncated 1154 chars]
- Remediation
View remediation
Remediation Suggestions
- 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" - If overrides are required for controlled testing, disable them by default and require an explicit test mode that never uses production credentials.
- 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.
- Add
curl --proto '=https'and fail closed when endpoint validation fails. - Ensure credentials are not forwarded across redirects to another origin. Prefer rejecting redirects entirely for OAuth and authenticated API calls.
- Add automated tests proving that HTTP URLs, unapproved hosts, deceptive subdomains, and malformed origins are rejected before request execution.
- Document any test-only endpoint customization and warn that production secrets must never be used with custom endpoints.
- Remove runtime base-URL overrides from production builds and use fixed official endpoints:
