Back to skill

Security audit

Tech Security Audit

Security checks for vulnerabilities and agentic risk

Overview

The skill appears intended for Nmap-based security scanning, but it can launch active scans against arbitrary targets without strong scope controls or target validation.

Install only if you are comfortable with an agent running active Nmap scans. Use it only on systems and networks you own or are explicitly authorized to test, and add target validation or manual confirmation before allowing arbitrary hostnames, CIDR ranges, or user-supplied target text.

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
nmap_scanner.py:16
Finding
Unvalidated Scan Target Allows Nmap Option Injection## Vulnerability Details **File Location**: `nmap_scanner.py`, lines 16–27 **Vulnerability Type**: Nmap argument and option injection **Risk Level**: Medium ### Vulnerable Code ```python if scan_type == "vulnerability": cmd = ["nmap", "-sV", "--script", "vuln", target, "-oX", "-"] elif scan_type == "service": cmd = ["nmap", "-sV", target, "-oX", "-"] elif scan_type == "os": cmd = ["nmap", "-O", target, "-oX", "-"] else: cmd = ["nmap", target, "-oX", "-"] try: # Run the scan result = subprocess.run(cmd, capture_output=True, text=True, timeout=300) ``` ### Technical Analysis The caller-controlled `target` value is inserted directly into the Nmap argument list without validation. Although `subprocess.run()` is used without `shell=True`, which prevents conventional shell metacharacter injection, Nmap still interprets arguments beginning with a hyphen as command-line options. Consequently, a value intended to represent an IP address, CIDR range, or hostname can instead alter Nmap's behavior. For example, an input using Nmap's inline input-list option, such as `-iL/path/to/targets`, may cause Nmap to read scan targets from a local file rather than treating the value as a target. Other supported inline Nmap options may modify script selection, data directories, exclusions, or scan configuration. Because the value occupies one process argument, embedded spaces do not create multiple shell arguments. Exploitation is nevertheless possible through Nmap options that support attached or equals-delimited values. ### Attack Path 1. An application exposes `run_nmap_scan()` to a caller and passes caller-controlled input as `target`. 2. The attacker supplies a value beginning with `-`, such as an attached Nmap input-list option referencing a known local file. 3. The function adds the value to `cmd` without checking whether it is a valid IP address, network range, or hostname. 4. `subprocess.run() ...[truncated 1135 chars]
Remediation
## Remediation Suggestions 1. Validate `target` before constructing the command: - Parse IP addresses and CIDR ranges with Python's `ipaddress` module. - If hostnames are supported, enforce a conservative hostname syntax and length limit. - Reject empty values, control characters, whitespace-separated target expressions, and all values beginning with `-`. - Explicitly decide whether multiple targets, wildcard expressions, or Nmap-specific target syntax are allowed. 2. Separate validation by supported target type rather than relying only on a blacklist. For example: ```python import ipaddress import re HOSTNAME_RE = re.compile( r"(?=.{1,253}\Z)" r"(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)*" r"[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\Z" ) def validate_target(target: str) -> str: if not isinstance(target, str) or not target or target.startswith("-"): raise ValueError("Invalid scan target") try: ipaddress.ip_network(target, strict=False) return target except ValueError: pass if HOSTNAME_RE.fullmatch(target): return target raise ValueError("Target must be an IP address, CIDR range, or hostname") ``` 3. Apply network authorization controls in addition to syntax validation. If the Skill is intended only for local networks, resolve hostnames and verify that every resulting address belongs to an explicitly approved network range. 4. Run Nmap with the minimum required operating-system privileges. Do not run the containing service as root unless a specific scan mode requires it. 5. Add regression tests covering: - Valid IPv4 and IPv6 addresses. - Valid CIDR ranges and hostnames. - Leading-hyphen inputs. - Attached options such as `-iL...`. - Equals-delimited long options. - Control characters, malformed CIDRs, and whitespac ...[truncated 85 chars]
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (3)

YARA rule 'offensive_tool_references': References to well-known offensive security tools [hacktools]

High
Category
YARA Match
Content
.join(os.path.dirname(__file__)))

from nmap_scanner import _parse_nmap_xml
import xml.etree.ElementTree as ET

def test_parser_with_sample_data():
    """Test the Nmap XML parser with sample data."""
    print("Testing Nmap XML parser with sample data...")
    
    # Sample Nmap XML output
    sample_xml = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nmaprun>
<nmaprun scanner="nmap" args="nmap -sV example.com" start="1234567890">
    <scaninfo type="syn" protocol="tcp"/>
    <host>
        <status state="up"/>
        <address addr="192.168.1.100" addrtype="ipv4"/>
        <hostnames>
            <hostname name="example.local" type="user"/>
        </hostnames>
        <ports>
            <port protocol="tcp" portid="22">
                <state state="open"/>
                <service name="ssh" version="OpenSSH 7.9"/>
            </port>
            <port protocol="tcp" portid="80">
                <state state="open"/>
                <service name="http" version="Apache httpd
Confidence
70% confidence
Finding
YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill advertises local network scanning and vulnerability assessment capabilities but does not warn users that active scans can be disruptive, trigger monitoring/IDS alerts, violate policy, or affect fragile services and devices. In a skill specifically designed for Nmap-based scanning, this omission increases the chance of unsafe or unauthorized use because users may treat the operation as routine and low-risk.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
try:
        # Run the scan
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
        
        if result.returncode != 0:
            return {"error": f"Nmap scan failed with return code {result.returncode}", "stderr": result.stderr}
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Static analysis

No suspicious patterns detected.