Back to skill

Security audit

AI陪伴减肥

Security checks for vulnerabilities and agentic risk

Overview

This weight-loss assistant is mostly coherent, but it stores sensitive health data and includes unsafe local JSON file handling plus medical-adjacent supplement and fasting guidance that users should review carefully.

Install only if you are comfortable sharing and storing health-related profile, diet, step, and conversation data locally. Treat its supplement, fasting, menstrual-cycle, and binge-recovery advice as non-medical coaching, and avoid using it as a substitute for a clinician. The record-path validation issue should be fixed before exposing the data manager to untrusted dates or automated writes.

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

Error
Location
scripts/data_manager.py:76
Finding

Path Traversal Enables Arbitrary JSON File Read and Write

Content
View full analysis

Vulnerability Details

File Location: scripts/data_manager.py, lines 76-108
Vulnerability Type: Path traversal and insufficient path validation
Risk Level: High

Vulnerable Code

python
def _get_record_path(self, date: str) -> Path:
    """Get the record file path for a specified date."""
    return self.records_dir / f"{date}.json"

def save_daily_record(self, date: str, record: Dict) -> bool:
    """Save a daily record."""
    try:
        record_path = self._get_record_path(date)
        with open(record_path, 'w', encoding='utf-8') as f:
            json.dump(record, f, ensure_ascii=False, indent=2)
        return True
    except Exception as e:
        print(f"Failed to save record: {e}")
        return False

def save_user_record(self, record: Dict) -> bool:
    """Save a user record using its date or the current date."""
    date = record.get('date', datetime.now().strftime('%Y-%m-%d'))
    return self.save_daily_record(date, record)

def get_daily_record(self, date: str) -> Optional[Dict]:
    """Get a record for a specified date."""
    record_path = self._get_record_path(date)
    if record_path.exists():
        with open(record_path, 'r', encoding='utf-8') as f:
            return json.load(f)
    return None

Technical Analysis

The date parameter is treated as a trusted filename component even though it can be supplied by a caller through save_daily_record(), get_daily_record(), or the date field accepted by save_user_record().

Appending .json does not prevent traversal. A value containing parent-directory components, such as ../../target, produces a path equivalent to:

text
data/daily_records/../../target.json

The implementation does not:

  • Strictly parse the value as a YYYY-MM-DD date.
  • Reject path separators or .. components.
  • Resolve the constructed path to its canonical location.
  • Verify that the resolved path remains within data/daily_records.

Consequently, the affected read m ...[truncated 1774 chars]

Remediation
View remediation

Remediation Suggestions

  1. Strictly validate and canonicalize all date inputs:

    python
    def _validate_date(self, date: str) -> str:
        parsed = datetime.strptime(date, "%Y-%m-%d")
        canonical = parsed.strftime("%Y-%m-%d")
        if canonical != date:
            raise ValueError("Invalid date format")
        return canonical
    
  2. Resolve the final path and verify containment within the records directory:

    python
    def _get_record_path(self, date: str) -> Path:
        safe_date = self._validate_date(date)
        base = self.records_dir.resolve()
        candidate = (base / f"{safe_date}.json").resolve()
    
        if candidate.parent != base:
            raise ValueError("Record path escapes the records directory")
    
        return candidate
    
  3. Explicitly reject path separators, null bytes, and traversal components before constructing a path.

  4. Apply the same validated helper to both read and write operations so that security checks cannot diverge.

  5. Use atomic writes to reduce corruption risk:

    • Create a temporary file inside records_dir.
    • Flush and synchronize it.
    • Replace the destination atomically.
  6. Set restrictive directory and file permissions appropriate for sensitive health data.

  7. Add negative security tests covering values such as:

    text
    ../profile
    ../../target
    /absolute/path
    ..\target
    2026-05-15/../../target
    
  8. Confirm that invalid dates and all paths outside daily_records are rejected before any filesystem access occurs.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (23)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

This second mismatch finding is also valid because the documented behavior expands into multiple undeclared domains: supplement advice, menstrual-cycle handling, binge-eating recovery guidance, device/variable sync, HTML report generation, and advanced personalization. In a health context, undeclared expansion materially increases privacy and safety risk because users may disclose more sensitive information than they would for a simple step calculator.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

This second mismatch finding is also valid because the documented behavior expands into multiple undeclared domains: supplement advice, menstrual-cycle handling, binge-eating recovery guidance, device/variable sync, HTML report generation, and advanced personalization. In a health context, undeclared expansion materially increases privacy and safety risk because users may disclose more sensitive information than they would for a simple step calculator.

Content

No source excerpt is available for this finding.

YARA rule 'agent_skill_mcp_tool_poisoning_metadata': MCP/tool metadata poisoning indicators in tool schemas or skill manifests [agent_skills]

High
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

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


name: kite-slim description: Kite博士的AI减肥陪伴智能体;根据昨日饮食热量智能计算今日目标步数,步数完成度是核心监督指标,饮食记录服务于步数目标的达成

Kite博士的减肥处方

核心理念(产品主线)

昨日卡路里摄入 → 今日目标步数消耗

这不是后台计算逻辑,而是用户每天必须完成的核心任务链:

text
昨日饮食记录 → 计算热量差 → 设定今日步数目标 → 全天督促完成 → 晚上验收结果 → 反馈激励

产品主线优先级

| 优先级 | 任务 | 说明 | |--

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

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

核心改造:步数信息置于最显眼位置

html
<!-- 步数任务卡片(最大最显眼) -->
<div class="steps-mission">
  <div class="mission-title">🎯 今日核心任务</div>
  <div class="mission-target">8,000 步</div>

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

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

核心改造:步数信息置于最显眼位置

html
<!-- 步数任务卡片(最大最显眼) -->
<div class="steps-mission">
  <div class="mission-title">🎯 今日核心任务</div>
  <div class="mission-target">8,000 步</div>

YARA rule 'agent_skill_mcp_tool_poisoning_metadata': MCP/tool metadata poisoning indicators in tool schemas or skill manifests [agent_skills]

High
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

Scanner excerpt · scripts/diet_calculator.py (reported line 141)May include surrounding context.

python
return 1.0


# ============================================================
# 运动消耗数据库(单位:kcal/小时,基于60kg体重)
# ============================================================
EXERCISE_DATABASE = {
    '走路': {
        '慢走': {'cal_per_hour': 200, 'speed': '4km/h', 'emoji': '🚶'},
        '快走': {'cal_per_hour': 350, 'speed': '6km/h', 'emoji': '🚶‍♂️'},
        '暴走': {'cal_per_hour': 450, 'speed': '8km/h', 'emoji': '💨'},
    },
    '跑步': {
        '慢跑': {'cal_per_hour': 450, 'speed': '8km/h', 'emoji': '🏃'},
        '快跑': {'cal_per_hour': 600, 'speed': '12km/h', 'emoji': '🏃‍♂️'},
    },
    '骑行': {
        '骑行': {'cal_per_hour': 400, 'speed': '15km/h', 'emoji': '🚴'},
        '动感单车': {'cal_per_hour': 500, 'emoji': '🚴‍♂️'},
    },
    '游泳': {
        '蛙泳': {'cal_per_hour': 450, 'emoji': '🏊'},
        '自由泳': {'cal_per_hour': 550, 'emoji': '🏊‍♀️'},

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This code provides medical-adjacent supplement recommendations, including dosage and timing guidance, despite the skill being framed as a diet/step companion rather than a medically supervised wellness tool. That mismatch raises the risk of harmful self-medication, contraindications, or unsafe use by vulnerable users who may interpret the output as professional guidance.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The 'binge recovery' module provides eating-disorder-adjacent guidance, including behavioral recovery steps after overeating, outside the declared scope of the skill. In a weight-loss context, this can be especially dangerous for vulnerable users because it may reinforce disordered eating patterns or substitute for professional mental-health and medical support.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
84% confidence
Finding

The skill explicitly references local data files and linked scripts for reading and managing user records, but the manifest does not declare any corresponding tool scope or permissions. That creates an under-specified trust boundary: a host may expose file read/write behavior that users were not clearly informed about, especially given the collection of sensitive health data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The onboarding flow requests sensitive health and biometric data such as height, weight, age, sex, body-fat rate, activity, and lifestyle patterns without any explicit privacy notice, consent flow, retention policy, or limitation statement. Because this is health-related information, undisclosed collection can expose users to privacy harm, misuse, and regulatory compliance issues.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill describes automatic access to device step data after app authorization, but does not clearly warn users about the scope of telemetry access, data sharing, retention, or revocation. Automatic ingestion of activity data is especially sensitive in a health-monitoring assistant and can enable ongoing tracking beyond what users expect.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains user-facing natural-language descriptions and prompts exclusively in Chinese, starting with the module docstring and continuing throughout the file. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The resume prompt strings shown to users are all hard-coded in Chinese and do not provide any mechanism to select another language. Because these are direct user-facing messages, they constitute a language-policy issue unless the skill explicitly limits itself to a justified Chinese-only context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module description states the skill outputs JSON for an agent, and throughout the file the user-facing strings are written in Chinese. For an all-file policy check, this is a natural-language locale constraint that is imposed by default and not presented as optional or region-specific.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file introduces supplement recommendation and prescription-generation capabilities that exceed the declared skill purpose of step-target supervision based on diet records. This scope expansion is dangerous because it can cause users to treat the agent as a health intervention tool and rely on unvetted supplement advice without appropriate medical oversight.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The docstring for get_supplement_recommendation says it returns a supplement recommendation plan, but the function body only initializes a recommendations dict and then ends without returning it. The actual recommendation logic appears later after an unrelated return in another function, so the documented intent contradicts the implemented behavior.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

After scientific_analysis returns at L1280, the subsequent block contains what appears to be supplement recommendation logic. Because it is placed after a return statement inside another function scope, it cannot execute, directly undermining the apparent documented/programmer intent of implementing recommendation behavior there.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The interaction templates instruct the assistant to greet, prompt, and guide users entirely in Chinese, but do not offer a language selection path. This creates a language policy issue because the skill fixes one locale for all users rather than allowing preference or documenting a justified region-specific scope.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill adds menstrual-cycle, binge-recovery, and sleep-schedule personalization that are not reflected in the manifest, materially expanding both sensitivity of processed data and behavioral influence over the user. This is risky because it increases collection and inference around intimate health data without transparent disclosure, narrowing, or consent appropriate to the declared skill purpose.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The entire skill description, prompts, and user-facing scripts are written only in Chinese, with no indication that the user may choose another language. This can violate language/locale policy when a skill effectively mandates a specific language without opt-in or documented regional justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

This SVG contains natural-language comments in Chinese (for example at L08, L10, L12, L15, L18, and L21). Under the policy rule for language/locale, embedding a single fixed language without user opt-in or documented justification can be considered a locale-policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

SQP-3 applies to all file types and covers language or locale policy violations. This markdown file presents all user-facing content in Chinese only, with no opt-in, alternative language option, or statement that the skill is intended specifically for a Chinese-speaking or region-specific audience.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This Python file contains user-facing descriptive strings and comments for the skill exclusively in Chinese, such as the module docstring naming the skill and its test coverage. Under the policy rule, forcing a specific language without user opt-in can be a natural-language locale violation, and this file does not document any choice or regional justification.

Content

No source excerpt is available for this finding.