T09 · Insecure Skill Coding Practices
- Location
scripts/xiaoka.sh:10- Finding
Environment-Controlled API Endpoint Can Exfiltrate Stored Credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/xiaoka.sh:10, 17-18, 136-139, 168-169
Vulnerability Type: Unvalidated API endpoint override leading to credential and data disclosure
Risk Level: MediumVulnerable Code
bash API_BASE="${XIAOKA_API_BASE:-${XIAOKA_API:-https://cal-cn.ishuohua.cn}}" API_KEY="${XIAOKA_API_KEY:-}" CONFIG_FILE="${HOME}/.openclaw/workspace/skills/xiaoka-food-log/.credentials" load_config() { if [[ -f "$CONFIG_FILE" ]] && [[ -z "$API_KEY" ]]; then API_KEY=$(cat "$CONFIG_FILE") fi }bash result=$(curl -s -X POST "${API_BASE}/openclaw/api/food/log" \ -H "Authorization: Bearer ${API_KEY}" \ -H "Content-Type: application/json" \ -d "$json_body")bash result=$(curl -s "${API_BASE}/openclaw/api/food/today" \ -H "Authorization: Bearer ${API_KEY}")Technical Analysis
The script permits
XIAOKA_API_BASEorXIAOKA_APIto override the service origin. It does not validate that the resulting endpoint uses HTTPS or belongs to the officialcal-cn.ishuohua.cnhost.When the
logortodaycommand runs,check_bindindcallsload_config, which reads the persistent API key from the local credentials file. The script subsequently includes that key in anAuthorization: Bearerheader sent to the environment-selected endpoint.Consequently, a process or execution context capable of controlling inherited environment variables can redirect authenticated requests to an attacker-operated server. The
logoperation additionally transmits the user's food-description data.Attack Path
- The victim has previously bound a Xiaoka Health account, causing an API key to be stored in
.credentials. - An attacker gains the ability to influence the environment used to launch the Skill, without needing direct read access to the credentials file.
- The attacker sets
XIAOKA_API_BASEorXIAOKA_APIto an attacker-controlled HTTP or HTTPS origin. - The victim or agent invo ...[truncated 1054 chars]
- The victim has previously bound a Xiaoka Health account, causing an API key to be stored in
- Remediation
View remediation
Remediation Suggestions
- Remove runtime endpoint overrides and use the fixed official HTTPS origin when custom deployments are not required:
bash readonly API_BASE="https://cal-cn.ishuohua.cn"-
If custom endpoints are a legitimate requirement, require an explicit trusted configuration and validate the URL before reading or transmitting credentials:
- Require the
httpsscheme. - Compare the parsed hostname against a strict allowlist.
- Reject embedded credentials, unexpected ports, malformed URLs, and redirects to untrusted origins.
- Avoid substring or suffix-only hostname checks that can accept attacker domains.
- Require the
-
Configure
curldefensively:- Use
--fail-with-body --show-error. - Disable or strictly constrain redirects, or verify every redirect destination.
- Do not use options that disable TLS certificate verification.
- Apply reasonable connection and overall timeouts.
- Use
-
Separate endpoint selection from credential loading. Validate and approve the final destination before calling
load_config. -
Consider using a restricted execution environment that clears untrusted
XIAOKA_API_BASE,XIAOKA_API, andXIAOKA_API_KEYvalues before invoking the script. -
Rotate any API key that may have been used while an untrusted endpoint override was present.
