By NHI Mgmt Group Editorial TeamDomain: Cyber SecuritySource: ProwlerPublished March 20, 2026

TL;DR: Only about 10% of the CIS Microsoft 365 benchmark was covered by Microsoft Graph alone, so meaningful Microsoft 365 auditing had to combine Graph with controlled PowerShell sessions, according to Prowler. The practical lesson is that security visibility often depends on the least elegant integration path, especially when identity, authentication state, and command safety all matter.


At a glance

What this is: This is a technical analysis of how Prowler extended Microsoft 365 auditing by running PowerShell from Python to cover CIS benchmark checks that Microsoft Graph could not reach.

Why it matters: It matters because IAM and cloud security teams often face the same control gap when official APIs expose only part of the configuration state and the rest sits behind session-based tooling and persistent authentication.

By the numbers:

👉 Read Prowler's analysis of PowerShell-based Microsoft 365 audit coverage


Context

Microsoft 365 audit coverage often breaks down at the boundary between API visibility and platform-specific administrative access. In practice, a security tool can be technically correct and still miss most of the control surface if it relies on a single integration path. This article is about that gap, and it has an identity dimension because the hard part is not only collecting settings but preserving authentication state safely across automated sessions.

The architectural problem is familiar to IAM and NHI practitioners: when a workflow depends on authenticated sessions, secrets handling, and command execution in a runtime process, the control plane becomes part identity system, part automation engine. Prowler's experience is typical of teams that discover the official interface covers only a fraction of the governance requirement, while the rest requires careful handling of credentials, session persistence, and execution boundaries.


Key questions

Q: What breaks when Microsoft 365 audit automation depends on a single API surface?

A: Coverage breaks first. If the API does not expose all of the relevant configuration and control data, the audit can look successful while leaving large parts of the benchmark untested. In practice, teams need a fallback collection path for settings that only appear in administrative modules or session-based tools, otherwise their evidence is incomplete.

Q: Why do stateful admin sessions create extra risk in security automation?

A: They turn authentication into a living runtime dependency. Once a process holds session state across multiple commands, the workflow becomes a privileged non-human identity with its own lifecycle, timeout, and parsing risks. That increases the blast radius of bugs in command handling, input validation, and process management.

Q: How do you know if audit automation is actually complete?

A: Check whether every control maps to a verified data source, not just whether the integration works. A complete audit should show control-by-control coverage, known exceptions, and a documented reason for any residual gap. If the easiest interface is also the only one you use, completeness is probably overstated.

Q: Who is accountable when privileged automation can be abused through command input?

A: The owning platform and security teams share accountability, because the control failure sits at the boundary between application design, identity governance, and operational oversight. Frameworks such as NIST SP 800-53 and NIST Cybersecurity Framework 2.0 both expect clear access control, monitoring, and resilience over privileged automation paths.


Technical breakdown

Why Microsoft Graph alone did not provide complete CIS coverage

Microsoft Graph is the supported programmatic interface for many Microsoft 365 services, but supported does not mean sufficient for every audit use case. The article shows a classic coverage gap: a vendor API may expose common objects and actions, while deeper security configuration remains accessible only through administrative paths or service-specific modules. That matters because compliance evidence is only as complete as the interface used to collect it. When an audit tool depends on one API, it inherits that API's blind spots and cannot claim full control verification.

Practical implication: validate whether your audit source actually covers every control family before you treat its output as complete evidence.

How persistent PowerShell sessions preserve authentication state

Running each command in a fresh subprocess breaks session continuity, which is a problem when Microsoft 365 modules expect one authenticated context across multiple queries. The solution described here is a long-lived PowerShell process that receives commands over stdin, returns output through stdout and stderr, and uses response markers to tell the caller when a command is finished. That design keeps authentication alive while avoiding the false independence of one-off calls. It is essentially a controlled session broker, not a casual command runner.

Practical implication: if your automation depends on stateful admin sessions, design for session lifecycle management rather than repeated re-authentication.

Why command injection and denial of service are the real control risks

The security risk is not PowerShell itself, but untrusted input crossing a language boundary into a live shell. The article highlights two failure modes: injection through malformed commands and denial of service through queries that never terminate. The mitigation pattern is layered, combining input sanitization, character validation, backend protections, and strict execution timeouts. For identity teams, this is a useful reminder that automation controls are part of the threat surface whenever secrets, credentials, or privileged sessions are embedded in runtime workflows.

Practical implication: treat shell-bound automation as a privileged pathway and enforce sanitization, timeouts, and session isolation before production use.


Threat narrative

Attacker objective: The attacker objective is to disrupt or manipulate privileged audit execution so that security visibility degrades or monitoring stops producing complete results.

  1. Entry begins when untrusted query content reaches a shell-backed automation path inside a privileged Microsoft 365 audit workflow.
  2. Escalation occurs when malformed input can keep the PowerShell session running indefinitely or attempt command injection through session context.
  3. Impact is denial of service against the audit process, reducing visibility and potentially leaving security-relevant M365 settings unchecked.

NHI Mgmt Group analysis

Coverage gaps are governance gaps, not just integration gaps. If Microsoft Graph exposes only a fraction of the CIS benchmark, the problem is not tooling preference but incomplete control evidence. Security teams routinely assume an API is authoritative because it is official, yet governance fails when the audit source cannot see the full configuration state. The lesson for practitioners is to validate evidence coverage before relying on any single access path.

Persistent automation sessions create a distinct identity and session risk surface. The moment a workflow preserves authentication across multiple commands, it behaves like a governed non-human session rather than a simple script. That means secrets handling, session lifetime, and command boundaries become identity controls in practice. Practitioners should treat long-lived automation processes as privileged workloads with explicit lifecycle governance.

Command execution boundaries need the same discipline as privileged access boundaries. The article shows that sanitization alone is not enough if execution can hang or state can bleed across commands. That is the same governance mistake seen in many NHI environments, where runtime access is assumed to be safe because it is machine-driven. The named concept here is session persistence risk: when a long-lived authenticated process becomes the control point, failures in timeout, parsing, or input handling can turn that session into a durable attack surface. Practitioners should govern the session, not just the credentials.

Security coverage should be measured against control completeness, not interface convenience. A clean API can make implementation easier while leaving large parts of the control plane unseen. That tension appears across IAM, PAM, and NHI programmes whenever operational reality is split across official APIs, administrative consoles, and service-specific protocols. Practitioners should define audit completeness metrics that reflect the full control requirement, not the easiest integration path.

What this signals

The operational signal here is that audit tooling is increasingly part of the identity plane, not separate from it. As Microsoft 365 coverage expands beyond the easiest API surfaces, teams will need explicit ownership for authenticated automation, session timeouts, and command handling, especially where service accounts or other non-human identities execute privileged checks.

Session persistence risk: when a long-lived authenticated process becomes the control point, failures in parsing, timeout, or input validation can create a durable attack surface. That pattern should prompt security leaders to align automation governance with the NIST Cybersecurity Framework 2.0 and to map privileged workflow controls to NIST SP 800-53 access and audit requirements.

For identity programmes, the forward move is to treat collection tooling as a governed workload with its own lifecycle. Where credentials, certificates, or tokens are used to reach administrative data, the same rotation, offboarding, and monitoring discipline used for other NHIs should apply, with special attention to session duration and command isolation.


For practitioners

  • Validate audit coverage against the actual control set Map each Microsoft 365 or similar benchmark control to the data source that proves it. If the primary API only covers a minority of checks, document the residual gap and assign an alternate collection method for the missing controls.
  • Treat persistent automation sessions as privileged identities Assign ownership, rotation rules, timeout policies, and break-glass handling to every long-lived automation process that preserves authentication state across commands. Apply the same review discipline you would use for a high-value service account.
  • Harden shell-backed integrations against malformed input Use strict sanitization, command allow-listing, and output delimiters whenever Python or another orchestrator sends instructions to PowerShell or any other shell. Add fail-closed timeouts so a malformed query cannot keep the session alive indefinitely.
  • Separate collection reliability from execution safety Measure completeness of collected findings separately from the risk of the collection mechanism itself. A secure audit pipeline must prove both that it sees enough of the environment and that the path used to collect evidence cannot be abused.

Key takeaways

  • Microsoft 365 audit coverage can fail long before detection or remediation if the chosen interface cannot see enough of the control surface.
  • Long-lived PowerShell sessions behave like privileged non-human identities, so authentication state, timeout logic, and input handling become governance controls.
  • The right design goal is not convenience but complete evidence with bounded execution risk, especially where automation touches secrets and administrative access.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST CSF 2.0, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST CSF 2.0PR.AC-4Session-backed audit workflows depend on controlled access to administrative data.
NIST SP 800-53 Rev 5IA-5The article centres on managing credentials and session persistence safely.
CIS Controls v8CIS-5 , Account ManagementThe workflow relies on account and session governance for administrative checks.

Map authenticated automation to PR.AC-4 and verify least-privilege access for every collection session.


Key terms

  • Persistent PowerShell Session: A long-lived PowerShell process that keeps authentication state active across multiple commands. In audit automation, it acts like a controlled runtime session rather than a one-shot script, which makes lifecycle management, timeout enforcement, and input validation essential security controls.
  • Control Coverage: Control coverage is the degree to which security controls actually match the assets, identities, and data flows they are meant to protect. A programme can look mature on paper while still missing blind spots if discovery, classification, and enforcement are not aligned.
  • Session Persistence Risk: The security exposure created when a privileged automation process retains state between commands. That state can be useful for authentication, but it also increases the impact of parsing bugs, malformed input, and process hangs if the session is not tightly governed.

What's in the full article

Prowler's full post covers the engineering detail this analysis intentionally leaves at a higher level:

  • Step-by-step breakdown of the PowerShell session wrapper used to preserve authentication across multiple M365 queries
  • Command parsing, stdout and stderr handling, and marker-based response delimiting for long-lived subprocesses
  • The specific sanitization and timeout protections added after internal break testing exposed denial-of-service risk
  • Why the hybrid Graph plus PowerShell approach was necessary to reach automated CIS coverage in Microsoft 365

👉 Prowler's full post covers the hybrid architecture, security hardening, and session handling details.

Deepen your knowledge

NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, secrets management, and identity lifecycle controls. It gives security and identity practitioners a practical framework for governing privileged automation and other non-human sessions.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 15, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org