/azure-access-and-exposure-audit:azure-access-and-exposure-auditfrom azure-access-and-exposure-audit
Audits Azure network exposure and hardens ACLs, or diagnoses RBAC/PIM access, activation, and approval failures using PowerShell or bash scripts.
Ships in azure-access-and-exposure-audit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two related investigation workflows: is this exposed? and why can't this identity do that?
Both fail the same way — a plausible but wrong answer, produced fast. Every rule here exists because it caused a real wrong answer. Report evidence, not inference.
publicNetworkAccess for the
types that matter most. ARG for inventory, direct ARM GET for the verdict.enable_<security-thing> = true is not
automatically additive — it can be a kill switch.Every tool ships in PowerShell and bash. Both report incomplete reads explicitly; their presentation and PIM policy handling differ as described below.
| Task | Windows (PowerShell 5.1+) | Linux / macOS (bash) |
|---|---|---|
| Exposure audit | Get-AzPublicExposure.ps1 | get-az-public-exposure.sh |
| Group → real RBAC | Get-AzGroupRbacMap.ps1 | get-az-group-rbac-map.sh |
| PIM status / activate / approve | Get-AzPimStatus.ps1 | get-az-pim-status.sh |
| networkAcls hardening | Set-AzNetworkAclHardening.ps1 | set-az-network-acl-hardening.sh |
Dependencies: the .sh scripts need only az — no jq, no curl. All parsing goes
through az --query ... -o tsv. They are bash 3.2 compatible, so they run on stock macOS.
chmod +x scripts/*.sh # once, after cloning
scripts/run-checks.sh # regression gate - re-run after ANY change to a .sh script
PowerShell Core (pwsh) also runs on Linux/macOS, so the .ps1 versions work there too if
preferred — they use only az, Invoke-RestMethod and built-in cmdlets.
⚠️ Do not run the
.shversions under Git Bash on Windows. Two independent things break, and both fail silently:
- MSYS rewrites a leading
/subscriptions/...argument intoC:/Program Files/Git/subscriptions/..., so every--idslookup fails, stderr is suppressed, and every resource reports as a FINDING.azisaz.cmd, parsed bycmd, which mangles the( )inasTarget()/asApprover()and fails with-o was unexpected at this time— which looks like an auth error.Use the
.ps1versions on Windows; they call ARM directly with a bearer token. WSL is fine and is a good place to test the.shvariants — it does not rewrite argument paths.
Verification status: this revision is checked with PowerShell parsing, bash syntax/help/ argument/encoding checks, and offline CLI/ARM fixtures on Windows PowerShell 5.1 and WSL Ubuntu. The fixtures exercise read and membership failures, scoped hardening with preserved bypasses, exposure controls and CSV identities, RBAC scopes, and scoped PIM activation/deactivation bodies. No live cloud audit, activation, approval, or hardening operation was performed for this revision. Perform a report-only pass before using these scripts in a new estate.
Run the regression suite from this skill directory with Python 3 and its test-only dependency:
python -m pip install -r tests/requirements.txt
python -B tests/test_audit_scripts.py
On Linux/macOS use python3. Run on Windows for PowerShell coverage and on Linux/macOS for bash
coverage. The fake transport rejects unrecognized calls and never invokes a live Azure command.
Use when responding to an exposure finding or auditing an estate.
scripts/Get-AzPublicExposure.ps1 -SubscriptionId <sub1>,<sub2> -CsvPath .\exposure.csv
scripts/get-az-public-exposure.sh -s <sub1> -s <sub2> -c ./exposure.csv
Enumerates 17 selected resource types and reads each with a direct ARM GET. This is a bounded
configuration audit, not proof of network reachability or exhaustive Azure coverage. Results are
FINDING, weak-2nd-control, explained, info, ok, or unverifiable. Read failures and
unsupported/missing controls remain visible; info requires interpretation and is not compliance.
Exit codes: 2 means an incomplete audit, 1 means findings with no incomplete reads, and 0
means neither. 0 does not certify informational results. CSV output includes subscription and
resource identity. -a / -IncludeCompliant also shows ok results.
Then:
Read references/public-exposure-audit.md for the type matrix, per-type verdict rules, the false-positive catalogue and the two-control model.
scripts/Set-AzNetworkAclHardening.ps1 -TargetJsonPath .\targets.json # report
scripts/Set-AzNetworkAclHardening.ps1 -TargetJsonPath .\targets.json -Apply # change
scripts/set-az-network-acl-hardening.sh -f ./targets.tsv # report
scripts/set-az-network-acl-hardening.sh -f ./targets.tsv -A # change
PowerShell takes JSON objects
({ "Kind": "storage"|"keyvault", "Sub": "...", "Rg": "...", "Name": "...", "Label": "dev" });
bash takes the same fields as tab-separated lines (kind<TAB>sub<TAB>rg<TAB>name<TAB>label,
# comments allowed).
The hardening commands change only defaultAction to Deny; they omit --bypass to preserve
the existing Storage or Key Vault bypass configuration in both report and apply modes.
Before applying: confirm whether the platform's IaC manages these properties — if it does, the change belongs in the module or it will be reverted on the next apply. Apply to non-production first, then run a plan and check for drift. If the storage account is an IaC state backend, verify a plan still runs before touching production.
Before changing an edge control (WAF, IP allow-list, deny-all), read references/edge-waf-traps.md — it documents a change that would have 403'd 100% of production traffic, and the Detection-mode rollout that avoids it.
Use for AuthorizationFailed, missing access, or a request nobody can find.
Start here — it resolves most cases and takes one command:
scripts/Get-AzGroupRbacMap.ps1 -GroupPrefix '<app group prefix>' -SubscriptionId <sub1>,<sub2> -ShowMembers
scripts/get-az-group-rbac-map.sh -p '<app group prefix>' -s <sub1> -s <sub2> -m
Maps every matching group to the RBAC it actually grants, active and PIM-eligible, and
includes the scope of every assignment. Only successful, empty reads are flagged as no assignments
for that group/subscription pair. Failed queries are UNVERIFIABLE and return nonzero; do not call
those groups dead. Compare each reported scope with the failing operation's resource scope;
nested groups, deny assignments, conditions, and directory roles need separate evaluation.
Optional member-query failures are reported separately as MEMBERS: UNVERIFIABLE and return
nonzero while preserving successfully read RBAC data. Only a successful empty member lookup
reports MEMBERS(0).
In a real case two of five groups — the two most obvious names —
carried zero RBAC on both subscriptions; requests against them never reached the queue of the group
that did grant access.
Then check the identity's own position:
scripts/Get-AzPimStatus.ps1 -SubscriptionId <sub> # eligible / active / in-flight / policy
scripts/Get-AzPimStatus.ps1 -Activate -Hours 2 -Justification '<why>' # raise activation
scripts/Get-AzPimStatus.ps1 -Approvals # as the APPROVER identity
scripts/Get-AzPimStatus.ps1 -Approvals -Approve
scripts/get-az-pim-status.sh -s <sub> # eligible / active / in-flight / policy
scripts/get-az-pim-status.sh -A -t 2 -j '<why>' # raise activation
scripts/get-az-pim-status.sh -L # as the APPROVER identity
scripts/get-az-pim-status.sh -L -P
PowerShell reads the governing policy and clamps duration, including fractional-hour maxima.
Policy lookup and activation requests use the selected eligibility's properties.scope, including
resource-group and resource scopes. Deactivation (-Deactivate / -D) selects an Activated assignment
belonging to the caller and sends its roleAssignmentScheduleId as targetRoleAssignmentScheduleId
at that assignment's scope; it does not require an eligibility record or activation-policy lookup.
Standing Assigned instances remain visible in the report but are excluded from deactivation selection.
Supply -TicketNumber and -TicketSystem when ticketing is required; the script stops before
writing if they are absent. Bash sends the requested -t duration and lets ARM enforce the
policy; use -k / -y for ticket number/system. It returns nonzero on rejection. Bash activation
requires a successful az ad signed-in-user show lookup; PowerShell gets the principal from the
ARM token. Approval mode in both variants uses returned full resource IDs and approves only
InProgress stages assigned to the current caller. List/read/PATCH failures return nonzero.
Three things to establish early, in order:
az cannot read or approve the former at all.T1-/admin account. The
normal account sees an empty queue even when requests exist.Read references/access-and-pim.md for the full diagnosis order, the queue comparison table, the group-name evidence, ownership rules, active-vs-eligible, and an escalation template.
Read references/powershell-az-traps.md first. It covers five traps that each produced a confidently wrong result:
$ErrorActionPreference='Stop' + az stderr → the loop dies silently mid-run and skips targets@($null).Count returns 1 → phantom IP allow-list rulesaz.cmd + cmd parsing → ( ) in --query fails as -o was unexpected, looks like an auth errorparam() block makes a wrapper advanced → az's -o collides with -OutVariable*> redirection writes UTF-16 → unreadable logsWrite findings so someone can act without re-running anything:
applied / blocked — waiting on X / gated). "Blocked" with a named
blocker is a useful result.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub guicedee/ai-rules --plugin azure-access-and-exposure-audit