Back to skill

Security audit

formal-capability-contract

Security checks for vulnerabilities and agentic risk

Overview

The verifier is local and runnable, but it also adds persistent learning and possible skill self-modification that users should review before installing.

Review this skill before installing if you do not want a verifier to keep local memory. Avoid recording secrets or sensitive user details in notes/preferences, and require human review before any learned content is applied to future behavior or written into SKILL.md.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T02 · Agent Memory Poisoning

Warning
Location
scripts/learner.py:64
Finding

Unvalidated Persistent Agent State Can Influence Future Sessions

Content
View full analysis

Vulnerability Details

File Location: scripts/learner.py:64-100; related behavioral instructions in SKILL.md:55-84 and scripts/section.md:3-29
Vulnerability Type: Persistent agent memory poisoning
Risk Level: Medium

Complete Code Snippet

python
def load_learning(skill_dir):
    p = learn_path(skill_dir)
    try:
        return json.loads(open(p, encoding="utf-8").read())
    except Exception:
        return default_data(os.path.basename(skill_dir))

def save_learning(skill_dir, data):
    data["lastUpdated"] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M")
    p = learn_path(skill_dir)
    with open(p, "w", encoding="utf-8") as f:
        f.write(json.dumps(data, indent=2, ensure_ascii=False))

def record_op(skill_dir, capability, success=True, error=None, note=None):
    data = load_learning(skill_dir)
    data["totalOps"] += 1
    cap = data["capabilityStats"].setdefault(capability, {"count": 0, "success": 0, "fail": 0})
    cap["count"] += 1
    if success:
        cap["success"] += 1
    else:
        cap["fail"] += 1
        data["totalErrors"] += 1
    if error:
        ep = data["errorPatterns"].setdefault(error, {"count": 0, "lastNote": "", "lastTime": ""})
        ep["count"] += 1
        ep["lastNote"] = note or ""
        ep["lastTime"] = data["lastUpdated"] or datetime.datetime.now().strftime("%Y-%m-%dT%H:%M")
    rec = {"t": data["lastUpdated"], "cap": capability, "ok": success, "err": error, "note": note}
    data["recentOps"].append(rec)
    data["recentOps"] = data["recentOps"][-20:]
    save_learning(skill_dir, data)
    return data

def record_preference(skill_dir, key, value):
    data = load_learning(skill_dir)
    data["preferences"][key] = value
    save_learning(skill_dir, data)
    return data

The related skill instructions direct the agent to persist user preferences in learned_patterns.json, apply them during lat ...[truncated 2837 chars]

Remediation
View remediation

Remediation Suggestions

  1. Treat persisted values as untrusted data

    • Explicitly instruct agents never to interpret stored notes, errors, capability names, or preference values as executable instructions.
    • Render stored content in a clearly delimited data section when presenting it to an agent.
  2. Introduce a strict preference schema

    • Allow only predefined preference keys.
    • Validate each value against an expected type and constrained set of values.
    • Reject unknown fields, control characters, excessive lengths, and instruction-like multiline content.
  3. Separate telemetry from behavioral configuration

    • Store operational notes and error history separately from approved preferences.
    • Do not place free-form notes into any context used to determine future agent behavior.
  4. Require explicit review before applying state

    • Present proposed preference changes to the user for confirmation.
    • Record approval status and provenance for every preference.
    • Ignore unapproved or externally modified entries.
  5. Remove automatic instruction rewriting

    • Do not direct the agent to copy learned content into SKILL.md.
    • If skill improvement is required, generate a proposed patch and require trusted human review before applying it.
  6. Protect memory-file integrity

    • Resolve and verify the canonical skill directory before writing.
    • Reject symbolic links and unexpected file ownership.
    • Use atomic file replacement with restrictive permissions.
    • Optionally authenticate trusted state with a keyed integrity check.
  7. Apply bounded input validation

    • Limit lengths for capability names, errors, notes, keys, and values.
    • Normalize Unicode and reject content containing role markers or instruction delimiters where they are not required.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (19)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The skill is presented as a formal verification capability, but the documented behavior includes unrelated persistence and learning features while the claimed verification logic is not substantiated in the provided file. This mismatch can mislead users and supervising agents into granting trust or using outputs as if they were machine-verified, when behavior may instead be heuristic and stateful.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The implementation does not perform formal capability-contract verification at all; instead it provides a generic telemetry and self-learning subsystem for arbitrary skills. In a security-sensitive skill whose stated purpose is proof-style correctness validation, this is dangerous because it silently expands scope into cross-skill behavior tracking, undermines user trust, and can enable unauthorized collection and persistence of operational data under misleading packaging.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The docstring advertises a generic self-evolving learning module for any WorkBuddy skill, directly contradicting the skill metadata claiming formal contract verification and provable correctness. This kind of capability deception is security-relevant because it can hide unexpected behavior behind a trusted interface, making operators more likely to deploy data-collecting code in contexts where only validation logic was expected.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This section materially expands the skill from formal capability verification into a generic self-learning and persistent memory system, which is outside the declared purpose and trust boundary. That kind of hidden scope expansion is dangerous because it introduces statefulness, data collection, and behavior drift that users and reviewers would not expect from a correctness-verification skill.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill documents executable commands that write persistent files (learned_patterns.json and potentially SKILL.md) but does not declare any tool scope or permission boundaries. That creates an authorization gap: an agent may perform file writes that users and orchestrators cannot pre-review or constrain, increasing the risk of unintended local state changes and covert persistence.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill's stated purpose is formal capability verification, but it also embeds a self-evolving learning system that records usage outcomes and preferences. This introduces hidden state and secondary data-processing behavior unrelated to the core task, which can surprise users and create additional privacy and integrity risks.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill establishes a natural-language retention channel by logging capabilities used, failures, notes, and user preferences across runs. Such free-form logs often capture sensitive or identifying details, and persistence magnifies the privacy impact because the data can accumulate and be repurposed beyond the original interaction.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Persistent storage of user preferences and operational history is not necessary for one-off formal contract verification and therefore exceeds the minimum functionality implied by the skill description. Excessive retention broadens the attack surface by accumulating sensitive natural-language data that could later be exposed, misused, or acted upon outside user expectations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs persistent recording of user preferences and usage history without warning users that their data will be stored locally. Lack of notice and consent is dangerous because users may provide sensitive information in notes or preferences that becomes silently retained beyond the current session.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This Python file contains its primary module docstring and CLI usage/help text in Chinese, and later emits Chinese-only verdicts and prompts. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation, and nothing in the file indicates a locale choice or region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The returned verdict strings, self-test success output, and usage prompt are all Chinese-only, so users are implicitly required to use that language to understand results. The file does not offer opt-in language selection or explain a justified reason for restricting output to Chinese.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code explicitly records user preferences, operation history, error notes, and cross-skill usage data despite the skill being presented as a formal verification capability. That mismatch matters because users invoking a verifier would not reasonably expect telemetry collection, and notes/preferences may contain sensitive workflow or personal information that gets stored on disk without purpose limitation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module writes user notes and preferences to a persistent JSON file without any disclosure, sensitivity handling, or filtering. Free-form notes are especially risky because they may contain secrets, personal data, internal identifiers, or incident details that then remain on disk in plaintext and may be read by other local processes or later exfiltrated.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Persisting user preferences, error history, and operational usage is not necessary to perform formal precondition/postcondition/invariant checking, so the feature creates unnecessary data exposure and hidden functionality. When a skill stores extra state unrelated to its stated mission, it increases the risk of privacy leakage, misuse of historical context, and undeclared cross-session profiling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The instructions tell operators to save user preferences and free-form error notes into a local memory file without any privacy notice, minimization guidance, or handling restrictions. Free-text notes can easily capture sensitive user data, and absent warnings or controls, this creates a straightforward data retention and confidentiality risk.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The section explicitly instructs the skill to retain user preferences and usage notes across runs, creating durable natural-language memory that may include personally sensitive or operationally sensitive information. Cross-session retention is especially risky in agent skills because later tasks may consume this data in unintended ways, expanding both privacy and prompt-surface exposure.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The instructions encourage writing back experiences into SKILL.md and learned_patterns.json without warning about the safety implications of modifying local files. Self-modifying instructions can corrupt skill definitions, create persistence for unsafe changes, and make later behavior harder to audit.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The natural-language documentation, help descriptions, and user-facing strings are entirely in Chinese, which imposes a specific language on users without offering an alternative or documenting a region-specific requirement. This matches the policy concern for language or locale constraints without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

Line L18 shows a persisted preference --key 输出语言 --val 中文, which indicates the skill may adopt a fixed language setting. Under the policy, forcing a specific language without explicit user choice can be a locale/language policy issue unless the constraint is documented as optional or region-specific.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.