Sunsetless EWS security and data flow

Sunsetless EWS runs inside your application and signs in as your own app registration in Microsoft Entra ID. Mail, tokens and credentials never reach Sunsetless.

Runs in
Your application’s process, installed from NuGet.org
Signs in as
Your app registration in Microsoft Entra ID
Sends to Sunsetless
Nothing (no telemetry, no license server)

Requests go from your application straight to Microsoft

For a mailbox in Exchange Online, Sunsetless EWS gets a token for your app registration from Microsoft Entra ID and turns each EWS call into Microsoft Graph requests inside your process. The answers come back to your code as EWS responses.

Calls to any other host, such as your own Exchange Server, go out as EWS, unchanged. The SUNSETLESS_BRIDGED_HOSTS setting decides which hosts go to Graph, SUNSETLESS_BRIDGE_ALL_HOSTS=true sends every host there, and SUNSETLESS_DISABLED=1 switches the translation off.

The Graph token goes only over https to graph.microsoft.com. A link the library reads back from a sync state is followed only into the mailbox the call is for; any other link fails as an invalid sync state.

Outbound connections from your process
  • login.microsoftonline.coma token for your app registration
  • graph.microsoft.comevery call translated from EWS
  • outlook.office365.com, outlook.office.comupload and import addresses that Graph hands out
  • mail.contoso.comyour Exchange Server, EWS as before
  • your push notification URLonly if your code uses EWS push subscriptions
  • sunsetless.comnever
Kept in memory
Access tokens, in the memory cache of the Microsoft Authentication Library, separately for each tenant and app registration. They are gone when the process stops.
Written to disk
Nothing. Sync states stay wherever your code stores them now.
Logged
Only license messages, to System.Diagnostics.Trace. EWS tracing works as before: when your code turns it on, the EWS XML, mail content included, goes to your trace listener. Graph requests and the Graph token are never traced.

Microsoft Graph permissions

The app registration needs Microsoft Graph application permissions for what your code does. Grant only those.

Microsoft Graph permissions
PermissionUsed forLimited to chosen mailboxes
Mail.ReadWrite, Mail.Sendmail, folders, conversations, sync and notificationsCan be limited to chosen mailboxes
Calendars.ReadWritecalendars, meetings, availability and delegatesCan be limited to chosen mailboxes
Contacts.ReadWritecontacts and contact folders; Contacts.Read is enough to only readCan be limited to chosen mailboxes
MailboxSettings.ReadWriteout-of-office, inbox rules, categories and working hoursCan be limited to chosen mailboxes
Tasks.ReadWrite.Alltasks, through Microsoft To DoApplies to the whole tenant
User.Read.All, Group.Read.AllResolveNames, ExpandDL, directory search and user photosApplies to the whole tenant
ProfilePhoto.ReadWrite.AllSetUserPhotoApplies to the whole tenant
Place.Read.Allroom listsApplies to the whole tenant
Optional: the rest works without them
MailboxFolder.Read.AllNotes, Journal, folders of every kind in folder listings, calendars created through EWS, and linked contacts in hidden folders for FindPeopleCan be limited to chosen mailboxes
MailboxFolder.ReadWrite.Allrenaming, moving, copying and deleting calendars created through EWSCan be limited to chosen mailboxes
MailboxItem.Read.Allcontact groups, a task's companies and contacts, items in Deleted Items and Recoverable ItemsCan be limited to chosen mailboxes
MailboxItem.ImportExport.Alloperations Graph has no call for, done through mailbox import and exportCan be limited to chosen mailboxes
MailboxItem.ReadWrite.Alldeleting contacts and contact groups in a single call, and purging a contact group from Recoverable ItemsCan be limited to chosen mailboxes
MailboxConfigItem.ReadWriteuser configuration objects of every name and the retention policy tags, through a Microsoft Graph API still in previewCan be limited to chosen mailboxes
Mail-Advanced.ReadWrite.Allchanging the subject, body, recipients or extended properties of received and sent messages, which Microsoft Graph requires from 31 December 2026Can be limited to chosen mailboxes
Domain.Read.AllAutodiscover GetDomainSettingsApplies to the whole tenant

A check mark means Exchange Online can limit the permission to chosen mailboxes. The others apply to the whole tenant or to the directory. Permissions in the getting started guide

Limit the app to the mailboxes it needs

A permission granted in Microsoft Entra ID covers every mailbox in the tenant. RBAC for Applications in Exchange Online grants the same permissions for a set of mailboxes only, chosen by a management scope or an administrative unit.

The two kinds of grant add up. To limit a permission, assign it through RBAC and remove it from the app registration in Microsoft Entra ID, or the tenant-wide grant still applies.

In EWS, opening another mailbox through a folder ID depended on the delegate rights of the impersonated user. In Graph it depends on the app’s permissions; SUNSETLESS_DENY_CROSS_MAILBOX_ACCESS=true refuses it the way EWS does, also for out-of-office settings, inbox rules and user photos.

RBAC for Applications on Microsoft Learn ↗

Exchange Online PowerShell
# IDs from Enterprise applications in Microsoft Entra admin center
New-ServicePrincipal -AppId <app ID> -ObjectId <object ID> `
  -DisplayName "Mail sync"

New-ManagementScope -Name "Mail sync mailboxes" `
  -RecipientRestrictionFilter "CustomAttribute1 -eq 'mailsync'"

New-ManagementRoleAssignment -App <app ID> `
  -Role "Application Mail.ReadWrite" `
  -CustomResourceScope "Mail sync mailboxes"

Test-ServicePrincipalAuthorization -Identity <app ID> `
  -Resource [email protected]

The license key is checked offline

A key is one line of text signed by Sunsetless. The library checks the signature with a public key built into the package, so it never needs to reach us, and we never learn where or how often it runs.

Format
SLK1.<payload>.<signature>: JSON in base64url, signed with ECDSA P-256 and SHA-256. Anyone can read the payload; changing it breaks the signature.
Contents
The license ID and type, the licensee (your company name, or the buyer’s email address when there is none) and the issue date. A test or trial key also has its last day. A permanent Single App or Organization key and a trial key carry your tenant ID.
When it is checked
Once for each configuration in the process, before the first EWS or Autodiscover call the library answers from Graph.
Without a valid key
The library sends nothing to Microsoft Graph. Calls to Exchange Online, Autodiscover included, fail with ErrorInvalidLicense and a message that says what is wrong. Calls to Exchange Server are not affected.
When a key ends
A test or trial key stops working at the next start of your application after its last day. A running application is never stopped.
What it gives access to
Nothing in your tenant and no mailbox. Keep it with the rest of your configuration.
The payload of a permanent Organization key
{
  "v": 1,
  "kid": "2026-1",
  "lid": "SL-7Q4M-2K9D",
  "plan": "organization",
  "to": "Contoso Ltd",
  "iat": "2026-10-28",
  "upd": "9999-12-31",
  "tid": ["4b5e8c1a-0d7f-4e2b-9a61-3c8d2f0e7b45"],
  "app": []
}

kid names the signing key, lid the license, iat the issue date and tid the tenant. upd is the last release date the key accepts; a paid key has 9999-12-31, so every future version accepts it. The library ignores app.

Questions from security reviews

Can Sunsetless see our mail, tokens or credentials?
No. The library sends nothing to us: requests go from your application to Microsoft, and the license key is checked inside your process. For the data in your mailboxes we are neither controller nor processor.
Do we need a data processing agreement with you for the library?
No. The library gives us no access to personal data in your mailboxes. What we process ourselves, for purchases, accounts and support, is described in the Privacy Policy.
Which hosts does our firewall need to allow?
login.microsoftonline.com and graph.microsoft.com, plus outlook.office365.com and outlook.office.com for large attachments and mailbox import. Calls that stay on EWS go to your Exchange Server as before. Nothing goes to sunsetless.com.
Does it work in GCC High, DoD or 21Vianet tenants?
No. The library connects only to the worldwide endpoints of Microsoft Entra ID and Microsoft Graph. If you need one of those clouds, write to us.
Can the library be changed or switched off remotely?
No. It has no remote configuration, no update check and no license server, so nothing outside your process can change what it does or stop it. A new version reaches you only when you update the package.
What does the package bring with it?
Its dependencies are all Microsoft packages: Microsoft.Identity.Client (MSAL) for sign-in, System.Text.Json and, depending on the target framework, a few System.* packages. Next to the translation layer, the package contains the EWS Managed API, built from Microsoft’s MIT-licensed source with a few dozen lines changed.
How do we know the package comes from you?
We publish Sunsetless.Ews and Sunsetless.Ews.NETStandard only on NuGet.org, where Sunsetless is the owner and NuGet.org adds its repository signature to every package. This site has no downloads of its own.
Is the source code available?
The code that translates EWS to Graph is not public. If development stops, the Terms give every license holder the complete source code of the latest release under the MIT License: when we announce it, when no release comes out for 12 months, or when the business stops trading.

Report a vulnerability

Send us a description and, if you can, the steps to reproduce. Please do not post it in a public issue on GitHub. We read English and Polish.

Have us move it to Microsoft Graph

If the application uses the EWS Managed API, we can rewrite its EWS code for Microsoft Graph, or switch it to Sunsetless EWS. Send us its EWS usage report, or tell us what it does, and we check it for free, then quote a fixed price from $1,000.