Back to skill

Security audit

Regex Tester

Security checks for vulnerabilities and agentic risk

Overview

This skill is a straightforward local regex testing helper, with a resource-exhaustion caveat for unsafe or very large patterns and inputs.

Installers should treat this as a local utility for trusted or reasonably sized regex workloads. Avoid running attacker-supplied pathological patterns or very large text through it unless the host environment adds time and memory limits.

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/regex_tester.py:64
Finding

Unbounded Regular Expression Execution Enables Denial of Service

Content
View full analysis

Vulnerability Details

File Location: scripts/regex_tester.py, lines 64–72
Vulnerability Type: Regular Expression Denial of Service and uncontrolled resource consumption
Risk Level: Medium

Vulnerable Code:

python
try:
    compiled = re.compile(pattern, flags)
except re.error as e:
    if as_json:
        print(json.dumps({"valid": False, "error": str(e)}))
    else:
        print(f"Invalid regex: {e}", file=sys.stderr)
    return 2

matches = list(compiled.finditer(text))

Technical Analysis

The application compiles and evaluates a user-controlled regular expression against user-controlled text using Python's backtracking re engine. No execution timeout, input-size restriction, pattern-complexity restriction, memory limit, or match-count limit is applied.

Certain expressions, such as (a+)+$, can trigger catastrophic backtracking when evaluated against a long near-matching string. CPU consumption may grow exponentially with input length. Additionally, converting the complete iterator into a list causes every match object to be retained simultaneously. Large inputs or patterns producing many matches can therefore cause excessive memory use even without catastrophic backtracking.

The regular expression itself does not provide command execution or elevated privileges. The exploitable consequence is resource exhaustion in the process or service invoking this skill.

Attack Path

  1. An attacker submits a pathological pattern, such as (a+)+$.
  2. The attacker supplies a sufficiently long near-matching input, such as many a characters followed by a nonmatching character.
  3. The agent invokes the documented regex tester with the attacker-controlled pattern and text.
  4. re.compile() accepts the syntactically valid expression.
  5. compiled.finditer(text) performs uncontrolled backtracking without a timeout.
  6. The process consumes excessive CPU and may remain unresponsiv ...[truncated 843 chars]
Remediation
View remediation

Remediation Suggestions

  1. Run regular-expression evaluation in a dedicated worker process with a strict wall-clock timeout. Terminate the worker if the limit is exceeded.
  2. Apply operating-system resource limits to the worker, including CPU time and maximum address-space or memory limits.
  3. Enforce conservative maximum lengths for both the pattern and input text before compilation or matching.
  4. Reject or separately handle expressions containing risky nested quantifiers, ambiguous alternation, and repeated zero-width constructs. Treat heuristic validation as defense in depth rather than a replacement for timeouts.
  5. Consider a non-backtracking regular-expression engine where compatibility permits, or an engine that provides an enforceable per-operation timeout.
  6. Avoid eagerly materializing all matches with list(). Iterate incrementally and stop after a configured maximum number of matches.
  7. Limit the size of captured values and generated plain-text or JSON output to prevent secondary memory exhaustion.
  8. Return a distinct timeout or resource-limit error so callers can safely distinguish rejected workloads from invalid patterns and ordinary nonmatches.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (1)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The invocation guidance says to use the skill when a user asks to "test, debug, validate, or explain a regex pattern," which is broad and lacks explicit boundaries or negative examples. While regex is somewhat domain-specific, the activation condition does not clearly define when this skill should be preferred versus general explanation or text-processing help, increasing the chance of unintended invocation.

Content

No source excerpt is available for this finding.