Summary
FreeScout versions prior to 1.8.213 contain a stored cross-site scripting (XSS) vulnerability in the mailbox signature feature, where user-controlled HTML is insufficiently sanitized and rendered back into the DOM as raw HTML.
Any authenticated user with the mailbox signature permission can inject HTML and JavaScript that execute automatically when other agents or administrators view conversations in the affected mailbox, enabling session hijacking, phishing overlays, and privilege escalation under suitable conditions.
Affected context
The vulnerability occurs in FreeScout's mailbox signature editing and rendering flow.
It affects deployments where:
- Users with the
ACCESS_PERM_SIGNATURE(sig) permission can edit mailbox signatures - The application stores signature content in the database and later renders it using Blade's
{!! !!}syntax - The resulting HTML is re-inserted into the page using JavaScript's
.html()API
In this context, mailbox signatures become a persistent script injection point that is rendered in the agent UI whenever an affected mailbox conversation is opened.
Exploit preconditions
- Attack surface: Web UI for managing mailbox signatures in FreeScout.
- Required access: Authenticated account with the delegatable
ACCESS_PERM_SIGNATUREpermission on at least one mailbox; no administrative privileges required. - User-controlled input: Signature content submitted via
MailboxesController::updateSave()and processed byHelper::stripDangerousTags(). - Sanitization weakness: The sanitizer uses an incomplete blocklist of four HTML tags (
script,form,iframe,object) and does not remove event handler attributes (e.g.,onerror,onload,onclick), allowing elements like<img>,<svg>, and<details>to carry executable JavaScript. - Trigger point: The stored signature HTML is rendered raw in
editor_bottom_toolbar.blade.phpusing{!! !!}and then injected into the DOM using jQuery.html()inmain.js:1789-1790, causing any event handlers to execute when the conversation view is loaded. - Why exploitation is possible: Untrusted, user-controlled HTML is stored and later inserted into the DOM without robust, context-aware sanitization or output encoding, so browser script execution rules are applied to attacker-supplied markup.
Why this happens
The core issue is a failure to neutralize script-related content before rendering it back into a browser context, aligning with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).
The sanitization logic uses:
- A narrow blocklist approach, only removing a small set of dangerous tags (
script,form,iframe,object) - No systematic handling of event attributes (e.g.,
onerror,onload,onclick) or other JavaScript-capable constructs (e.g.,xlink:hrefin SVG,javascript:URLs)
Instead of applying context-appropriate output encoding, the application:
- Stores sanitized-but-still-dangerous HTML directly in the database
- Outputs it using Blade's unescaped
{!! !!}directive - Reinserts it into the DOM using
.html(), which instructs the browser to parse the attacker-controlled HTML as active markup
This pattern represents an input validation and output encoding mismatch: HTML is only superficially filtered at input time, and no escaping is applied at render time, allowing attacker-controlled scripts to execute in victims' browsers.
Potential impact
- Unauthorized execution of attacker-controlled JavaScript in the browser sessions of agents and administrators viewing affected mailboxes
- Session hijacking and account takeover where cookies or tokens are accessible to JavaScript and CSP allows extraction
- Creation of phishing overlays or UI redressing elements that prompt agents to reveal credentials or perform unintended actions
- Abuse of authenticated agent or admin context to perform state-changing actions (e.g., modifying settings, exfiltrating mail, changing mail routing rules)
- Potential self-propagating behavior by injecting malicious signatures into additional mailboxes ("worm-like" propagation inside the FreeScout instance)
- Exposure of sensitive mailbox content through scripted exfiltration to attacker-controlled endpoints
General mitigation guidance
Effective mitigation focuses on eliminating unsafe HTML handling patterns and enforcing strong, context-aware output encoding for any user-derived content.
Recommended defensive patterns include:
- Prefer output encoding over raw HTML rendering:
- Avoid using unescaped template directives (e.g., Blade
{!! !!}) for user-controlled content. - Use escaped output (
{{ }}) or encode user input so it is treated as text, not active markup.
- Use allowlist-based HTML sanitization when HTML is truly needed:
- If rich text signatures are required, use a well-maintained HTML sanitizer that:
- Enforces a strict allowlist of tags and attributes
- Strips event handlers (
on*attributes),javascript:URLs, and other script-like constructs - Configure sanitization separately for each context (HTML body, attribute, URL, etc.).
- Avoid client-side
.html()for untrusted content: - Prefer
.text()or safe DOM APIs that do not parse strings as HTML when dealing with user-controlled input. - If HTML must be generated, build DOM elements using safe APIs (e.g.,
document.createElement) with explicit control of attributes.
- Apply least privilege to content-editing permissions:
- Restrict the
ACCESS_PERM_SIGNATUREpermission to trusted roles and review delegation practices. - Periodically audit which accounts can modify globally visible content like signatures.
- Harden browser-side defenses where possible:
- Define and maintain a strict Content Security Policy (CSP) to reduce impact if a script injection occurs (e.g., disallow
unsafe-inline, restrict script sources). - Avoid legacy configurations that weaken CSP (e.g., permissive
script-srcor broadunsafe-inlineallowances).
How teams detect issues like this
Detection strategies can combine code-focused review with runtime monitoring to identify and prevent similar XSS patterns.
Static and code review approaches:
- Search for:
- Uses of unescaped template rendering (
{!! !!}in Blade or equivalent in other frameworks) involving variables derived from user or database content. - JavaScript calls like
.html()orinnerHTMLthat accept data originating from request parameters, database fields, or other untrusted sources. - Add static analysis rules to:
- Flag concatenation of HTML strings with variables derived from user input.
- Identify sanitization functions that:
- Use ad-hoc blocklists of tags or attributes
- Do not explicitly strip event attributes or
javascript:URLs - During manual reviews, verify:
- That any feature allowing rich content (signatures, templates, comments) uses a vetted, allowlist-based sanitizer.
- That output encoding is applied at the template layer according to the context (HTML, attribute, URL).
Automated security tooling:
- Employ SAST tools configured with rules for:
- Improper use of raw HTML rendering APIs
- Known XSS sinks (
.html(),innerHTML,document.write, etc.) without prior robust sanitization or encoding. - Integrate these checks into CI pipelines so that new or changed code involving HTML rendering and sanitization is automatically analyzed.
Runtime and behavior monitoring:
- Implement Content Security Policy (CSP) violation reporting endpoints to observe unexpected script execution attempts.
- Monitor logs and telemetry for anomalous patterns:
- Unexpected requests to external domains from the application's UI
- Sudden changes in signatures or other shared rich text areas across multiple mailboxes.

