# NSG Open Management Port Finder

> Finds Azure NSG rules that allow SSH, RDP, WinRM and other management ports from the internet. Reads az CLI JSON or ARM templates, skips Allow rules an earlier Deny already blocks, and warns about database ports and very wide source ranges. Offline and read-only.

NSG Open Management Port Finder is a free AI agent skill on Agensi by Abdelrhman Fikri, in DevOps & Cloud. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Abdelrhman Fikri](https://www.agensi.io/creators/abdelrhman-fikri)
- Category: [DevOps & Cloud](https://www.agensi.io/skills/devops-cloud)
- Version: 1.0.0
- Last updated: 2026-12-03
- Security: scan passed (2026-12-03); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/nsg-open-management-port-finder
- Tags: devops, security, code-review, azure, nsg, network-security, rdp, ssh

## What it does

- Reads az network nsg list output, rule lists and ARM templates that contain network security groups
- Flags inbound Allow rules open to any source on SSH, RDP, WinRM, Telnet, SMB and VNC ports as blockers
- Flags rules that open every port, including ranges that cover a management port
- Warns about database and Docker API ports and very wide source ranges
- Marks Allow rules that an earlier Deny rule already blocks as not effective
- Notes network security groups with no subnet or interface association in the export

## Who it's for

- **Cloud and platform engineers:** security reviewers and auditors who need a quick list of internet-exposed management ports from an NSG export.
- **Anyone reviewing an ARM template pull request:** who wants open management ports caught before merge.

## About this skill

The fastest way to lose a virtual machine is an NSG rule that lets the whole internet reach RDP or SSH. Portal reviews miss rules buried in long lists, in port ranges, or in ARM templates. This skill gives your agent a deterministic, offline workflow: export your NSGs, run the bundled finder, and read a short list of exposed ports with the rule name and priority.

The finder is a single standard-library script. It does not call Azure and never changes a rule. It reads the output of az network nsg list, a plain rule list, or an ARM template that contains network security groups or child security rules. For each inbound Allow rule it works out the source (any, Internet, a very wide range, or narrow) and the destination ports, including ranges and lists. Management ports open to any source are blockers. A rule that opens every port is a blocker. Database and Docker API ports, and sources such as AzureCloud or a huge public range, are warnings. Because Azure evaluates the lowest priority number first, an Allow rule that an earlier Deny rule already covers is marked not effective instead of raising a false alarm.

Synthetic example files with expected output are included so you can verify the behaviour in seconds.

## Known limitations

- It reads exported rules; it cannot see effective security rules after Azure Firewall, Application Security Groups or Virtual WAN, and it does not test real reachability.
- Only the fixed management and data port lists are checked; custom admin ports are not.
- Source and destination address prefixes are treated as a whole: a rule limited to one destination address is still reported, because the export alone cannot show what runs there.
- An Allow rule is called shadowed only when an earlier Deny rule from an open source covers all of the exposed ports.
- Reports and explains; it never edits rules.

## Technical details

The finder is a single standard-library Python script. It makes no network calls and never writes files. Give it files or directories; it reads .json.

Accepted input: the output of az network nsg list (securityRules with flat or nested properties), a list of rules from az network nsg rule list (grouped by the NSG name in each rule id), or an ARM template with networkSecurityGroups and child securityRules resources.

Only inbound Allow rules with TCP, UDP or any protocol are checked. Source classes: open (*, 0.0.0.0/0, Internet, Any), wide (the AzureCloud tag or a public IPv4 range of /8 or larger) and narrow. Destination ports are parsed from single ports, lists and ranges. Management ports: 22, 23, 445, 3389, 5900, 5985, 5986. Data ports: 1433, 1521, 2375, 3306, 5432, 6379, 9200, 27017.

An Allow rule is marked not effective when a lower-numbered inbound Deny rule from an open source covers all its exposed ports.

Exit codes: 0 no blockers, 1 blockers found, 2 bad arguments. Options: --format json, --hide-info.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the NSG Open Management Port Finder skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Does it need Azure access?

No. It only reads the JSON files you give it.

### Does it understand priorities?

Yes. A lower priority number is evaluated first, and an Allow that an earlier Deny already blocks is marked not effective.

### Does it read Bicep?

Not directly. Build the Bicep to an ARM template first, or export the NSGs with az.

### Which Python?

Python 3.9 or newer, no packages to install.

### What does exit code 1 mean?

One or more BLOCKER findings. Warnings alone still exit 0.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
