Security Architecture & Considerations
This document outlines the security architecture, design decisions, and compensating controls implemented in Teams for Linux, particularly around the DOM access requirements and security trade-offs. The reasoning behind the renderer-side controls is recorded in ADR-035.
Security Context
The DOM Access Requirement
Teams for Linux requires DOM access to Microsoft Teams' React components to provide core functionality:
- User Status Tracking: Monitor and sync user presence state
- Custom Background Integration: Inject custom background options into Teams interface
- System Idle Management: Sync system idle state with Teams presence
- Authentication Flow Enhancement: Improve login experience and reduce re-authentication
Security vs. Functionality Trade-off
The application faces a fundamental security vs. functionality trade-off:
Option A: Maximum Security
- Enable Electron
contextIsolationandsandbox - ❌ Breaks all DOM access functionality
- ❌ Eliminates core application features
Option B: Balanced Security (Current Approach)
- Disable
contextIsolationandsandboxfor main window - ✅ Restore all DOM access functionality
- ✅ Implement comprehensive compensating controls
- ✅ Recommend system-level sandboxing
Current Security Implementation
Electron Security Configuration
// app/mainAppWindow/browserWindowManager.js
webPreferences: {
contextIsolation: false, // Required for ReactHandler DOM access
nodeIntegration: false, // Secure: preload scripts don't need this
sandbox: false, // Required for system API access
}
Key Security Decision: nodeIntegration remains false, so page script has no require. The preload itself is not sandboxed and shares the page's JavaScript world, which is why the controls below exist; they compensate for a missing boundary rather than restore it (ADR-035). Profile views use the same settings.
Compensating Security Controls
1. Content Security Policy
The application sets no Content Security Policy of its own for the Teams window. An earlier custom policy was never active and was removed. The page is governed by the policy Microsoft serves with Teams, and the application changes response headers in two cases only (app/mainAppWindow/index.js, app/customBackground/index.js):
- Report-only CSP headers are stripped from pages on non-Teams hosts, such as federated sign-in pages
- When custom backgrounds are configured, the configured service origin is added to
img-srcandconnect-src
Treat Teams' own CSP as outside the application's control: it limits what injected script can load, but it is not a control this project maintains.
2. IPC Channel Validation
Implementation: app/security/ipcValidator.js
Features:
- Channel Allowlisting: Only legitimate IPC channels are permitted
- Payload Sanitization: Removes the
__proto__,constructorandprototypeproperties from the first argument of each message, recursing up to 10 levels deep; anything nested deeper, and any further arguments, are passed through as sent, so handlers still validate what they use - Request Validation: Every
ipcMain.handle,onandonceregistration is wrapped, so the allowlist and sender checks run before the handler - Sender Pinning: The channels in
appPageOnlyChannels(the screen-share picker, the profile channels and the Graph channels) are answered only when the sending frame shows a file inside the app directory (isSenderAllowed), so page script cannot capture the screen, pick a source, switch profiles or call the Graph API on its own. Channels outside that list answer any frame - No Raw
ipcRendererin the Page: WithcontextIsolation: false, anythingelectronAPIreturns is usable by page script, so its listener helpers return nothing and strip Electron's IPC event (whosesenderis the rawipcRenderer) before calling back - Listener Errors Contained: an exception or rejected promise from an
ipcMain.onoroncelistener is logged and dropped by the wrapper inapp/security/ipcSecurity.js, so a message with an unexpected shape cannot reach the process-wide error handlers that exit the app
function validateIpcChannel(channel, payload = null) {
if (!allowedChannels.has(channel)) {
console.warn(`[IPC Security] Blocked unauthorized channel: ${channel}`);
return false;
}
sanitizePayload(payload); // Recursive sanitization
return true;
}
3. Domain Validation
Implementation: _isAllowedTeamsDomain in app/browser/tools/reactHandler.js, and isTeamsHost in app/helpers/teamsHosts.js
The React handler acts only when the page's host is teams.cloud.microsoft, teams.microsoft.com or teams.live.com, an immediate subdomain of one of them, or its .mcas.ms (Defender for Cloud Apps) proxy name.
Protection: Keeps the handler from reading React internals on a page that is not Teams. The check runs inside the page's own JavaScript world, so it guards against acting on the wrong page, not against script already running in the Teams page.
4. Screen Sharing Isolation
Security Model: The screen-sharing picker and preview windows set only a preload, so they keep Electron's defaults: context isolation on, sandbox on, no Node.js integration. They have no DOM access requirement.
5. Process Error Handlers
Implementation: app/index.js (top-level)
Features:
uncaughtExceptionhandler: Logs error details and exits with code 1 (process state unknown after uncaught exception)unhandledRejectionhandler: Logs rejection details; network errors are ignored, anything else exits with code 1, so every promise-returning Electron call (for exampleshell.openExternal) must be caught- Startup try/catch:
handleAppReady()wrapped with error logging and gracefulapp.quit()on failure
Protection: Prevents silent process termination and provides diagnostic output for crash reports.
6. Input Sanitization for External Commands
Implementation: app/mainAppWindow/browserWindowManager.js
Features:
sanitizeCommandArg(): Validates string type, limits length to 500 characters, strips control characters- Applied to all incoming call notification arguments (
caller,text,image) before passing tospawn()
Protection: Defense-in-depth against edge cases in user-configured notification commands receiving untrusted data from Teams messages.
7. Webview Attach Blocked
Implementation: app/security/webviewGuard.js, webviewTag: false in app/mainAppWindow/browserWindowManager.js and profileViewManager.js
Features:
webviewTag: false: Nothing in the app or in Teams web uses<webview>, so the tag is off in the root window and every profile view- App-wide
will-attach-webviewrefusal: Covers any webContents created later, including popups, since a guest can request its own preload withsandbox=noand that preload would run with full Node.js - Sticker import signature check:
customStickersURL import saves a file only when it starts with the declared image type's signature, rather than trusting the server's content-type header alone (a format sanity check; the webview block is the actual protection)
Protection: Keeps page script from turning a file on disk into code running with Node.js, which preserves the nodeIntegration: false boundary above.
8. Preload Trust Boundary
Implementation: app/browser/preload.js, the browser tools under app/browser/tools/, app/config/rendererConfig.js; enforced by tests/unit/preloadIpcLeak.test.js and tests/unit/preloadModules.test.js
Features:
- Init once, on the browser's event: the
DOMContentLoadedhandler ignores synthetic events (event.isTrusted) and re-dispatches (module-level flag), so page script cannot make the preload hand outipcRenderera second time through patched built-ins - Indexed module loop: the module list is walked by index over own properties, with every entry setting its own
ipcflag, becausefor...of,Set.hasandObject.prototypelookups are all patchable from the page ipcRendererin private fields under strict mode: tools flaggedipc: truestill receive the fullipcRendererat init and keep it in#privatefields; strict mode stopsEventEmitter'sthis(the rawipcRenderer) from reaching sloppy-mode frames via V8'sCallSite.getThis- No generic
electronAPI.send: the page gets named methods bound to fixed channels; the profile channels and all seven Graph channels are pinned to the app page, and profile URLs must behttps - Credential-free renderer config:
get-configreturnstoRendererConfig(config), without MQTT, basic-auth or client-certificate secrets
Protection: These rules are what keep script in the Teams window from recovering ipcRenderer, so it stays bounded to the named electronAPI methods with the preload's argument shaping, and it cannot read credentials (GHSA-58j7-22f8-6xqp). The world is still shared, so a preload change that breaks one of the rules can reopen a path; the two tests above exist to catch that.
9. Session Permission Handlers
Implementation: app/security/permissions.js, installed on the default session and every profile partition
Features:
- Trusted requesters get full access to device permissions: Teams and government Teams hosts, the Microsoft sign-in hosts, the configured URL,
httpsprofile URLs and the app's ownfile:pages - External links are limited by scheme: a trusted requester, and a link opened in a new window, may hand only
https,http,mailto,tel,sip,msteamsandweb+msteamsURLs to the operating system (app/helpers/externalUrl.js); other schemes are refused and logged by scheme only - Embedded frames keep only policy-gated permissions: a cross-origin frame inside a trusted page (Whiteboard, Loop, SharePoint) may use media, display capture, clipboard and fullscreen, which Chromium already gates per frame with Permissions Policy, and nothing else
- Other pages may only open mail and phone links: any other permission from a popup, an in-app link or a page navigated to is denied
- Denials logged once per permission and origin, without the URL path
Protection: Without these handlers Electron grants every request, so a page opened in an app window could use the microphone or camera without a prompt (GHSA-58j7-22f8-6xqp, item 3).
Recommended User-Level Security
System-Level Sandboxing
The Teams window cannot use Electron's own isolation, so operating-system confinement is the layer that limits what a compromised renderer can reach. How much there is depends on the package:
| Package | Confinement | What it still grants |
|---|---|---|
| Flatpak (Flathub) | Flatpak sandbox | The home directory (--filesystem=home), all devices (--device=all) and the network, which file sharing, calls and screen sharing rely on. Flatseal or flatpak override can narrow this |
| Snap | Strict confinement | The home directory, removable media, camera, audio recording and the network, through the declared interfaces |
| deb, rpm, AppImage, tarball | None | Everything the user account can reach |
| macOS and Windows builds | None from this project | Everything the user account can reach |
For the unconfined packages, firejail, bubblewrap or an AppArmor or SELinux profile can add confinement. The project ships and tests none of these, so treat them as your own configuration.
Local Control Surfaces
Some opt-in features let other software on the machine, or on the network, drive the application. They are off by default and worth understanding before enabling:
- D-Bus control (
dbusControl.enabled, Linux): the service lives on the session bus with no per-caller access control, so any process in the user's session can call its methods (answer or decline a call, mute, leave, set presence) and read its signals (presence, call state, and the caller's identity when that is opted in). See ADR-033 - MQTT (
mqtt.enabled): anyone who can publish to the command topic can toggle the microphone, camera and raised hand, leave a call and, when the Graph API integration is enabled, request calendar data, which is then published to the broker. Amqtt://broker URL is cleartext, so usemqtts://for anything beyond localhost - Configured commands:
auth.basic.passwordCommand,auth.webLogin.passwordCommand,incomingCallCommandanddefaultURLHandlerrun with the user's permissions
Configuration Is Trusted
Configuration decides which commands run and which servers are trusted, so anyone who can change it can act as the user. It is read from the user's config.json, the system-wide /etc/teams-for-linux/config.json (defaults that the user file overrides), environment variables named after options, command-line flags, and electronCLIFlags, which passes arbitrary switches to Chromium. None of these is a policy-enforcement mechanism: a system-wide file sets defaults, it cannot lock a setting.
Token Storage
Teams keeps its authentication tokens in the page's own storage (localStorage and IndexedDB) and in cookies, all inside the application's profile directory. The token cache bridge (app/browser/tools/tokenCache.js, Token Cache Architecture) gives Teams the storage interface it expects and passes values through to localStorage; it adds no encryption of its own.
Two layers of encryption do apply, neither of them the bridge's. Teams' sign-in library (MSAL) encrypts some of its token entries in localStorage with a key held in the msal.cache.encryption cookie, which the application keeps across restarts (app/mainAppWindow/msalCookiePersistence.js). Packaged builds also enable Electron's cookie encryption, which protects the cookie store with a key from the operating system's keyring where one is available.
The entries and the means to decrypt them all belong to the same user account, so this guards against casual reading of the files, not against a process running as the user. Disk encryption and the security of the user account are what protect the tokens at rest.
The opt-in Graph API integration reuses the Teams session token rather than a separate app registration (ADR-030), and its requests are made from the main process.
Risk Assessment
Residual Risk
The application's exposure is concentrated in one place: script running in the Teams window, through a script-injection flaw in Teams web or a page loaded in that window. Context isolation is off there, so what stands between such script and the rest of the system is the set of compensating controls above, not a process boundary. Three security advisories in October and November 2026 (GHSA-3vg9-cwq9-p773, GHSA-6xpg-fhf9-chcr, GHSA-58j7-22f8-6xqp) were all in this area, and each led to one of those controls.
What the controls bound today:
- Page script reaches only the named
electronAPImethods and the IPC channels behind them, with privileged channels answered only for the app's own pages - It cannot load a
<webview>, read credentials from the configuration, or obtain device permissions for a page outside the trusted set - Links it hands to the operating system are limited to web, mail, phone, SIP and Teams schemes
What remains open:
- A top-level navigation away from Teams keeps the preload attached to the new page. ADR-035 records this as the outstanding item
- The controls depend on rules that every browser tool must keep following, so a regression is possible; the unit tests named above guard the known cases
- Everything depends on Teams web staying free of script injection, which this project does not control
On the local side, any process running as the user can read the profile directory, and the opt-in control surfaces above accept commands from other local software. Operating-system confinement varies by package, as the table above shows.
Taken together this is a moderate residual risk, accepted because the alternative (enabling context isolation) removes the features the application exists to provide.
Continued Security Best Practices
For Users:
- Use official package repositories (Flatpak, Snap, distribution packages) when available
- Keep the application updated through your package manager
- Enable the D-Bus, MQTT and command options only when you use them
For Developers:
- Continue monitoring Teams web app changes that could affect security
- Maintain IPC channel validation and domain restrictions
- Follow the renderer rules in ADR-035 for every new browser tool: strict mode,
ipcRendererin a private field, no Electron objects returned to the page, sender checks on new privileged channels - Validate arguments in the main process, not only in the preload
- Keep dependencies updated and monitor security advisories
Security Contact & Reporting
Security Issues: Report privately through GitHub's private vulnerability reporting, as described in the repository's SECURITY.md
Security Questions: Open a GitHub issue