Back to skill

Security audit

Logfile Analyzer

Security checks for vulnerabilities and agentic risk

Overview

This log analyzer is mostly purpose-aligned, but it reads arbitrary log paths and can render crafted log content unsafely in terminal or Markdown reports.

Install only if you are comfortable letting the agent read the specific log files or directories you provide. Avoid running it on broad system log directories unless needed, treat generated terminal and Markdown reports as untrusted when logs may include attacker-controlled content, and prefer JSON output for safer downstream processing.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyze_logs.py:550
Finding

Terminal Control-Sequence Injection Through Untrusted Log Messages

Content
View full analysis

Vulnerability Details

File Location: scripts/analyze_logs.py, lines 550-555
Vulnerability Type: Terminal output injection
Risk Level: Medium

Vulnerable code snippet:

python
for i, p in enumerate(result['patterns'], 1):
    sev = p['severity_label']
    out.append(f'[{sev}] #{i} — {p["count"]:,}x occurrences')
    out.append(f'  Message: {p["message"][:200]}')

Technical Analysis

Log messages are attacker-controlled data in many realistic deployments, including HTTP headers, request paths, usernames, exception values, and messages received from external services. The text formatter inserts this data directly into terminal output without escaping ASCII control characters, ANSI escape sequences, carriage returns, or other non-printable characters.

A crafted message containing characters such as ESC [ 2 J, ESC [ H, carriage return, or terminal-specific OSC sequences will be interpreted by a compatible terminal rather than displayed as inert text. This can clear or overwrite visible output, disguise malicious entries, create deceptive links, or otherwise alter the presentation of the audit report. Some terminal configurations support additional OSC operations, but arbitrary command execution is not established by the audited code and depends on the terminal implementation.

Truncating the message to 200 characters does not mitigate the issue because functional terminal sequences are usually only a few bytes long.

Attack Path

  1. An attacker causes an application to record attacker-controlled data in a log message.
  2. The attacker embeds terminal control characters in that data, for example an ANSI sequence that clears the screen followed by a forged clean-status message.
  3. A user runs the analyzer with its default text output against the affected log file.
  4. format_text() places the raw message in the generated output.
  5. print() sends the resulting control sequence to the user' ...[truncated 592 chars]
Remediation
View remediation

Remediation Suggestions

  • Sanitize all log-derived text before writing it to an interactive terminal.
  • Remove or visibly encode C0/C1 control characters, especially \x1b, \r, \b, and terminal OSC terminators.
  • Preserve safe formatting characters only where explicitly required; encode unsafe bytes with representations such as \x1b or \u001b.
  • Apply sanitization at the final output boundary so every terminal-facing field, including messages and source names, receives consistent protection.
  • Consider a helper such as:
    python
    def sanitize_terminal(value):
        return ''.join(
            ch if ch in '\n\t' or ord(ch) >= 0x20 else f'\\x{ord(ch):02x}'
            for ch in str(value)
        ).replace('\x1b', r'\x1b').replace('\r', r'\r')
    
  • If multiline values are unnecessary in text reports, replace newlines and tabs with visible escaped forms as well.
  • Add regression tests using ANSI clear-screen sequences, carriage-return overwrites, OSC hyperlinks, and other non-printable input.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyze_logs.py:652
Finding

Markdown and Raw-HTML Injection Through Untrusted Log Messages

Content
View full analysis

Vulnerability Details

File Location: scripts/analyze_logs.py, lines 652-656
Vulnerability Type: Markdown report injection
Risk Level: Medium

Vulnerable code snippet:

python
for i, p in enumerate(result['patterns'], 1):
    sev = p['severity_label']
    out.append(f'### {i}. [{sev}] {p["count"]:,}x — {p["message"][:120]}')

Technical Analysis

The Markdown formatter interpolates an untrusted log message directly into a Markdown heading. No escaping is applied to Markdown metacharacters, embedded newlines, links, images, or raw HTML.

Structured JSON logs can contain escaped newline characters that become actual newlines after json.loads(). Consequently, an attacker-controlled message can terminate the intended heading and inject additional headings, links, images, block content, or raw HTML into the generated report. Whether raw HTML or active content executes depends on the Markdown renderer, but report-content spoofing is possible in ordinary renderers.

The 120-character limit does not prevent exploitation because short Markdown constructs are sufficient to inject false findings or remote resources.

Attack Path

  1. An attacker causes a structured application log to contain a crafted message with embedded newlines and Markdown, such as a false summary heading or an externally hosted image.
  2. An operator generates a report with --output markdown.
  3. format_markdown() concatenates the message into the report without contextual escaping.
  4. The report is saved, published, or opened in a Markdown viewer.
  5. The injected markup is rendered as legitimate report content, allowing the attacker to forge findings or, where remote images are loaded, trigger a request to an attacker-controlled server.

Impact Assessment

The primary impact is loss of integrity and trust in generated reports. An attacker may insert deceptive conclusions, conceal the visual relationship between genuine ...[truncated 343 chars]

Remediation
View remediation

Remediation Suggestions

  • Escape untrusted values according to their Markdown context before interpolation.
  • Replace embedded carriage returns and newlines when a value is intended to remain within a heading.
  • Escape Markdown metacharacters such as backslashes, backticks, asterisks, underscores, braces, brackets, parentheses, angle brackets, hash signs, and pipes.
  • Encode or remove raw HTML delimiters instead of relying on the downstream renderer to disable HTML.
  • Prefer rendering messages in fenced code blocks, while safely handling embedded fence sequences, or in plain-text blocks with explicit escaping.
  • Apply the same protections to source names, recommendations, and any other value that might later become externally controlled.
  • Configure report viewers to disable raw HTML and remote resource loading where possible.
  • Add tests with multiline JSON messages, headings, links, images, raw HTML, table delimiters, and embedded code fences.
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 (10)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python3 scripts/analyze_logs.py /var/log/app.log

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python3 scripts/analyze_logs.py /var/log/app.log

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python3 scripts/analyze_logs.py /var/log/app.log

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python3 scripts/analyze_logs.py /var/log/app.log

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python3 scripts/analyze_logs.py /var/log/app.log

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
python3 scripts/analyze_logs.py /var/log/app.log

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The skill documentation describes operations on arbitrary log files and directories and references a script invocation that clearly implies file-reading capability, yet the manifest declares no explicit tool scope or permissions. In an agent environment, missing scope boundaries can allow the skill to be invoked with broader file access than intended, increasing the risk of reading sensitive logs or nearby files without clear user consent or enforcement.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger list includes relatively broad phrases such as "what's failing," "check logs," and "incident analysis," which could cause the skill to activate in situations that are only loosely related to log parsing. Unintended invocation is dangerous because it may steer the agent into reading or summarizing logs unnecessarily, exposing operational or sensitive information and increasing the chance of over-broad file access.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and manifest claim support for Apache/Nginx access and error logs, Node.js errors, Docker logs, and auto-detection across those formats. However, the parser only has dedicated handling for JSON, syslog, nginx error, apache access, generic lines, and Python tracebacks; detected formats like apache_error, node_error, docker, and syslog_iso fall through to the generic parser, and there is no nginx access parser despite the stated Apache/Nginx access support.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The documentation says '--group-by' changes grouping, '--context' controls lines around errors, and '--quiet' outputs only the summary. In code, analysis always groups by normalized message fingerprint, context is never collected or emitted, and quiet mode is parsed but never used when formatting output, so the documented intent directly conflicts with runtime behavior.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.