Security Guidelines for App Suite Teams
This document outlines security practices and guidelines for the Teams application, with focus on preventing common web vulnerabilities.
Table of Contents
- HTML Sanitization and XSS Prevention
- Where Untrusted HTML Is Handled
- Safe vs Unsafe Patterns
- Testing for Security
- Shared Component Library
HTML Sanitization and XSS Prevention
Cross-Site Scripting (XSS) is one of the most common web security vulnerabilities. It occurs when untrusted data is included in a web page without proper validation or escaping.
Critical Rule: Never render untrusted HTML content without sanitization.
Teams does not ship a sanitizer of its own. Each source of untrusted HTML has one dedicated path, described below. Do not add v-html for a new source without deciding which of these paths it takes.
Threat Model
Sources of Untrusted Content:
- Email content - From external senders (highest risk)
- User-generated comments - From authenticated users (medium risk, handled by TipTap)
- Collaborative drafts - Synced via Yjs (medium risk, handled by TipTap)
Attack Vectors Blocked:
- Script tags and inline JavaScript
- Event handlers (onclick, onerror, onload, onfocus, etc.)
- javascript: and data: URLs
- Dangerous elements (iframe, object, embed, form inputs)
- HTML injection and DOM clobbering
- Credential dialogs and tracking through external fonts, media and images
Where Untrusted HTML Is Handled
Email bodies
Email bodies are sanitized with the App Suite mail sanitizer ($/io.ox/mail/sanitizer) at the trust boundary, once per fetched mail (sanitizeMailData in ui/teams/utils/mail-frame-host.ts). The backend fetches the unmodified mail (view=raw), so the client is the only place where sanitization happens and the Core UI hardening and test suite are reused rather than duplicated.
The sanitized body is processed by the App Suite content pipeline and rendered inside the sandboxed mail content frame (ui/teams/lib/mail-frame). The frame is the hard second gate:
- a Content-Security-Policy with
script-src 'none'is written into thesrcdocshell at parse time, so no script can run even if one survived sanitization; font-srcandmedia-srcare'none', closing the Basic-Auth credential dialog vector;- the
sandboxattribute never grantsallow-scriptson Blink and Gecko. WebKit gets it because it does not dispatch DOM events to parent listeners otherwise; the CSP remains the gate there; - external images are blocked by default and revealed in place from the sanitizer's stash (
data-original-*attributes), without a second fetch.
The frame runs a defense-in-depth sanitize pass right before injection. See ADR-0026 and ui/teams/lib/mail-frame/README.md for the host contract.
Comments and drafts
Comments and collaborative drafts are produced and rendered by TipTap. TipTap's schema-based document model only allows whitelisted nodes and marks and strips dangerous attributes and event handlers during editing. Content shared through Yjs goes through the same schema on every client. Do not add a second sanitizer in front of TipTap output: it is redundant and breaks collaborative editing marks and mentions.
See the security comment in ui/teams/components/core/chat-message.vue.
Everything else
Plain values (subjects, names, addresses) are rendered with text interpolation, which Vue escapes. The remaining v-html uses in Teams render TipTap output (chat-message.vue) or a bundled static SVG asset (empty folder illustration), never remote data. If a new feature needs rich HTML from an untrusted source, render it through the mail content frame or through TipTap; do not introduce an ad-hoc sanitizer.
Safe vs Unsafe Patterns
✅ Safe Patterns
Text Content (No HTML):
<template>
<!-- Automatically escaped by Vue -->
<div>{{ userInput }}</div>
<div>{{ mail.subject }}</div>
</template>Attributes with Binding:
<template>
<!-- Vue automatically escapes attribute values -->
<a :href="linkUrl">{{ linkText }}</a>
<img :src="imageUrl" :alt="imageAlt">
</template>Mail bodies through the frame:
<template>
<MailContentFrame :content="frameContent.html" :sanitize="sanitizeForFrame" ... />
</template>❌ Unsafe Patterns
Unsanitized v-html:
<template>
<!-- ❌ CRITICAL VULNERABILITY -->
<div v-html="props.emailContent" />
</template>Dynamic Inline Event Handlers:
<template>
<!-- ❌ Unsafe - use @click instead -->
<div :onclick="dynamicHandler">Click me</div>
<!-- ✅ Safe alternative -->
<div @click="handleClick">Click me</div>
</template>innerHTML Assignment:
// ❌ Unsafe
element.innerHTML = userContent
// ✅ Use textContent if no HTML is needed
element.textContent = userContentRendering a mail body outside the frame:
<!-- ❌ The main document has no CSP gate for mail content -->
<div v-html="mail.attachments[0].content" />Testing for Security
Unit Tests
The frame's security invariants are locked by unit tests:
pnpm test spec/frontend/lib/mail-frame spec/frontend/utils/mail-frame-host.test.tsTest Coverage:
- CSP contents (
script-src 'none',font-src/media-src 'none',img-srcallow-list) font-srcallow-list validation against policy injection- Sandbox never grants
allow-scriptsoutside WebKit - Stash protocol and in-place reveal
- Trust-boundary sanitization is applied once per mail, including nested messages
E2E Security Tests
End-to-end security tests in e2e/tests/content-security.spec.js:
# Run all security tests
pnpm e2e e2e/tests/content-security.spec.jsTest Scenarios:
- Script injection in comments
- Event handler injection
- Malicious email content
- URL injection in tags
- Collaborative editing XSS
- Advanced attack vectors
- No
allow-scriptson the mail frame in Chromium
Manual Testing
Test Email with XSS Vectors:
Send a test email with this content to verify sanitization:
<p>Hello!</p>
<script>alert('XSS')</script>
<img src=x onerror="alert('XSS')">
<a href="javascript:alert('XSS')">Click me</a>
<div onclick="alert('XSS')">Clickable div</div>
<iframe src="javascript:alert('XSS')"></iframe>
<body onload="alert('XSS')">Body</body>
<input type="text" onfocus="alert('XSS')" autofocus>
<svg onload="alert('XSS')"></svg>
<object data="javascript:alert('XSS')"></object>
<embed src="javascript:alert('XSS')">Expected Result: No alerts should execute, content should be safely rendered.
Console lines such as "Blocked script execution in 'about:srcdoc'" come from browser extensions or DevTools probing the frame; they show the CSP working and are not a defect.
Shared Component Library
The mail content frame in ui/teams/lib/mail-frame is built to be moved into the shared App Suite Vue component library (ADR-0026). The frame takes its sanitizer as an injected function; the library will ship a dedicated sanitizer alongside it, possibly derived from the Core UI implementation. Until then, Teams reuses the App Suite mail sanitizer through the host adapter. Teams no longer carries a DOMPurify module of its own (ADR-0012 is superseded).
See ADR-0026 (docs/development/adr/0026-library-ready-mail-content-frame.md) and ADR-0012 (docs/development/adr/0012-local-sanitization-pending-core-ui-api.md).
Security Checklist
Before deploying changes that handle user content:
Resources
- OWASP XSS Prevention Cheat Sheet
- Vue.js Security Best Practices
- TipTap Security
- Content Security Policy (CSP)
- MDN: iframe sandbox
Reporting Security Issues
Security vulnerabilities should be reported immediately to the security team. Do not create public GitHub issues for security problems.
Contact: security@open-xchange.com

