Back to skill

Security audit

Log Analyzer

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent local log-analysis skill, but users should know its human-readable output prints raw log text and some advertised filters are imperfect.

Install only if you are comfortable running a local Python analyzer on log files you choose. Treat logs as untrusted input: prefer --json or sanitize output when analyzing logs that may contain attacker-controlled text, and do not rely on --severity or --since for strict filtering until those bugs are fixed.

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/analyze_logs.py:132
Finding
Terminal Escape-Sequence Injection Through Untrusted Log Content<![CDATA[ ## Vulnerability Details **File Location**: `scripts/analyze_logs.py`, lines 132–136 and 178–181 **Vulnerability Type**: Improper neutralization of terminal control sequences **Risk Level**: Medium ### Vulnerable Code ```python if severity in ("FATAL", "ERROR", "WARN"): fp = fingerprint(stripped) error_groups[fp] += 1 if fp not in error_examples: error_examples[fp] = stripped[:500] ``` ```python for i, err in enumerate(result["top_errors"], 1): print(f"\n #{i} [{err['count']}x]") example = err["example"] if len(example) > 120: example = example[:117] + "..." print(f" {example}") ``` ### Technical Analysis Log entries are commonly influenced by untrusted remote input, such as HTTP headers, request paths, usernames, protocol values, or application error messages. The analyzer retains the original log text in `error_examples` and later prints it directly to the terminal. Truncating the string does not neutralize embedded ANSI, OSC, C0, or C1 terminal control sequences. If a malicious log entry contains such sequences, a compatible terminal may interpret them as commands rather than displaying them as ordinary text. The JSON output path uses `json.dumps()`, which escapes standard control characters. The vulnerable path is the default human-readable output generated by `print_report()`. ### Attack Path 1. An attacker supplies crafted input to an application or service that records attacker-controlled values in its logs. 2. The crafted value includes terminal control sequences and a severity keyword such as `ERROR`, causing the analyzer to retain it as an error example. 3. An operator invokes `python3 scripts/analyze_logs.py <logfile>` without the `--json` option. 4. The analyzer reads the malicious line, stores up to 500 characters of the raw content, and selects it as an example for a top error pattern. 5. `print_report()` writes the content directly to the operator's terminal. 6. The terminal ...[truncated 917 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Sanitize all untrusted strings before writing them to an interactive terminal: 1. Remove or visibly encode ANSI, OSC, C0, and C1 control sequences. 2. Preserve safe formatting characters only when necessary, such as converting tabs and newlines to visible escaped forms. 3. Apply sanitization at the output boundary in `print_report()` so every future terminal output field receives consistent protection. 4. Continue using `json.dumps()` for JSON output and avoid manually constructing JSON. 5. Add automated tests containing ESC (`\x1b`), BEL (`\x07`), carriage return (`\r`), backspace (`\b`), OSC sequences, and ANSI CSI sequences. 6. Document that logs should be treated as untrusted data. A defensive implementation could convert every non-printable character into a visible escape: ```python def sanitize_terminal(value: str) -> str: return "".join( ch if ch.isprintable() else f"\\x{ord(ch):02x}" for ch in value ) ``` Apply it immediately before terminal output: ```python example = sanitize_terminal(err["example"]) if len(example) > 120: example = example[:117] + "..." print(f" {example}") ``` For stronger coverage, use a well-tested terminal sanitization routine that explicitly handles complete ANSI CSI and OSC sequences rather than relying only on a narrow regular expression. ]]>
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (3)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The code largely matches the stated purpose: it analyzes log files, detects error patterns, groups repeated errors by fingerprint, summarizes severities, and identifies anomalous error windows. It accesses only the user-specified local log file and has no unrelated behaviors. However, there are meaningful behavior-description mismatches in functionality details. First, the advertised severity filtering capability is not truly implemented: `min_severity` creates a `severity_filter` set, but that set is never used to exclude lines from counts or grouped errors. Second, the `--since` feature is implemented as raw string comparison on extracted timestamp substrings, not real timestamp parsing, which can produce incorrect filtering across the multiple log formats the description claims to support. These are not malicious or unrelated capabilities, but they are material mismatches between declared behavior and actual operation.

Lp3

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding
Without declared permissions the skill's intent is opaque and cannot be validated.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The description says to use the skill when asked to "debug server issues from logs" and "summarize log output," which are broad natural-language triggers without clear boundaries or exclusion conditions. This increases the chance of unintended invocation for general debugging or summarization requests that may not specifically require this skill.

Static analysis

No suspicious patterns detected.