Summary
Seafile Server's Seadoc editor contains multiple stored cross-site scripting (XSS) issues where document structure updates sent over WebSockets are not properly sanitized.
Authenticated remote users can inject malicious JavaScript into documents via the src attribute of embedded Excalidraw whiteboards or the href attribute of anchor tags, which then executes in the browsers of other users who view or edit the affected Seadoc documents.
Affected context
The vulnerability appears in Seafile Server's collaborative Seadoc (sdoc) editor, specifically in how it processes and persists rich-text document structure updates over WebSockets.
It is most relevant in deployments where multiple authenticated users collaborate on shared documents and where embedded content (such as Excalidraw whiteboards) and hyperlinks are commonly used.
The risk increases in environments with broad document sharing, group workspaces, or external collaborators, since malicious content can be stored in one user's document and later rendered in other users' browsers.
Exploit preconditions
- Attack surface: Seadoc document editing and viewing interfaces accessed via a browser.
- Required access: Authenticated user account with permission to create or edit Seadoc documents in a target library or workspace.
- Trigger point: A victim user opens or previews a maliciously modified Seadoc document; the unsanitized WebSocket-based document updates are rendered by the browser.
- Why exploitation is possible: The server-side or client-side handling of WebSocket messages for document structure updates fails to robustly validate and sanitize attributes such as
srcon embedded Excalidraw elements andhrefon anchor tags, allowing attacker-controlled JavaScript execution contexts to be stored and replayed to other users.
Why this happens
The underlying issue is insufficient input sanitization and output encoding of user-controlled content before it is stored and rendered as part of a rich-text document.
In this Seadoc context, document structure updates delivered via WebSockets can carry HTML-like structures or attributes (e.g., embedded components, links) that are persisted and later rendered in the browser.
When attributes like src and href are not constrained to safe URL schemes or stripped of script-capable payloads, they enable persistent injection of executable JavaScript.
This aligns with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), where user-controlled data is incorporated into a web page without sufficient neutralization, leading to script execution in the victim's browser.
Potential impact
- Attackers may execute arbitrary JavaScript in the context of the victim user's Seafile domain.
- Session cookies, CSRF tokens, and other sensitive web session data could be accessed and exfiltrated by injected scripts, potentially enabling account takeover.
- Malicious scripts may perform unauthorized actions on behalf of victims, such as modifying or deleting documents, changing sharing permissions, or exfiltrating stored data.
- XSS payloads could be used as a pivot to deliver further phishing, malware, or browser exploitation against users.
- Stored payloads may persist in documents, impacting many users over time until the malicious content is removed.
General mitigation guidance
Effective mitigation commonly focuses on reducing the trust boundary of document content and enforcing strict sanitization for all user-controlled fields:
- Normalize and sanitize all document structure updates on the server side before persistence, ensuring that only a safe subset of tags and attributes is allowed.
- Enforce strict allowlists for attributes like
srcandhref, restricting URL schemes to safe values (e.g., https) and rejecting or stripping script-capable constructs. - Apply robust output encoding at render time so that any remaining user-controlled text is treated as data rather than executable HTML/JavaScript.
- Design rich-text and embedded component models so that user content is stored as structured data (e.g., JSON with typed fields) instead of raw HTML, limiting direct browser interpretation.
- Limit the privileges and capabilities of embedded widgets (such as Excalidraw) to reduce potential script injection surfaces.
- Encourage a defense-in-depth model by combining sanitization, encoding, and stricter content policies (e.g., Content Security Policy) to reduce the impact of any missed injection points.
How teams detect issues like this
Detection approaches generally combine proactive code-level checks with runtime monitoring:
- Use static analysis and linters to flag any paths where user-controlled fields are inserted into HTML or DOM contexts without encoding or sanitization, especially in WebSocket handlers and rich-text processing logic.
- During code review, pay special attention to document editors, collaboration features, and embedded component integrations, looking for direct assignment to
innerHTMLor dynamic attribute construction without proper escaping. - Implement automated tests that inject benign but distinctive HTML/JavaScript markers into document content and assert that they are safely rendered or neutralized.
- Employ Content Security Policy (CSP) reporting endpoints to observe attempts at inline script execution or blocked script loads, which can reveal ongoing exploitation of XSS flaws.
- Integrate security-focused review tools into CI pipelines to scan for known XSS anti-patterns in both server-side and client-side code.

