How to Flatten AuditData JSON in Microsoft 365 Unified Audit Log CSV Exports
Microsoft Purview Unified Audit Log CSV exports store crucial forensic fields—such as ClientIP, UserAgent, Parameters, and Target objects—inside a single escaped JSON string column named AuditData. Flattening AuditData recursively promotes every nested key and {Name, Value} array into clean tabular columns so SOC analysts can sort, filter, and pivot on attacker infrastructure in seconds without risking confidential uploads.
Why This Artifact Matters in M365 Incident Response
Anyone who has opened a Microsoft Purview Audit Search export inside Excel hits an immediate wall of friction: five narrow top-level columns (RecordId, CreationDate, RecordType, Operation, UserId) followed by a massive, multi-kilobyte blob of escaped JSON inside the AuditData column. The actual evidence needed to prove or disprove an intrusion—the source IP address, port number, HTTP User-Agent, client application ID, target folder path, and cmdlet arguments—sits locked inside that single cell.
During high-pressure Business Email Compromise (BEC) or Adversary-in-the-Middle (AiTM) triage, analysts rarely have time to debug multi-line PowerShell loops on a locked-down jump box or fight Excel Power Query parsing errors when double-double quotes break row boundaries. Worse, pasting corporate audit exports containing employee emails, search terms, and internal document names into random cloud CSV tools creates a secondary confidentiality leak.
Unlike flat syslog files, Exchange Online, SharePoint, Teams, and Entra ID emit completely different JSON sub-schemas inside AuditData depending on RecordType. Exchange Admin cmdlets (RecordType 1) pack command arguments into a Parameters array of {"Name":"...","Value":"..."} objects. Entra logins (RecordType 8, 9, and 15) bury UserAgent inside ExtendedProperties arrays, while MailItemsAccessed telemetry nests message IDs inside Folders and OperationProperties arrays.
Generic JSON flatteners treat those Name/Value lists as opaque array indices like Parameters[0].Name="MoveToFolder" and Parameters[0].Value="RSS Feeds"—forcing you to still write complex pivot rules just to read what changed. An M365-aware flattener detects Name/Value pair arrays automatically and collapses them directly into semantic keys like AuditData.Parameters.MoveToFolder and AuditData.ExtendedProperties.UserAgent, transforming messy telemetry into an instant SOC investigation grid.
Step-by-Step Attack Reconstruction Timeline
Consider a real-world Friday afternoon BEC alert: a helpdesk engineer exports 4,200 Purview UAL rows covering seven days of an executive’s mailbox into Purview_Exec_7d.csv and opens it in Excel. Searching Excel for "RSS Feeds" matches 14 lines, yet Excel renders the entire AuditData cell as one unreadable paragraph and truncates display past 32,767 characters if an affected folder list is huge.
By dropping that unmodified Purview_Exec_7d.csv straight into AuditVane’s client-side browser worker, RFC 4180 quote unescaping runs locally in under 150 milliseconds, unfolding 48 distinct AuditData keys across every row. Immediately, AuditData.Parameters.MoveToFolder reveals a stealth rule named ".." created from 185.220.101.45 using axios/1.7.7—and exporting the Flattened CSV strips Excel formula risks while handing management a clean spreadsheet ready for legal review.
Raw Escaped AuditData Cell vs. Flattened Key Structure
{
"CreationTime": "2026-12-01T08:18:55Z",
"Operation": "New-InboxRule",
"ClientIP": "185.220.101.45:51422",
"Workload": "Exchange",
"Parameters": [
{ "Name": "Name", "Value": ".." },
{ "Name": "MoveToFolder", "Value": "RSS Feeds" },
{ "Name": "MarkAsRead", "Value": "True" },
{ "Name": "StopProcessingRules", "Value": "True" }
]
}
Notice how Microsoft Purview encodes ClientIP with an appended ephemeral source port (:51422), which prevents straightforward IP pivot matching against Entra Sign-In logs unless stripped cleanly. Inside Parameters, each rule attribute sits inside its own object rather than a flat JSON property—meaning recursive flattening must inspect array elements before building column headers.
Once flattened, those four array items become dedicated columns: AuditData.Parameters.Name, AuditData.Parameters.MoveToFolder, AuditData.Parameters.MarkAsRead, and AuditData.Parameters.StopProcessingRules—while AuditData.ClientIP normalizes to 185.220.101.45 for effortless IOC deduplication.
Forensic Telemetry Fields & High-Signal Indicators
| Telemetry Field / Pattern | Meaning in M365 / Entra | High-Signal Threat Indicator |
|---|---|---|
AuditData.ClientIP / ClientIPAddress | Source IPv4 or IPv6 (often suffixed with :port) | Unfamiliar VPS, Tor exit, or residential proxy ASN |
AuditData.ExtendedProperties.UserAgent | HTTP user-agent captured during Entra token grant | python-requests, axios, curl, Go-http-client, Edge/18 |
AuditData.Parameters.* | Promoted Exchange cmdlet flags and arguments | MoveToFolder=RSS Feeds, MarkAsRead=True, ForwardTo |
AuditData.OperationProperties.* | Exchange telemetry metadata (MailAccessType, IsThrottled) | MailAccessType=Bind or IsThrottled=True spikes |
AuditData.AppAccessContext.ClientAppId | OAuth client application GUID calling Graph/REST | Unexpected Azure CLI or Graph PowerShell GUIDs |
AuditData.ResultStatus | Execution verdict recorded by M365 microservice | Succeeded/True from unapproved foreign geography |
PowerShell Recursive Flattening Script (When Scripting Locally)
$rows = Import-Csv .\PurviewExport.csv
$flattened = foreach ($r in $rows) {
$ad = $r.AuditData | ConvertFrom-Json
$h = [ordered]@{ TimeUtc = $ad.CreationTime; Operation = $ad.Operation; User = $ad.UserId; ClientIP = ($ad.ClientIP -replace ":\d+$","") }
if ($ad.Parameters) { foreach ($p in $ad.Parameters) { $h["Param_" + $p.Name] = $p.Value } }
if ($ad.ExtendedProperties) { foreach ($e in $ad.ExtendedProperties) { $h["Ext_" + $e.Name] = $e.Value } }
[PSCustomObject]$h
}
$flattened | Export-Csv .\Flattened_UAL.csv -NoTypeInformation
Sample Flattened Output Table
TimeUtc Operation User ClientIP Param_Name Param_MoveToFolder Param_MarkAsRead
------- --------- ---- -------- ---------- ------------------ ----------------
2026-12-01T08:18:55Z New-InboxRule finance.director@contoso.invalid 185.220.101.45 .. RSS Feeds True
Comparison: Purview AuditData Flattening Methods
| Method | Speed & Setup | Handles Name/Value Arrays & Privacy |
|---|---|---|
| Excel Power Query | Slow; manual JSON steps break across RecordTypes | Local, but strips timestamps & fails on mixed schemas |
| PowerShell ConvertFrom-Json | Requires local terminal & custom flattening recursion | Local; manual scripting required for Name/Value pairs |
| Generic Online CSV/JSON Converters | Fast, but requires uploading logs to third-party servers | High NDA/GDPR risk; leaves Parameters[0].Name unmerged |
| AuditVane Client-Side Flattener | Instant drag-and-drop in browser Web Worker | 0 bytes uploaded; collapses Parameters/ExtendedProperties cleanly |
Step-by-Step Triage, Containment & Verification
- Export the target mailbox or tenant activity window from Microsoft Purview Audit Search or Search-UnifiedAuditLog using Export-Csv -NoTypeInformation so quotes remain RFC 4180 compliant.
- Open AuditVane and drag one or multiple CSV files directly onto the browser dropzone; verify the green 0 Bytes Uploaded indicator in the header.
- Inspect the KPI strip to confirm total events and total unique flattened AuditData keys discovered across your dataset.
- Click any triggered finding card (such as AV-001 or AV-003) or type a specific operation into the search box to isolate suspect records.
- Click any event row to open the Flattened AuditData Inspector modal showing every nested key/value alongside the raw JSON payload.
- Click Export Flattened CSV to save an Excel-safe spreadsheet where formula injection prefixes (=, +, -, @) are automatically neutralized.
How to Verify Containment Completed Cleanly
- Confirm row count in AuditVane matches the raw CSV line count (verifying no truncated rows or 50,000-row Purview ceiling cutoffs).
- Verify timestamps are sorted chronologically by AuditData.CreationTime (UTC) rather than browser-localized CreationDate strings.
- Confirm exported Flattened CSV opens cleanly in Excel without column misalignment or formula warnings.
Analyst Blind Spots, Licensing Quirks & False Positives
A dangerous and frequently overlooked risk when opening raw or third-party flattened CSV files in Microsoft Excel is CSV Formula Injection (CWE-1236). Attackers routinely craft malicious inbox rule names, email subjects, or search queries starting with =, +, -, or @—if opened unescaped in Excel, spreadsheet formulas can execute unexpectedly.
Additionally, never open a raw Purview CSV in Excel, edit a column, and hit Ctrl+S before running forensic scripts: Excel silently converts ISO-8601 UTC timestamps into regional MM/DD/YYYY strings and drops sub-second precision, breaking correlation against Entra ID logs.
Frequently Asked Questions
Why does AuditData use double-double quotes in Purview CSV exports?
Under RFC 4180 CSV rules, literal double quotes inside a quoted string field must be escaped as "". Naive split-on-comma scripts break immediately on embedded commas and doubled quotes inside JSON.
Is it safe to upload M365 Unified Audit Logs to an online flattener?
Never upload corporate audit logs to server-backed websites because they expose employee UPNs, sensitive SharePoint file names, home IP addresses, and search terms. Use a 100% client-side browser tool like AuditVane or local PowerShell.
How does AuditVane flatten Name/Value arrays like Parameters?
When AuditVane encounters an array whose items all share Name and Value fields—common in Parameters, ExtendedProperties, and OperationProperties—it promotes each entry directly to a named dotted key such as AuditData.Parameters.MoveToFolder.
Can I merge multiple Purview CSV chunks at the same time?
Yes. Select or drag multiple CSV and Entra JSON files simultaneously onto AuditVane and they will be parsed, merged, and sorted chronologically in browser memory.