Back to skill

Security audit

Logflux

Security checks for vulnerabilities and agentic risk

Overview

LogFlux is a small user-run log viewer whose behavior matches its stated purpose, with a bounded terminal-display risk when viewing untrusted logs.

Installers should treat this as suitable for trusted or already-sanitized logs. Avoid pointing it at attacker-controlled logs in an interactive terminal unless terminal escape/control characters are sanitized first.

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
tool.py:56
Finding

Terminal Control-Sequence Injection Through Untrusted Log Content

Content
View full analysis

Vulnerability Details

File Location: tool.py, lines 26-38 and 56-70
Vulnerability Type: Unsanitized terminal output
Risk Level: Medium

Vulnerable Code

python
def colorize_log_line(line):
    """Apply colors to different log levels and timestamps."""
    # Colorize timestamps (ISO or common formats)
    line = re.sub(r'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})', f'{Fore.CYAN}\\1{Fore.RESET}', line)
    line = re.sub(r'(\d{2}:\d{2}:\d{2})', f'{Fore.CYAN}\\1{Fore.RESET}', line)

    # Colorize log levels
    line = re.sub(r'(ERROR)', f'{Style.RESET_ALL}{Fore.RED}[\\1]{Fore.RESET}{Style.RESET_ALL}', line, flags=re.IGNORECASE)
    line = re.sub(r'(WARN|WARNING)', f'{Style.RESET_ALL}{Fore.YELLOW}[\\1]{Fore.RESET}{Style.RESET_ALL}', line, flags=re.IGNORECASE)
    line = re.sub(r'(INFO)', f'{Style.RESET_ALL}{Fore.GREEN}[\\1]{Fore.RESET}{Style.RESET_ALL}', line, flags=re.IGNORECASE)
    line = re.sub(r'(DEBUG)', f'{Style.RESET_ALL}{Fore.CYAN}[\\1]{Fore.RESET}{Style.RESET_ALL}', line, flags=re.IGNORECASE)

    return line
python
            for line in recent_lines:
                print(colorize_log_line(line.rstrip()))
            # Follow mode
            while True:
                where = f.tell()
                line = f.readline()
                if line:
                    print(colorize_log_line(line.rstrip()))
                else:
                    time.sleep(0.1)
                    f.seek(where)
        else:
            # Print last N lines
            all_lines = f.readlines()
            for line in all_lines[-lines:]:
                print(colorize_log_line(line.rstrip()))

Technical Analysis

The application treats log-file contents as terminal-ready text. The colorize_log_line() function adds its own ANSI formatting but does not remove, encode, or visibly escape control characters already present in the input. The resulting attacker-contr ...[truncated 2116 chars]

Remediation
View remediation

Remediation Suggestions

Treat all log content as untrusted before writing it to an interactive terminal.

  1. Strip or visibly encode C0/C1 control characters, the ESC character, CSI sequences, OSC sequences, and other non-printable terminal controls before applying LogFlux's own formatting.
  2. Preserve only safe whitespace such as tabs when explicitly desired; represent other control bytes using escaped forms such as \x1b, \r, or Unicode control pictures.
  3. Apply sanitization before colorize_log_line() so only ANSI sequences generated internally by the application can reach the terminal.
  4. Consider disabling color automatically when output is not attached to a TTY.
  5. If raw output is required, expose it only through an explicit warning-bearing option rather than making it the default.
  6. Add tests containing CSI cursor movement, screen-clearing sequences, OSC hyperlinks, OSC 52 clipboard requests, carriage returns, and other control characters to verify that they are rendered inert.

Example hardening approach:

python
ANSI_ESCAPE = re.compile(
    r'[\x1b\x9b](?:\][^\x07]*(?:\x07|\x1b\\)|'
    r'[[\]()#;?]*(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d/#&.:=?%@~_]+)*)?\x07|'
    r'(?:(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=;<>~])))'
)

def sanitize_terminal_text(text):
    text = ANSI_ESCAPE.sub('', text)
    return ''.join(
        ch if ch in '\t' or ch.isprintable() else repr(ch)[1:-1]
        for ch in text
    )

Invoke sanitize_terminal_text(line.rstrip()) before colorization and printing.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep