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.
- 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.
The library signs in as your app registration
Sign-in goes through the Microsoft Authentication Library (MSAL) with the client credentials flow, without a signed-in user. The app registration is yours: your administrators decide what it may do and can revoke it in Microsoft Entra ID at any time.
The tenant ID, the client ID and the credential come from environment variables or from your code. Managed identities and sign-in as a user are not supported.
- Certificate in the Windows certificate store
SUNSETLESS_CERT_THUMBPRINT, looked up in CurrentUser\My, then in LocalMachine\My. Microsoft recommends a certificate for production.- Certificate in a .pfx file
SUNSETLESS_CERT_PATHandSUNSETLESS_CERT_PASSWORD.- Client secret
SUNSETLESS_CLIENT_SECRET. It is quicker to set up for a test.- In code instead
SunsetlessEws.Configure(options)for the whole process, orSunsetlessEws.Configure(service, options)for one ExchangeService when one process works for several tenants.
Microsoft Graph permissions
The app registration needs Microsoft Graph application permissions for what your code does. Grant only those.
| Permission | Used for | Limited to chosen mailboxes |
|---|---|---|
Mail.ReadWrite, Mail.Send | mail, folders, conversations, sync and notifications | Can be limited to chosen mailboxes |
Calendars.ReadWrite | calendars, meetings, availability and delegates | Can be limited to chosen mailboxes |
Contacts.ReadWrite | contacts and contact folders; Contacts.Read is enough to only read | Can be limited to chosen mailboxes |
MailboxSettings.ReadWrite | out-of-office, inbox rules, categories and working hours | Can be limited to chosen mailboxes |
Tasks.ReadWrite.All | tasks, through Microsoft To Do | Applies to the whole tenant |
User.Read.All, Group.Read.All | ResolveNames, ExpandDL, directory search and user photos | Applies to the whole tenant |
ProfilePhoto.ReadWrite.All | SetUserPhoto | Applies to the whole tenant |
Place.Read.All | room lists | Applies to the whole tenant |
| Optional: the rest works without them | ||
MailboxFolder.Read.All | Notes, Journal, folders of every kind in folder listings, calendars created through EWS, and linked contacts in hidden folders for FindPeople | Can be limited to chosen mailboxes |
MailboxFolder.ReadWrite.All | renaming, moving, copying and deleting calendars created through EWS | Can be limited to chosen mailboxes |
MailboxItem.Read.All | contact groups, a task's companies and contacts, items in Deleted Items and Recoverable Items | Can be limited to chosen mailboxes |
MailboxItem.ImportExport.All | operations Graph has no call for, done through mailbox import and export | Can be limited to chosen mailboxes |
MailboxItem.ReadWrite.All | deleting contacts and contact groups in a single call, and purging a contact group from Recoverable Items | Can be limited to chosen mailboxes |
MailboxConfigItem.ReadWrite | user configuration objects of every name and the retention policy tags, through a Microsoft Graph API still in preview | Can be limited to chosen mailboxes |
Mail-Advanced.ReadWrite.All | changing the subject, body, recipients or extended properties of received and sent messages, which Microsoft Graph requires from 31 December 2026 | Can be limited to chosen mailboxes |
Domain.Read.All | Autodiscover GetDomainSettings | Applies to the whole tenant |
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.
# 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
ErrorInvalidLicenseand 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.
{
"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.