Back to skill

Security audit

autonomous-science-loop

Security checks for vulnerabilities and agentic risk

Overview

The science-discovery code is functional, but the skill also directs agents to keep persistent user preferences and usage history and to write lessons back into the skill definition, which needs careful review before installation.

Review this skill before installing if you do not want a skill to keep local cross-session memory. The science_loop.py component is ordinary local computation, but learner.py can persist usage history, errors, free-form notes, and preferences, and the instructions encourage future agents to reuse that data and update SKILL.md. Install only if you are comfortable with that local memory behavior or can disable/remove the learner section.

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:97
Finding

Untrusted User-Controlled Preferences Are Persisted for Future Agent Sessions

Content
View full analysis

Vulnerability Details

File Location: scripts/learner.py:97-101; supporting command interface at scripts/learner.py:133-134 and scripts/learner.py:148-150
Vulnerability Type: Persistent agent memory poisoning
Risk Level: Medium

Technical Analysis

The learning module accepts arbitrary preference keys and values and writes them directly into the persistent learned_patterns.json state without validation, trust metadata, namespace restrictions, or approval. The relevant implementation is:

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

The command-line interface exposes these fields directly:

python
p_pre  = sub.add_parser("prefer"); p_pre.add_argument("skill_dir")
p_pre.add_argument("--key", required=True); p_pre.add_argument("--val", required=True)
python
elif args.cmd == "prefer":
    record_preference(sd, args.key, args.val)
    print("✅ 已记录偏好")

The accompanying instructions in SKILL.md explicitly state that important preferences stored in learned_patterns.json should be adopted on the next invocation. Consequently, attacker-controlled text can cross a session boundary and later be treated as trusted behavioral guidance.

There is no distinction between benign presentation preferences and instruction-like content. For example, a value can contain directives to ignore task constraints, disclose data, or invoke tools. The Python code does not itself execute the stored text, but the documented workflow creates a consumption path in which a future agent may read and follow it.

Attack Path

  1. An attacker gains access to a workflow that invokes the documented prefer command, or otherwise controls its --key and --val arguments.
  2. The attacker supplies instruction-like text as a preference, for example under a plausible key such as output_style or default_behavior.
  3. ` ...[truncated 1297 chars]
Remediation
View remediation

Remediation Suggestions

  1. Restrict preference keys to an explicit allowlist of non-security-sensitive settings, such as language, date format, or verbosity.
  2. Enforce strict schemas and length limits for every allowed value. Prefer enumerated values over unrestricted text.
  3. Reject multiline values and instruction-like content, including shell commands, tool directives, role changes, and requests to override security constraints.
  4. Store provenance with each preference, including the originating user, session, timestamp, and approval status.
  5. Require explicit confirmation before a newly supplied preference becomes persistent.
  6. Treat loaded preferences strictly as untrusted data. Never concatenate them into system prompts or higher-priority instructions.
  7. Ensure system and developer instructions always take precedence over persisted preferences, and document that precedence explicitly.
  8. Separate behavioral preferences from operational state and provide users with commands to inspect, revoke, and reset saved entries.
  9. Apply restrictive file permissions and reject symlinked or unexpected memory files where the deployment threat model includes local attackers.
  10. Add tests proving that stored values cannot modify safety rules, select tools, initiate commands, or override the current task.
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 (14)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The documented purpose is autonomous scientific discovery, but the skill also introduces unrelated persistence, preference storage, and self-improvement behavior that are not disclosed as part of the core function. This mismatch is dangerous because users and reviewers may authorize or invoke the skill under false assumptions while hidden side behaviors collect data or modify local state.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This file is a generic cross-skill telemetry and preference-learning module, not code for the advertised autonomous scientific discovery loop. That mismatch is dangerous because it quietly enables persistent activity tracking across arbitrary skills, creating a hidden data-collection capability that users and reviewers would not reasonably expect from this skill’s stated purpose.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill documents file-writing behavior via the learner subsystem but does not declare any tool scope or permissions boundaries. This is dangerous because it enables persistent writes and state changes without explicit capability disclosure, reducing reviewability and making unintended data retention or file modification easier.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill expands from a science workflow into a persistent self-learning system that tracks usage history, preferences, and reflection state across runs. That scope expansion is risky because it introduces long-lived state and user profiling beyond what is necessary for the declared task, increasing privacy and integrity risk.

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 error history is not justified by the stated scientific-discovery purpose. Collecting and retaining unrelated behavioral data creates unnecessary privacy exposure and may influence future runs in opaque ways.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill explicitly instructs persistence of user preferences and usage history in a local memory file across sessions. Cross-session memory is dangerous when not strictly necessary because it accumulates user data over time and can be reused in ways the user did not expect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill describes persistent storage of user preferences and usage/error history without warning users about retention. Lack of notice is dangerous because users may unknowingly disclose personal or sensitive workflow information that is stored across sessions.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The instructions encourage writing user preferences into persistent storage for automatic reuse in future sessions. Automatic reuse of retained preferences can silently shape outputs and reveals a profiling capability that is unrelated to the stated scientific-discovery function.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The example stores 输出语言=中文 as a user preference, and the surrounding document is written as if Chinese is the default operating language, without explicitly offering language choice. Under the language/locale policy, forcing or assuming a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The code records arbitrary preferences, capabilities, errors, and notes for any WorkBuddy skill via a shared path convention under ~/.workbuddy/skills. In the context of a science-discovery skill, this creates unjustified user/activity tracking and possible retention of sensitive free-form notes, expanding privacy risk beyond the skill’s declared function.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The module’s natural-language description, CLI help text, and user-facing output are all written in Chinese, with no indication that another language is supported or that Chinese is a required locale for a specific regional use case. This can violate language/locale policy when a skill imposes a language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This file includes user-facing natural-language documentation and usage instructions exclusively in Chinese, which effectively forces a specific language for users interacting with the skill. The policy allows locale constraints only when explicitly justified or when users are given a language choice, neither of which appears here.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The documentation instructs the learner to write accumulated experience back into SKILL.md, effectively self-modifying the skill definition. Self-modifying instructions are dangerous because they can alter future behavior outside normal review, create prompt-injection persistence, and undermine change-control assumptions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

Several print statements emit status and test results only in Chinese, which imposes a fixed locale on runtime interaction. Because no user opt-in or documented regional justification is present, this conflicts with the language/locale policy.

Content

No source excerpt is available for this finding.