Back to skill

Security audit

小卡健康饮食记录skill

Security checks for vulnerabilities and agentic risk

Overview

This food logging skill is mostly purpose-aligned, but it stores an API key locally and the bundled script can be redirected by environment variables to send that key and food data to an unvalidated endpoint.

Install only if you are comfortable sending dietary entries to Xiaoka Health and storing a local API key. Avoid using this skill in environments where untrusted processes can set XIAOKA_API_BASE or XIAOKA_API, and prefer narrowing use to explicit food-log commands rather than casual mentions of what you ate.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
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: Medium

Vulnerable 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_BASE or XIAOKA_API to override the service origin. It does not validate that the resulting endpoint uses HTTPS or belongs to the official cal-cn.ishuohua.cn host.

When the log or today command runs, check_bindind calls load_config, which reads the persistent API key from the local credentials file. The script subsequently includes that key in an Authorization: Bearer header 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 log operation additionally transmits the user's food-description data.

Attack Path

  1. The victim has previously bound a Xiaoka Health account, causing an API key to be stored in .credentials.
  2. An attacker gains the ability to influence the environment used to launch the Skill, without needing direct read access to the credentials file.
  3. The attacker sets XIAOKA_API_BASE or XIAOKA_API to an attacker-controlled HTTP or HTTPS origin.
  4. The victim or agent invo ...[truncated 1054 chars]
Remediation
View remediation

Remediation Suggestions

  1. 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"
  1. If custom endpoints are a legitimate requirement, require an explicit trusted configuration and validate the URL before reading or transmitting credentials:

    • Require the https scheme.
    • 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.
  2. Configure curl defensively:

    • 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.
  3. Separate endpoint selection from credential loading. Validate and approve the final destination before calling load_config.

  4. Consider using a restricted execution environment that clears untrusted XIAOKA_API_BASE, XIAOKA_API, and XIAOKA_API_KEY values before invoking the script.

  5. Rotate any API key that may have been used while an untrusted endpoint override was present.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (10)

Vague Triggers

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger condition is overly broad because it activates on essentially any user message describing food intake, forcing transmission to an external API. This can capture sensitive health/dietary information without sufficiently clear user intent to log or consent to external processing.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · SKILL.md (reported line 121)May include surrounding context.

  • 401:凭证失效,删除凭证文件重新绑定:
    bash
    rm "$HOME/.openclaw/workspace/skills/xiaoka-food-log/.credentials"
    
  • 403:免费次数已用完,提示用户开通小卡健康会员
  • 429:超出每日上限(50次)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill invokes shell commands and network access via curl/jq but does not declare any explicit tool scope or allowed-tools boundary. That increases the chance the runtime grants broader capabilities than necessary and makes review/enforcement of least privilege harder.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill instructs local storage and retrieval of an API key from a credentials file without warning the user that a sensitive token is being stored locally or explaining retention/access risks. In a health-related skill, this increases privacy and account-compromise concerns if the workspace is shared or improperly secured.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 54)May include surrounding context.

bash
CRED="$HOME/.openclaw/workspace/skills/xiaoka-food-log/.credentials"
echo "oc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" > "$CRED"
chmod 600 "$CRED"
echo "绑定成功,已保存凭证。"

External Transmission

Medium
Category
Data Exfiltration
Confidence
95% confidence
Finding

The skill sends user-provided food descriptions and an authorization bearer token to an external service. Although this is core functionality, it is still a real data-exfiltration surface involving dietary/health-adjacent personal data and should be treated as sensitive outbound transmission.

Content

Scanner excerpt · SKILL.md (reported line 87)May include surrounding context.

md
XIAOKA_API="https://cal-cn.ishuohua.cn"
CRED="$HOME/.openclaw/workspace/skills/xiaoka-food-log/.credentials"
XIAOKA_API_KEY=$(cat "$CRED")
curl -s -X POST "$XIAOKA_API/openclaw/api/food/log" \
  -H "Authorization: Bearer $XIAOKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "一碗米饭和红烧肉", "meal_type": "lunch"}' | jq .

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script persists the API key to a local credentials file in the user's home directory without any explicit user-facing notice that a long-lived secret will be stored on disk. Although permissions are tightened with chmod 600, silent local secret storage increases the risk of accidental exposure through backups, dotfile sync, shared accounts, or compromised user sessions.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/xiaoka.sh (reported line 25)May include surrounding context.

sh
# 保存 API Key
save_config() {
    echo "$1" > "$CONFIG_FILE"
    chmod 600 "$CONFIG_FILE"
}

# 检查是否已绑定

External Transmission

Medium
Category
Data Exfiltration
Confidence
96% confidence
Finding

This command sends user dietary content plus an authorization token to an external network endpoint via curl. In the context of a food-logging skill this transmission is expected, but it still constitutes real exfiltration of potentially sensitive personal data to a third-party service and depends on trusting the configured API base.

Content

Scanner excerpt · scripts/xiaoka.sh (reported line 141)May include surrounding context.

sh
json_body="{\"text\": \"${food_text}\", \"meal_type\": \"${meal_type}\"}"
        fi

        result=$(curl -s -X POST "${API_BASE}/openclaw/api/food/log" \
            -H "Authorization: Bearer ${API_KEY}" \
            -H "Content-Type: application/json" \
            -d "$json_body")

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The log flow transmits user-entered dietary information to a remote service without an explicit disclosure at the point of submission. Dietary data can reveal sensitive health, lifestyle, or religious information, so sending it off-host without clear notice or consent creates a privacy risk even if this is the skill's intended function.

Content

No source excerpt is available for this finding.