Back to skill

Security audit

Network Scan

Security checks for vulnerabilities and agentic risk

Overview

This network-scanning skill is coherent, but needs review because it can probe broad networks and weak input checks can let requests change Nmap behavior beyond the documented options.

Install only if you intend to run authorized network scans. Use it in a controlled environment, avoid broad CIDR or aggressive scans unless approved, and treat the input-validation gaps as something to fix before exposing the skill to untrusted users or automated agents.

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

Error
Location
main.py:27
Finding
Unvalidated Input Permits Injection of Additional Nmap Arguments<![CDATA[ ## Vulnerability Details **File Location**: `main.py`, lines 27–28, 45–50, and 94–95 **Vulnerability Type**: Nmap argument injection through insufficient input validation **Risk Level**: High ### Vulnerable Code ```python if exclude: scan_options += f' --exclude {exclude}' ``` The `exclude` value originates directly from command-line input: ```python elif arg.startswith("--exclude="): exclude = arg.split("=")[1] ``` Range and comma-separated targets are also passed to the scanner without validating their individual addresses: ```python elif '-' in target: start_ip, end_ip = target.split('-') results = scanner.scan(start_ip+'-'+end_ip, ports, arguments=scan_options) elif ',' in target: results = scanner.scan(target, ports, arguments=scan_options) ``` ### Technical Analysis The implementation constructs the Nmap argument string by directly interpolating the attacker-controlled `exclude` value. Although the documentation describes this value as a single IP address, the code does not validate it with `ipaddress.ip_address()`, reject whitespace, or ensure that it contains only one address. Consequently, a value containing an address followed by additional Nmap options can alter the command interpreted by Nmap. This is Nmap argument injection rather than conventional shell-command injection: there is no evidence that shell metacharacters are directly evaluated by a shell, but an attacker can potentially access powerful Nmap functionality such as NSE script selection, script arguments, alternate configuration options, output controls, or more aggressive scan modes. The same validation weakness affects range and comma-separated targets. Unlike single-IP and CIDR targets, these formats are selected merely by checking for `-` or `,`, after which the unvalidated value is passed to `scanner.scan()`. The `ports` parameter is also passed through without an explicit application-level allowlist. ### Attack Path 1. An attacker obtains th ...[truncated 1811 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate `exclude` as exactly one IP address before constructing Nmap arguments: ```python if exclude: try: validated_exclude = str(ipaddress.ip_address(exclude)) except ValueError: return {"error": "Invalid exclusion address."} scan_options += f" --exclude {validated_exclude}" ``` 2. Validate every component of comma-separated target lists: ```python targets = target.split(",") if not targets or not all(is_valid_ipv4_address(item.strip()) for item in targets): return {"error": "Invalid comma-separated target list."} target = ",".join(str(ipaddress.ip_address(item.strip())) for item in targets) ``` 3. Parse ranges with a bounded split and independently validate both endpoints. Confirm that both addresses use the same IP version and that the start address does not exceed the end address. 4. Strictly validate the `ports` parameter against an allowlist grammar. Accept only port numbers and explicitly supported ranges, enforce values from 1 through 65535, and reject whitespace or option-like tokens. 5. Enforce safe bounds for numeric options: - Require `timeout` to be a positive integer with a reasonable maximum. - Require `top_ports` to be within Nmap-supported limits. - Require `hosts_limit` to be positive and capped according to the deployment policy. 6. Reject control characters, unexpected whitespace, and values beginning with `-` in all fields that can reach Nmap. 7. Prefer structured argument construction where supported by the dependency. Do not combine user-controlled values into a free-form option string. 8. Run the Skill under a dedicated, minimally privileged account. Avoid unnecessary root execution and restrict access to local NSE script directories and sensitive files. 9. Add regression tests that verify injected tokens such as additional Nmap options are rejected for `exclude`, targets, and ports before Nmap is invoked. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (3)

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

High
Category
YARA Match
Content
ats, including CIDR notation, IP ranges, and comma-separated lists.  Defaults to quick scan for CIDR.

## Inputs

*   `target`: The target network or IP address to scan (e.g., 192.168.1.0/24, 192.168.1.1-192.168.1.10, 192.168.1.1,192.168.1.2).
*   `ports`: The ports to scan (e.g., 80,443).
*   `--quick`: (Optional) Scan only the top 10 ports.
*   `--fast`: (Optional) Use aggressive scan settings (nmap -T4).
*   `--timeout`: (Optional) Set a timeout in seconds for the scan (default: 30).
*   `--top-ports`: (Optional) Scan the top N most common ports (e.g., --top-ports 100).
*   `--hosts-limit`: (Optional) Limit the number of hosts to scan (e.g., --hosts-limit 50).
*   `--exclude`: (Optional) Exclude a specific IP address from the scan (e.g., --exclude 192.168.1.5).

## Outputs

JSON object containing the nmap scan results. Includes scan results, nmap command used, and scan information.

## Usage

To use this skill, call it with the `target` and `ports` parameters:

```
network-scan targ
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 enables active network scanning but does not warn users that port scanning can disrupt services, trigger IDS/IPS alerts, or violate organizational policy or law if run without authorization. In this context, the omission increases misuse risk because the skill is explicitly designed to scan networks and even supports broader target formats such as CIDR ranges.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
This skill performs active network scanning against user-supplied targets and port ranges without any warning, confirmation, or authorization check before initiating outbound probes. In an agent or automation context, that can enable unintended reconnaissance of internal or external networks, creating policy, legal, and detection risks even if the code's apparent purpose is administrative.

Static analysis

No suspicious patterns detected.