Back to skill

Security audit

Network Scanner

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but its network scanner has unsafe command execution and weaker-than-advertised public-scan protections.

Install only if you are comfortable reviewing or fixing the script first. Do not run it with untrusted network names, CIDRs, DNS values, or config files, and prefer --no-sudo until shell=True is removed, inputs are strictly validated, and configured networks receive the same public-target checks as ad-hoc targets.

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

Error
Location
scripts/scan.py:61
Finding

Shell Command Injection Through Unvalidated Network and DNS Parameters

Content
View full analysis
/dev/null" nmap_output = run_cmd(nmap_cmd, timeout=180) ``` ```python elif args.network in networks: net = networks[args.network] cidr = net['cidr'] dns = args.dns or net.get('dns') name = net.get('description', args.network) trusted_network = True # Pre-configured = trusted ``` ### Technical Analysis The centralized `run_cmd()` function executes command strings with `shell=True`. Consequently, shell metacharacters contained in interpolated values are interpreted by the operating-system shell rather than passed as literal arguments to `dig` or `nmap`. The following externally controllable values reach these command strings: - The `--dns` command-line argument. - The `dns` property of a configured network. - The `cidr` property of a named network loaded from a user-selected JSON file. - A configuration file selected through the `--config` argument. Ad hoc network arguments receive some val ...[truncated 3009 chars]
Remediation
View remediation
/dev/null`. Use `stderr=subprocess.DEVNULL` or capture stderr through `subprocess.run()`. 4. Validate every CIDR, including values from trusted named networks: ```python network = ipaddress.ip_network(cidr, strict=False) cidr = str(network) ``` 5. Validate DNS server values before use: ```python dns_server = str(ipaddress.ip_address(dns_server)) ``` 6. Reject unexpected option-like values and ensure user-controlled values cannot become executable names or nmap flags. 7. Treat configuration files as untrusted input regardless of their location or whether a network is labeled trusted. 8. Avoid invoking nmap through unrestricted sudo. If elevated scanning is required, use a narrowly scoped privilege mechanism and a fixed executable/argument policy. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/scan.py:376
Finding

Configured Networks Bypass Public-Target and Route Safety Validation

Content
View full analysis
1 else str(network.network_address) test_ip_obj = ipaddress.ip_address(test_ip) # BLOCK scanning public IP ranges entirely if not test_ip_obj.is_private: return False, f"Target {cidr} is a PUBLIC IP range - scanning public IPs is not allowed" except Exception as e: return False, f"Invalid CIDR: {e}" ``` Named configured networks are automatically designated as trusted: ```python elif args.network in networks: net = networks[args.network] cidr = net['cidr'] dns = args.dns or net.get('dns') name = net.get('description', args.network) trusted_network = True # Pre-configured = trusted ``` The complete validation function is then skipped for trusted networks: ```python # For non-trusted networks, verify we have a private route if not trusted_network: is_safe, route_reason = check_route_is_private(cidr) if not is_safe: print(f"❌ BLOCKED: Cannot safely scan {cidr}", file=sys.stderr) print(f" {route_reason}", file=sys.stderr) print(f" ...[truncated 2707 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (11)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This is a true tool-parameter abuse issue because command strings are assembled from externally influenced values and executed by a shell. In this skill context, users supply network names, CIDRs, DNS servers, and config entries, making exploitation realistic and especially dangerous on systems where the tool may run with elevated privileges.

Content

Scanner excerpt · scripts/scan.py (reported line 64)May include surrounding context.

python
def run_cmd(cmd, timeout=60):
    """Run a shell command and return output."""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
        return result.stdout.strip()
    except subprocess.TimeoutExpired:
        return ""

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

High
Category
YARA Match
Confidence
70% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

Scanner excerpt · scripts/scan.py (reported line 240)May include surrounding context.

python
json.dump(example, f, indent=2)
    print(f"Example config saved to {config_path}", file=sys.stderr)


def scan_network(cidr, dns_server=None, use_sudo=True):
    """Scan network using nmap and gather device info."""
    devices = []
    
    # Run nmap scan - use sudo for MAC discovery
    print(f"Scanning {cidr}...", file=sys.stderr)
    sudo = "sudo " if use_sudo else ""
    nmap_cmd = f"{sudo}nmap -sn -oX - {cidr} 2>/dev/null"
    nmap_output = run_cmd(nmap_cmd, timeout=180)
    
    if not nmap_output:
        print("No nmap output - check permissions or network", file=sys.stderr)
        return devices
    
    # Parse nmap XML output
    import xml.etree.ElementTree as ET
    try:
        root = ET.fromstring(nmap_output)
    except Exception as e:
        print(f"Failed to parse nmap output: {e}", file=sys.stderr)
        return devices
    
    for host in root.findall('.//host'):
        status = host.find('status')
        if status is None or status.get('state') != 'up':

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The code advertises safety controls that block scanning of public or unsafe routes, but any network defined in the config is marked trusted and bypasses the route/private-network verification entirely. If the config is modified maliciously or carelessly, the tool can scan public or externally routed targets despite the documented protections.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill advertises and demonstrates shell execution and likely file-writing behavior (for config initialization) but does not declare any explicit tool scope or permissions. This weakens governance and review because an agent could invoke shell-capable behavior without clear user-visible authorization boundaries, increasing the risk of unintended network scanning or local file modification.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

List configured networks

python3 scripts/scan.py --list

Scan without sudo (may miss MAC addresses)

python3 scripts/scan.py home --no-sudo

text

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

List configured networks

python3 scripts/scan.py --list

Scan without sudo (may miss MAC addresses)

python3 scripts/scan.py home --no-sudo

text

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
99% confidence
Finding

The helper executes shell commands with shell=True and is fed multiple command strings built from user-controlled inputs such as network, DNS server, interface name, and derived IP values. This creates a direct command injection path where an attacker can supply shell metacharacters to execute arbitrary commands on the host running the scanner.

Content

Scanner excerpt · scripts/scan.py (reported line 64)May include surrounding context.

python
def run_cmd(cmd, timeout=60):
    """Run a shell command and return output."""
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
        return result.stdout.strip()
    except subprocess.TimeoutExpired:
        return ""

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The code creates parent directories and writes example JSON directly to the path provided by --config, which can overwrite an existing file. Although it prints a message after writing, there is no prior confirmation, overwrite check, or warning in the CLI help/docstring that running --init-config may replace user data.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/scan.py (reported line 237)May include surrounding context.

python
"""Scan network using nmap and gather device info."""
    devices = []
    
    # Run nmap scan - use sudo for MAC discovery
    print(f"Scanning {cidr}...", file=sys.stderr)
    sudo = "sudo " if use_sudo else ""
    nmap_cmd = f"{sudo}nmap -sn -oX - {cidr} 2>/dev/null"

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/scan.py (reported line 336)May include surrounding context.

python
"""Scan network using nmap and gather device info."""
    devices = []
    
    # Run nmap scan - use sudo for MAC discovery
    print(f"Scanning {cidr}...", file=sys.stderr)
    sudo = "sudo " if use_sudo else ""
    nmap_cmd = f"{sudo}nmap -sn -oX - {cidr} 2>/dev/null"

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
97% confidence
Finding

The tool constructs a sudo-prefixed nmap shell command using untrusted CIDR input and then executes it through shell=True. This means command injection can occur in a context likely to prompt for or use elevated privileges, potentially leading to root-level arbitrary command execution.

Content

Scanner excerpt · scripts/scan.py (reported line 239)May include surrounding context.

python
# Run nmap scan - use sudo for MAC discovery
    print(f"Scanning {cidr}...", file=sys.stderr)
    sudo = "sudo " if use_sudo else ""
    nmap_cmd = f"{sudo}nmap -sn -oX - {cidr} 2>/dev/null"
    nmap_output = run_cmd(nmap_cmd, timeout=180)

Static analysis

No suspicious patterns detected.