All right class.

You've got a mailbox called accounts@. One called info@. One called hr@. Three or four people open each of them from Outlook, and nobody has thought about the object behind them since the day it was created.

Every one of those is an account in Entra ID. An object, a user principal name, a password. You've been treating them as furniture.

Whether anybody can sign in to one directly is a setting. In a lot of tenants that setting is wrong, and the question is how many of yours.

What a shared mailbox actually is

Two things stapled together. In Exchange Online it's a recipient with RecipientTypeDetails set to SharedMailbox, which is what gives you the shared inbox, the shared sent items and the free 50GB. In Entra ID it's a user object with a UPN, a password hash and everything else a user object carries.

The Exchange half is the part everybody designs. The Entra half is the part nobody looks at, because the mailbox has no owner, no manager and no joiner-mover-leaver process attached to it. It's a user account that was never anybody's user account.

Delegation is the design, sign-in is the hole

The intended way to reach a shared mailbox is delegation. Sarah opens accounts@ using Sarah's credentials, so Sarah's Conditional Access applies, Sarah's MFA applies, and the audit log records Sarah. The shared mailbox never authenticates. That's the whole point of it.

Direct sign-in throws all of that away. Somebody authenticates as accounts@ using the mailbox password, and now Conditional Access is evaluating an account nobody manages, MFA is almost certainly not registered, and every action in the audit log is attributed to a mailbox rather than a person.

There's a second-order problem that's worse, and it's why I'd treat this as urgent rather than tidy. If your tenant doesn't restrict security information registration, the first person to sign in with the correct password gets prompted to register MFA. Not the owner. The first person. If that's somebody who bought the password from a broker, they register their own authenticator against your shared mailbox, and from that moment the account shows as MFA protected in every dashboard you own (you will be surprised that this is not an uncommon scenario to happen)

I do wonder what your MFA registration percentage is measuring, given that nobody has ever been told to register accounts@

After that the persistence is trivial. Grant mailbox folder permissions on the root inbox to another account they control, and access survives the password reset you'll eventually do on the shared mailbox. The password was never the thing holding the door open.

The default is not what anybody tells you

The documentation is admirably even-handed on this. It will tell you that shared mailboxes have sign-in blocked by default, and elsewhere that they don't, and both are true, because the default changed. Modern tenants block sign-in on the underlying object at creation. Older ones didn't.

None of that matters for the mailbox that causes your incident, because that one was converted. Somebody left, IT converted their user mailbox to a shared mailbox so the team could keep the history, and the conversion doesn't disable the account. It keeps the enabled account, the existing password, and any MFA the leaver had registered. You offboarded them in March and left their credentials pointing at a live mailbox.

So don't assume the default. Measure it.

Finding them without PowerShell

There's no IsSharedMailbox column anywhere in Sentinel. SigninLogs doesn't know, IdentityInfo doesn't carry it, and the authoritative answer lives in Exchange behind Get-EXOMailbox.

You can identify them from behaviour instead, and the signature is clean. In OfficeActivity, MailboxOwnerUPN is the mailbox and UserId is the person acting on it. When those two differ, somebody is working in a mailbox that isn't theirs. When they differ for several distinct people, that mailbox is shared. Mailbox audit records also carry Logon_Type, which is Owner, Admin or Delegate, so you can drop admin impersonation before it inflates your delegate count.

// Mailboxes that behave like shared mailboxes, and whether anyone can sign in to them
let Lookback = 14d;                  // sweep window
let MinDelegates = 2;                // distinct delegates before a mailbox counts as shared
// A shared mailbox is one that several people open with their own credentials
let SharedCandidates = materialize(
    OfficeActivity
    | where TimeGenerated > ago(Lookback)
    | where OfficeWorkload == "Exchange"
    | where isnotempty(MailboxOwnerUPN) and isnotempty(UserId)
    | where Logon_Type != "Admin"        // admin impersonation is not delegation
    | extend Mailbox = tolower(MailboxOwnerUPN), Actor = tolower(UserId)
    | where Actor != Mailbox
    | where Actor contains "@"           // real UPNs only, and "has" cannot match punctuation
    | where Actor !startswith "app@"     // drops the app@sharepoint service context
    | summarize Delegates = dcount(Actor), DelegateList = make_set(Actor, 20), DelegateOps = count()
      by Mailbox
    | where Delegates >= MinDelegates);
let CandidateMailboxes = toscalar(SharedCandidates | summarize make_set(Mailbox, 10000));
// Anyone authenticating as the mailbox itself, interactive or not
let DirectSignIns =
    union isfuzzy=true
      (SigninLogs
        | where TimeGenerated > ago(Lookback)
        | where UserPrincipalName in~ (CandidateMailboxes)
        | project UserPrincipalName, ResultType, TimeGenerated, IPAddress, AppDisplayName,
                  ClientAppUsed, AuthenticationRequirement),
      (AADNonInteractiveUserSignInLogs
        | where TimeGenerated > ago(Lookback)
        | where UserPrincipalName in~ (CandidateMailboxes)
        | project UserPrincipalName, ResultType, TimeGenerated, IPAddress, AppDisplayName,
                  ClientAppUsed, AuthenticationRequirement)
    | extend Mailbox = tolower(UserPrincipalName)
    | summarize Attempts = count(),
                Successes = countif(ResultType == "0"),
                SingleFactor = countif(ResultType == "0" and AuthenticationRequirement == "singleFactorAuthentication"),
                LastSuccess = maxif(TimeGenerated, ResultType == "0"),
                SourceIPs = dcount(IPAddress),
                Apps = make_set(AppDisplayName, 10),
                Clients = make_set(ClientAppUsed, 10)
      by Mailbox;
SharedCandidates
| lookup kind=leftouter DirectSignIns on Mailbox
| extend Verdict = case(
      Successes > 0, "Sign-in works and is being used",
      Attempts > 0, "Sign-in attempted, all failed so far",
      "No direct sign-in seen in the window")
| extend Priority = case(Successes > 0, 1, Attempts > 0, 2, 3)
| project Priority, Verdict, Mailbox, Delegates, Successes, SingleFactor, Attempts,
          LastSuccess, SourceIPs, Apps, Clients, DelegateList, DelegateOps
| sort by Priority asc, Successes desc, Delegates desc

Priority one is the finding. A mailbox that several people access by delegation, and that also accepts direct authentication, is doing both things at once and only one of them was designed.

Priority two matters too. Failed sign-ins against a shared mailbox mean somebody is trying, and shared mailbox names are guessable by design, which is why they're on every password spraying list ever assembled.

The sign-ins worth opening

The inventory tells you which mailboxes are exposed. This gives you the events to triage, with a weighted score so the worst ones sort to the top instead of you reading a string column in alphabetical order.

// Successful authentications as a shared mailbox, scored and sorted worst first
let Lookback = 14d;
let MinDelegates = 2;
let W_NoMfa = 40;          // password alone was enough
let W_LegacyClient = 30;   // protocol that cannot do modern auth
let W_HighRisk = 30;       // Identity Protection said high
let W_MediumRisk = 15;     // Identity Protection said medium
let Shared = materialize(
    OfficeActivity
    | where TimeGenerated > ago(Lookback)
    | where OfficeWorkload == "Exchange"
    | where isnotempty(MailboxOwnerUPN) and isnotempty(UserId)
    | where Logon_Type != "Admin"
    | extend Mailbox = tolower(MailboxOwnerUPN), Actor = tolower(UserId)
    | where Actor != Mailbox
    | where Actor contains "@"
    | where Actor !startswith "app@"
    | summarize Delegates = dcount(Actor) by Mailbox
    | where Delegates >= MinDelegates);
SigninLogs
| where TimeGenerated > ago(Lookback)
| where ResultType == "0"
| extend Mailbox = tolower(UserPrincipalName)
| lookup kind=inner Shared on Mailbox
| extend Country = tostring(LocationDetails.countryOrRegion),
         City = tostring(LocationDetails.city)
| extend MfaSatisfied = AuthenticationRequirement == "multiFactorAuthentication"
| extend LegacyClient = ClientAppUsed in~ ("IMAP4", "POP3", "SMTP", "Other clients", "Exchange ActiveSync")
| extend Ind_NoMfa  = iff(not(MfaSatisfied), "Password only, no second factor", "")
| extend Ind_Legacy = iff(LegacyClient, strcat("Legacy or non-browser client: ", ClientAppUsed), "")
| extend Ind_Risk   = iff(RiskLevelDuringSignIn in~ ("medium", "high"),
                          strcat("Identity Protection risk: ", RiskLevelDuringSignIn), "")
| extend RiskScore = iff(not(MfaSatisfied), W_NoMfa, 0)
                   + iff(LegacyClient, W_LegacyClient, 0)
                   + case(RiskLevelDuringSignIn =~ "high", W_HighRisk,
                          RiskLevelDuringSignIn =~ "medium", W_MediumRisk, 0)
| extend RiskIndicators = strcat_array(
      set_difference(pack_array(Ind_NoMfa, Ind_Legacy, Ind_Risk), dynamic([""])), " | ")
| project TimeGenerated, Mailbox, Delegates, RiskScore, RiskIndicators, IPAddress, Country, City,
          AppDisplayName, ClientAppUsed, AuthenticationRequirement, UserAgent, CorrelationId
| sort by RiskScore desc, TimeGenerated desc

The legacy client weight earns its place. Shared mailboxes are where old protocols go to survive, because there's a scanner on the second floor with IMAP credentials for info@ taped inside the lid, and everybody has quietly agreed not to look at it. POP or IMAP against a shared mailbox is both a finding and an explanation.

The Identity Protection weight needs Entra ID P2. Without it RiskLevelDuringSignIn returns hidden rather than a real value, which scores zero and never fires the indicator. It doesn't produce a false reading, it just tells you nothing, and it's better to know which of those two you're looking at.

What happens after

If a sign-in looks wrong, this is where you check whether it turned into persistence.

// Permission grants, forwarding and rules applied to mailboxes
let Lookback = 14d;
let PersistOps = dynamic(["Add-MailboxPermission", "Add-MailboxFolderPermission", "Add-RecipientPermission",
                          "Set-Mailbox", "New-InboxRule", "Set-InboxRule", "UpdateInboxRules"]);
OfficeActivity
| where TimeGenerated > ago(Lookback)
| where OfficeWorkload == "Exchange"
| where Operation in~ (PersistOps)
| where isnotempty(Parameters)
// Parameters is a name and value array, so pull the fields by name rather than indexing blindly
| mv-apply Param = todynamic(Parameters) on (
      where tostring(Param.Name) in~ ("Identity", "User", "AccessRights", "ForwardingSmtpAddress",
                                      "ForwardingAddress", "DeliverToMailboxAndForward")
      | summarize Details = make_bag(bag_pack(tostring(Param.Name), tostring(Param.Value)))
  )
| extend TargetMailbox = tolower(tostring(Details.Identity)),
         GrantedTo = tolower(tostring(Details.User)),
         AccessRights = tostring(Details.AccessRights),
         ForwardTo = tolower(coalesce(tostring(Details.ForwardingSmtpAddress),
                                      tostring(Details.ForwardingAddress)))
| extend ForwardingTouched = isnotempty(ForwardTo) or isnotempty(tostring(Details.DeliverToMailboxAndForward))
// Set-Mailbox fires on any property change, so keep only the rows that moved access or mail
| where ForwardingTouched or isnotempty(GrantedTo) or Operation contains "InboxRule"
| extend Change = case(
      isnotempty(ForwardTo), strcat("Forwarding set to ", ForwardTo),
      isnotempty(GrantedTo), strcat(GrantedTo, " granted ", AccessRights),
      Operation contains "InboxRule", "Inbox rule created or changed",
      Operation)
| project TimeGenerated, Operation, Change, TargetMailbox, GrantedTo, AccessRights, ForwardTo,
          ChangedBy = tolower(UserId), ClientIP, ResultStatus, Parameters
| sort by TimeGenerated desc

Cross-reference the mailbox names against query one. A permission grant on a shared mailbox is routine administration. The same grant an hour after somebody authenticated to that mailbox from an address you don't recognise is not.

The honest limitations

The behavioural test finds mailboxes that are being used. A shared mailbox nobody has opened in the last fortnight produces no delegate activity and stays invisible, which is unfortunate, because a forgotten shared mailbox is exactly the one with a stale password. Widen the lookback in Logs, and accept that the authoritative list only comes from Get-EXOMailbox -RecipientTypeDetails SharedMailbox.

Mailbox auditing has to be on and the events have to be reaching your workspace. MailItemsAccessed stopped being an E5 exclusive in 2024 and now generates for Purview Audit Standard, but only where the mailbox is licensed and the audit set hasn't been customised. Shared mailboxes under 50GB are usually unlicensed, so they're the population most likely to be silent. Run Get-Mailbox <name> | Format-List DefaultAuditSet, AuditEnabled on a couple of them before you trust an empty result.

The test also can't tell a shared mailbox from a normal mailbox that several people have permissions on, such as an executive's mailbox opened by two assistants. That's a small false positive class and the fix is to read the names.

Finally, none of this covers resource mailboxes for rooms and equipment. They have the same problem for the same reason and they generate no delegate activity at all, so they need the PowerShell answer.

What you should do next

  1. Run query one and clear priority one today. Five minutes to run, about an hour to work through the results. A shared mailbox accepting direct sign-ins is an unmanaged account with a password somebody knows. Blocking sign-in on the underlying object breaks nothing for the delegates, because delegation never used that account in the first place.
  2. Check MFA registration before you block. Entra admin centre, Protection, Authentication methods, User registration details. Twenty minutes for a mid-sized tenant. If a shared mailbox has an authenticator registered, ask who registered it and when. There's no good answer to that question for a mailbox nobody is supposed to sign in to, and it's the clearest evidence you'll get that somebody was there first.
  3. Restrict who can register security information. Conditional Access, new policy, target resources, user actions, Register security information. Half a day including a report-only run. The registration hijack only works because the account is unclaimed until the first person claims it, and this closes it permanently for far more than shared mailboxes.
  4. Fix the conversion process. An hour, and most of that is writing it down. Every user mailbox converted to shared gets sign-in blocked and the password reset as part of the same change.

Class dismissed.