Interpreting the Office 365 MailItemsAccessed Audit Event

Crucial Office 365 Forensics Events

The MailItemsAccessed event is the first crucial (sometimes called high-value) audit event introduced as part of Microsoft 365 Advanced Audit (or auditing). Its introduction was neither smooth nor uncomplicated and contributed to some of the issues around Exchange Online mailbox auditing experienced over the last year. MailItemsAccessed audit events are now showing in tenants, and I wanted to find out how useful these events are when investigating compromised accounts.

E5 Licenses Needed

The MailItemsAccessed event is generated when licensed users access items in Exchange Online mailboxes using any connectivity protocol from any client, but only if your account has an Office 365 E5 or Microsoft 365 E5 Compliance add-on. In my case, I have an Office 365 E5 license, and Advanced Auditing shows up as one of the apps in the plan (Figure 1). After capture, events are uploaded by Exchange Online to the Office 365 audit log along with other mailbox audit events.

Image 1 Expand
Figure 1: Microsoft 365 Advanced Auditing is part of Office 365 E5 (image credit: Tony Redmond)

Two Kinds of MailItemsAccessed Event

MailItemsAccessed events come in two kinds: Sync (synchronization) and Bind (access to a message).

Sync events are captured when an Outlook desktop client synchronizes messages from the mailbox to its local cache (the OST for Windows or OLM for Mac). During synchronization, the client downloads copies of all new or changed items from the mailbox and notes any deletions to apply in its local copy. The sync event records that synchronization occurred for a folder. In the normal course of events, you’d expect to see many events recording synchronization for folders like Inbox, Sent Items, Deleted Items, and the Calendar, plus any other folder where messages are moved to. In terms of investigation, the assumption is that if a breach occurs and someone can use Outlook to synchronize a folder to a local cache, potentially all items in that folder are copied.

Bind events record access to an individual message. To reduce the number of audit records, Exchange Online generates a single bind event covering access to messages within a two-minute period. Thus, a bind event might cover access to a single message or ten messages.

To give an idea of the volume of events a user might produce, over a two-day period my account generated 443 MailItemsAccessed events. The majority were Bind events (394), and of these 312 were in the Inbox and 32 in Sent Items.

Interestingly, 25 events were captured for the Outbox, which is a transient folder where items exist while awaiting processing by the Exchange transport service. It’s also used when Outlook posts to a conversation in an Outlook group, which is why the events for the Outbox folder appeared in audit records.

The Potential for Throttling

I don’t use email as heavily as I once did when I was a corporate VP, so expect heavier volumes for other mailboxes. The transfer of some communications to Teams has also reduced email volume in some tenants. However, I do use multiple clients (OWA, Outlook, and Outlook mobile), all of which are usually signed in and active, which increases the number of Bind events. In the case of very active mailboxes, if more than a thousand events are generated for a mailbox in less than 24 hours, Exchange Online stops generating MailItemsAccessed events for that mailbox for 24 hours. Microsoft says that less than 1% of Exchange Online mailboxes are throttled.

Searching for Events

Now we know about what events to expect, how do we access events during an investigation? Using the audit log search in the Microsoft 365 compliance center is not feasible because it’s impossible to correlate events there. Instead, we need to extract relevant events from the audit log and process them into a form that facilitates further analysis.

To do this, I use a PowerShell script to:

  • Use the Search-UnifiedAuditLog cmdlet to find MailItemsAccessed events. The search can be tailored for different date ranges and users.
  • Process each record to extract information from the JSON-formatted AuditData property.
  • Do further processing to make the AuditData information clearer. For example, write out the logon type as text (User, Delegate, or Admin) instead of a numeric code.
  • If possible, perform a message trace to retrieve the subject for messages (see below).
  • Generate a CSV file containing the processed records.

The script transforms an audit record which looks like this:


To an item looking like this:


The parsed and cleaned-up audit record is much easier to work with.

No Email Subjects

MailItemsAccessed events don’t tell you anything about message subjects. All references to messages in audit events are by their internet message identifier, a unique value generated by the sending mail server. For example:

[email protected]

Microsoft might not include message subjects in the MailItemsAccessed events because they could reveal personal information to an investigator. This is understandable, but the position is undermined by the fact that SharePoint Online is quite happy to reveal document titles in its audit records and message subjects are revealed to investigators in Office 365 content searches.

Given that the audit events only contain internet message identifiers, investigators face the problem of how to connect audit events to real messages. This is important because if an attacker has penetrated a mailbox, you need to understand if any important, confidential, or sensitive information exists in the messages that they accessed.

Message Tracing Helps

The easiest way to match a message identifier with a message is to use a message trace. However, the interactive message trace (available in the Microsoft 365 compliance center) or the Get-MessageTrace cmdlet only supports tracing messages less than ten days old. For this reason, when it processes audit events, the script only calls the Get-MessageTrace cmdlet to retrieve subjects for messages less than 10 days old. The call isn’t made for older messages and some explanatory text is inserted for the subject instead. The output for a set of messages found in a MailItemsAccessed Bind event looks something like this. The presence of the subject makes it much easier to understand if any important messages were compromised.

(1) [email protected]od.outlook.com (Re: Counting Distribution list members);
(2) [email protected] (TechSmith Influencer News – Camtasia 2020 sneak peek, help for organizations transitioning to remote work and learning, and more!);
(3) [email protected]com (Coronavirus: Ireland’s infection peak may have passed, toll could hit 400 by August, report forecasts);
(4) [email protected]od.outlook.com (Presentation on ‘Inclusive Meetings’ today)

Tracing Older Messages

For older messages, it’s possible to run an historic search to retrieve details of messages between 11 and 90 days old, but you can’t do this interactively as the cmdlet sets up a background search. Exchange Online doesn’t hold message tracing data for longer than 90 days, which creates a problem if an attacker accesses older email. On the upside, older email might not be quite as sensitive as newer messages.

You can link message identifiers found in audit events to old email, but it’s a tedious business if the data isn’t in some searchable repository. The manual approach is to use Outlook or OWA to examine messages in the user’s mailbox around the date of the audit event. For each message, use the Message Header Analysis add-in to report message headers, among which is the internet message identifier (Figure 2).

Image 2 Expand
Figure 2: Using the Message Header Analysis add-in to check an email’s internet message identifier (image credit: Tony Redmond)

Interpreting the Audit Events

My script (which you can download from GitHub) outputs results to a PowerShell list, which makes it easy to generate statistics like the number of bind events per folder. The list is also piped to PowerShell’s Out-GridView window for initial analysis (Figure 3) and to a CSV file for consideration over the longer term.

Image 3 Expand

Figure 3: Browsing MailItemsAccessed audit records with Out-GridView (image credit: Tony Redmond)

 
Out-GridView is a great way to get an initial handle on what might have happened because you can quickly sort events by SessionId or Client IP Address. Microsoft’s documentation explains how to use these fields to link events together to highlight actions that might have been performed by an attacker.

Helpful Insight into What Happens in a Mailbox

MailItemsAccessed audit events provide a helpful insight into what goes on when users access mailbox items. I’d like to see the information published in the events be more accessible and complete (message subject is an important piece of data), but what we have now is better than what we had before.

Generating and storing audit events costs money, especially when the events are prolific. I understand why Microsoft regards MailItemsAccessed as a crucial event and look forward to seeing what other events matching the criteria they deliver in the future. It’s just a pity that these audit events are an E5 feature. E3 tenants are attacked too!

Related Topics:

  • Microsoft 365
  • Office
  • Office 365
  • BECOME A PETRI MEMBER:

    Don't have a login but want to join the conversation? Sign up for a Petri Account

    Register
    Tony Redmond has written thousands of articles about Microsoft technology since 1996. He covers Office 365 and associated technologies for Petri.com and is also the lead author for the Office 365 for IT Pros eBook.