Back to skill

Security audit

Drift Guard

Security checks for vulnerabilities and agentic risk

Overview

Drift Guard is a coherent local monitoring tool that analyzes agent response text and stores local baselines/history, with some operational cautions but no hidden or malicious behavior found.

Install only if you are comfortable with a local tool reading agent response files and writing baseline/history/log files. Use only trusted Python config files, because --config imports executable Python code. Monitor or rotate drift_history.json in long-running use, since retention is not enforced in the inspected code.

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

Note
Location
drift_guard.py:210
Finding
Unbounded Drift History Growth Can Cause Local Resource Exhaustion## Vulnerability Details **File Location**: `drift_guard.py`, lines 210-221; related configuration in `config_example.py` defines `max_history_size` but the monitor does not enforce it. **Vulnerability Type**: Uncontrolled resource consumption and unbounded persistent storage **Risk Level**: Low ### Technical Analysis Every call to `monitor()` creates a measurement containing metrics and detailed drift data. `record_measurement()` appends that record to the in-memory history and then serializes the entire history back to disk: ```python record = { 'timestamp': time.time(), 'datetime': datetime.now().isoformat(), 'metrics': metrics, 'drift_score': drift_score, 'drift_details': drift_details } self.history.append(record) # Save to file history_path = Path(self.config.get('history_file', 'drift_history.json')) with open(history_path, 'w') as f: json.dump(self.history, f, indent=2) ``` The provided configuration defines a finite default: ```python # How many measurements to keep in history (0 = unlimited) 'max_history_size': 10000, ``` However, `record_measurement()` never reads or enforces `max_history_size`. Consequently, history grows without an effective bound even when an administrator believes a retention limit has been configured. The full history is also loaded into memory during initialization and rewritten on every measurement. As the file grows, each invocation consumes progressively more memory, CPU time, disk I/O, and storage. The cumulative write complexity becomes increasingly expensive because all prior records are serialized again for each new record. ### Attack Path 1. An attacker or untrusted integration obtains the ability to submit responses to a service or workflow that invokes `DriftGuard.monitor()`. 2. The attacker repeatedly submits responses, causing `record_measurement()` to append a new entry for every invocation. 3. The configured `max_history_ ...[truncated 1179 chars]
Remediation
## Remediation Suggestions Enforce the configured retention limit before persisting history: ```python self.history.append(record) max_history_size = int(self.config.get('max_history_size', 10000)) if max_history_size > 0: self.history = self.history[-max_history_size:] ``` Additional hardening should include: 1. Validate that `max_history_size` is a non-negative integer and reject invalid configuration values. 2. Use an append-oriented format such as JSON Lines instead of rewriting the complete history for every measurement. 3. Implement file rotation based on record count, file size, or age. 4. Set an explicit maximum history-file size and fail safely or rotate the file when the limit is reached. 5. Write updates atomically through a temporary file followed by replacement to reduce corruption risk during interrupted writes. 6. Apply file locking if concurrent monitor processes can write to the same history file. 7. Add automated tests verifying that finite retention settings are respected and that `0` remains the only explicitly unlimited mode. 8. Monitor disk usage and emit a local warning before storage reaches a critical threshold.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (9)

Memory Manipulation

High
Category
Memory Poisoning
Content
if result['alert_level'] == 'critical':
    print(f"ALERT: Agent drift detected ({result['drift_score']:.3f})")
    # Trigger recovery: load checkpoint, reset memory, etc.
```

### Automatic Drift Checks via Cron
Confidence
80% confidence
Finding
Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.

Memory Manipulation

High
Category
Memory Poisoning
Content
if result['alert_level'] == 'critical':
    print(f"ALERT: Agent drift detected ({result['drift_score']:.3f})")
    # Trigger recovery: load checkpoint, reset memory, etc.
```

### Automatic Drift Checks via Cron
Confidence
80% confidence
Finding
Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.

Lp3

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding
The skill clearly describes capabilities that read local files, write baseline and report artifacts, and process agent response files, but it declares no explicit tool scope or permissions. That mismatch can cause an agent platform to grant broader-than-expected filesystem access or leave operators unaware of the skill's true data-handling behavior.

Context-Inappropriate Capability

Medium
Confidence
99% confidence
Finding
This CLI feature explicitly loads configuration by executing a Python module from a path provided at runtime. That creates an arbitrary code execution primitive whenever a user is tricked into supplying an untrusted config file, which is especially risky in automation, agent, or pipeline contexts where inputs may come from external sources.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
Beyond the dynamic import itself, the tool presents --config as a normal CLI option without a prominent warning that providing a path will execute Python code. This increases the likelihood of unsafe use because operators may reasonably assume they are supplying passive configuration data rather than running code.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Content
if args.config:
        sys.path.insert(0, str(Path(args.config).parent))
        module_name = Path(args.config).stem
        config_module = __import__(module_name)
        config = config_module.CONFIG
    else:
        try:
Confidence
97% confidence
Finding
The code derives a module name from a user-supplied --config path, prepends that path's directory to sys.path, and then imports the module with __import__(). In Python, importing a module executes its top-level code, so any attacker-controlled config file can run arbitrary code as the user invoking this CLI.

Natural-Language Policy Violations

Low
Confidence
84% confidence
Finding
This markdown file explicitly says Drift Guard's patterns are English-centric and describes assumptions about English phrasing, grammar, and Latin script. Under the policy rule for language/locale constraints, this is a natural-language limitation that restricts use by language without presenting an opt-in choice or a clearly justified region-specific requirement.

Scope Creep

Low
Category
Excessive Agency
Content
**USE AT YOUR OWN RISK.**

- The author(s) are NOT liable for any damages, losses, or consequences arising from 
  the use or misuse of this software — including but not limited to financial loss, 
  data loss, security breaches, business interruption, or any indirect/consequential damages.
- This software does NOT constitute financial, legal, trading, or professional advice.
- Users are solely responsible for evaluating whether this software is suitable for
Confidence
70% confidence
Finding
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Scope Creep

Low
Category
Excessive Agency
Content
**USE AT YOUR OWN RISK.**

- The author(s) are NOT liable for any damages, losses, or consequences arising from 
  the use or misuse of this software — including but not limited to financial loss, 
  data loss, security breaches, business interruption, or any indirect/consequential damages.
- This software does NOT constitute financial, legal, trading, or professional advice.
- Users are solely responsible for evaluating whether this software is suitable for
Confidence
70% confidence
Finding
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Static analysis

No suspicious patterns detected.