← Back to All Articles
CSPM & CNAPP

Optimizing Azure Security Center Secure Score and Just-in-Time (JIT) VM Access

A 2018 Cloud Security Posture Management (CSPM) guide leveraging Azure Security Center Secure Score prioritization and NSG-backed Just-in-Time (JIT) VM Access to eliminate permanently open RDP (3389) and SSH (22) ports.

·9 min read·
#Azure Security Center#Defender for Cloud#Secure Score#JIT VM Access#CSPM#Azure
Optimizing Azure Security Center Secure Score and Just-in-Time (JIT) VM Access

Executive Summary and Cloud Posture Context

Leaving management ports like RDP (3389) and SSH (22) permanently open in Network Security Groups during initial Azure IaaS deployments guarantees automated brute-force scanning and credential stuffing within hours. Azure Security Center (ASC) pairs prioritized Secure Score remediation with Just-in-Time (JIT) VM Access, locking down management ports by default and inserting time-bound NSG Allow rules strictly upon authorized operator requests.

From an architectural evolution standpoint, this foundational design connects directly to modern platform controls. Born in 2018 as Azure Security Center (ASC), Microsoft’s CSPM engine evolved into Microsoft Defender for Cloud CNAPP—complementing Azure Bastion and Azure Firewall Private Link Microsegmentation across multi-cloud environments.

Detection Boundaries, Asset Scope, and Design Principles

  • Just-in-Time (JIT) VM Access denies inbound 22, 3389, and 5985/5986 traffic until an Azure AD PIM authorized operator initiates a short-lived (1–3 hour) source-IP-pinned session.
  • Secure Score weights cloud posture risks across encryption, endpoint protection, and exposed ports so engineering teams fix the highest-impact gaps first.
  • Adaptive Application Controls baseline legitimate server binaries via machine learning and flag unauthorized PowerShell or cryptomining execution.
  • Cloud and SaaS posture engines (CSPM/SSPM), attack-path graphs, and OAuth governance must tie directly to concrete privilege reduction and IaC/PR gates rather than accumulating unactioned alert queues.

Prerequisites, Connector Coverage, and RBAC Separation

  • Licensing: Azure Security Center Standard tier (today Microsoft Defender for Servers Plan 1/2) per subscription for JIT VM Access; baseline Secure Score runs free.
  • Infrastructure & RBAC: VMs must attach to ARM Network Security Groups (NSGs) or Azure Firewall, and requesters need least-privilege jitNetworkAccessPolicies/initiate permissions.
  • Monitoring Agent: Attach VMs to a central Log Analytics Workspace for OS patch and baseline configuration telemetry.

Technical Verification, Posture Score, and OAuth Audits

PowerShell Cloud and SaaS Posture Assessment

Inspecting Azure Secure Score and provisioning JIT VM Access policies via Az PowerShell:

  • Execution Environment and Prerequisites: Requires Az.*.
  • Least Privilege and Operation Separation: Run with scoped Azure Reader (audit) / Contributor (state changes) privileges. This block pairs **read-only (Get-*/Search-*) posture queries with state-changing (New-*/Set-*/Enable-*)** examples; execute mutating steps strictly under change control in a pilot ring (using -WhatIf where supported) before broad rollout.
  • Security Control Mapped and Boundary Note: Verifies active policy state and guards against silent drift or mis-scoped rollouts without blind production changes.
powershell
# 1. Retrieve current subscription Secure Score metrics
Connect-AzAccount
Get-AzSecuritySecureScore | Select-Object Name, CurrentScore, MaxScore, Percentage

# 2. Preview source-pinned Just-in-Time (JIT) VM Access policy with 3-hour max RDP ceiling
$vmId = "/subscriptions/<SUB_ID>/resourceGroups/RG-PROD-CORE/providers/Microsoft.Compute/virtualMachines/VM-APP-01"
$JitPolicy = @{
  id = $vmId
  ports = @(
    @{ number = 3389; protocol = "TCP"; allowedSourceAddressPrefix = "203.0.113.0/24"; maxRequestAccessDuration = "PT3H" },
    @{ number = 22; protocol = "TCP"; allowedSourceAddressPrefix = "203.0.113.0/24"; maxRequestAccessDuration = "PT2H" }
  )
}
Set-AzJitNetworkAccessPolicy -ResourceGroupName "RG-PROD-CORE" -Location "westeurope" -Name "default" -Kind "Basic" -VirtualMachine @($JitPolicy) -WhatIf

Cloud Security Telemetry and KQL Query

KQL audit tracking JIT access approvals alongside direct NSG rule modifications in AzureActivity:

kql
// Execution Scope: Read-only hunting/audit query (Log Analytics Reader / Security Reader)
// Data Source: Azure Activity Log Diagnostic Settings -> Log Analytics / Microsoft Sentinel (AzureActivity)
AzureActivity
| where TimeGenerated > ago(14d)
| where OperationNameValue has_any ("jitNetworkAccessPolicies/initiate", "networkSecurityGroups/securityRules/write")
| where ActivityStatusValue == "Success"
| project TimeGenerated, Caller, CallerIpAddress, OperationNameValue, ResourceGroup, ResourceId
| summarize RequestCount = count() by Caller, OperationNameValue, ResourceGroup
| order by RequestCount desc

Critical Architectural Assessment, Production Risks, and Rollback Strategy

  • Excessive Maximum Request Duration: Leaving maxRequestAccessDuration at 24 hours defeats time-bound defense; cap production JIT windows at PT2H or PT3H.
  • Missing NSGs on Subnets: VMs residing in subnets without NSGs cannot enforce JIT deny baselines; mandate NSG attachment via Azure Policy.
  • Risks Mitigated vs. Residual Limitations: Defender CSPM, attack-path graphs, FIM, and Shadow AI OAuth governance curb public cloud exposure, drift on sensitive host files, and illicit consent grants; however, they do not stop zero-day runtime exploits before patches/detections arrive, logic bugs in custom SaaS apps, or credential abuse on accounts outside connector RBAC scope.
  • New Dependencies and Production Failure Modes: Coverage relies on active multi-cloud read connectors (AWS/GCP), endpoint/VM agents, and App Governance API feeds. Blindly enabling automatic OAuth revocation or strict PR/deployment gates can interrupt authorized vendor workflows or release pipelines.
  • Rollback and Pilot Validation Procedure: Operate OAuth app governance and IaC admission gates in audit/alert mode before activating enforcement; export Get-MgOauth2PermissionGrant baselines and retain Defender policy exemptions to reinstate inadvertently paused integrations.

Verified Primary Sources & Open-Source Repositories

This architectural guide was cross-corroborated against the official advisories, Microsoft Learn docs, and open-source PowerShell / KQL repositories below.

Multi-Channel Distribution Summary (X & LinkedIn Draft)

Toggle X (Twitter) & LinkedIn sharing drafts
X (Twitter) Draft

Eliminate permanently open RDP and SSH ports in Azure IaaS with Azure Security Center Secure Score and Just-in-Time (JIT) VM Access. #DefenderForCloud #CSPM #Azure

LinkedIn Draft

2018 Azure CSPM blueprint: prioritizing infrastructure risks with Secure Score and enforcing time-bound NSG Just-in-Time VM Access via Az PowerShell.