/

CVE-2026-40497

Severity:

HIGH RISK

(8.1)

XSS in FreeScout Mailbox Signature Rendering

CVE-2026-40497

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Account Takeover and Privilege Escalation via CSS-Based XSS

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

FreeScout's mailbox signature handling prior to version 1.8.213 allowed unescaped <style> tags to be stored and later rendered in conversation views, enabling CSS-based cross-site scripting behavior.

An authenticated attacker with mailbox settings access could inject crafted CSS to exfiltrate CSRF tokens from other agents/admins who view affected conversations, enabling full account takeover and privilege escalation.

Affected context

The vulnerability occurs in FreeScout instances where:

  • Mailbox signatures are configured through POST /mailbox/settings/{id}.
  • The signature is rendered in conversation views using {!! $conversation->getSignatureProcessed([], true) !!} without escaping.
  • Content Security Policy (CSP) permits style-src * 'self' 'unsafe-inline', allowing inline styles and broad style sources.

Under these conditions, a trusted-but-editable mailbox signature becomes an injection point for malicious CSS that runs in the browser of any user viewing conversations for that mailbox.

Exploit preconditions

  • Attack surface: Web UI for FreeScout conversation views where mailbox signatures are displayed.
  • Required access:
  • Ability to edit mailbox settings/signature (e.g., admin or agent with mailbox permission).
  • Victim (another agent/admin) must view a conversation in the affected mailbox while logged in.
  • Trigger point: Rendering of the malicious mailbox signature in the conversation view template via unescaped HTML output.
  • Why exploitation is possible:
  • Helper::stripDangerousTags() removes some dangerous tags (script, form, iframe, object) but leaves <style> tags intact.
  • The signature is output with {!! !!} in Blade, bypassing HTML escaping.
  • CSP configuration explicitly allows inline styles and wide style sources, so attacker-controlled CSS is honored by the browser.
  • Carefully crafted CSS attribute selectors can interact with the DOM and side channels to exfiltrate the victim's CSRF token.

Why this happens

This issue is rooted in incomplete output sanitization and overreliance on a narrow blacklist of HTML tags. The function Helper::stripDangerousTags() attempts to neutralize XSS by stripping specific elements (<script>, <form>, <iframe>, <object>), but it does not consider <style> as dangerous, despite the ability of CSS to influence and sometimes exfiltrate sensitive data in permissive CSP contexts.

Combined with unescaped rendering using Laravel Blade's {!! !!} syntax, the application treats semi-trusted user-controlled data (mailbox signature) as safe HTML. This pattern maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting)—untrusted content is incorporated into dynamic pages without comprehensive neutralization or a default-escape strategy. The prior fix for a related XSS focused on script-centric payloads and failed to address style-based injection and CSP interactions, leaving a residual cross-site scripting vector.

Potential impact

  • Theft of CSRF tokens from agents or admins who view conversations in affected mailboxes.
  • Execution of unauthorized state-changing actions as the victim, including:
  • Creating new administrator accounts.
  • Changing email addresses and passwords for existing accounts.
  • Modifying mailbox or global application settings.
  • Privilege escalation from a lower-privileged agent with mailbox access to full administrative control.
  • Compromise of the integrity and availability of help desk workflows, including ticket manipulation and data tampering.
  • Potential pivot into broader infrastructure if FreeScout is used as a foothold and integrated with other internal systems.

General mitigation guidance

Effective mitigation focuses on treating mailbox signatures and similar rich-text fields as untrusted content by default and enforcing robust output encoding and sanitization patterns.

Recommended defensive patterns include:

  • Default to output escaping: Use auto-escaping template constructs (e.g., {{ }} in Blade) and reserve unescaped output for strictly controlled, pre-sanitized HTML.
  • Adopt whitelisting sanitizers: Apply an allowlist-based HTML sanitizer that permits only a minimal, well-defined subset of tags and attributes (e.g., basic formatting) and removes <style>, event handlers, and potentially dangerous attributes entirely.
  • Reduce reliance on blacklists: Avoid tag-based blacklists that target only a few elements (script, iframe, etc.). Instead, define a positive model of what markup is acceptable for signatures.
  • Constrain styling capabilities: Where rich formatting is necessary, use server-side formatting tools (e.g., markdown, BBCode, or a constrained WYSIWYG) that generate controlled HTML, and avoid user-controlled raw CSS.
  • Harden CSP policies: Tighten CSP to minimize inline style execution (style-src 'self' and disallow 'unsafe-inline' where feasible) and avoid overly permissive directives like style-src *.
  • Apply least privilege for roles: Limit who can modify mailbox signatures and similar shared content fields, reducing the number of potential internal attackers.

How teams detect issues like this

Organizations can detect and prevent similar issues through a combination of code analysis, review practices, and runtime monitoring:

  • Static analysis:
  • Configure linters or SAST tools to flag unescaped output patterns (e.g., Blade {!! !!} or equivalent templating constructs) when fed data originating from HTTP requests or database fields.
  • Add rules to detect use of custom sanitization functions that rely on tag blacklists (like stripDangerousTags) and require review of their coverage and usage sites.
  • Code review signals:
  • Treat any HTML-rendering of user-controlled fields (signatures, templates, canned replies, comments) as high-risk and require security review.
  • Look for logic paths where sanitization occurs only on input save, not at render time, and ensure that assumptions about trust are documented and correct.
  • Cross-check CSP configuration, verifying that it is aligned with the assumptions embedded in sanitization logic (e.g., no assumption that CSS is "safe" when CSP is permissive).
  • Automated policy enforcement:
  • Implement pre-merge checks that reject use of dangerous template constructs for untrusted data unless a security justification is provided.
  • Use automated HTML sanitization libraries by default and discourage ad-hoc filter helpers.
  • Runtime monitoring (where possible):
  • Monitor logs and security tools for suspicious content in rich-text fields (e.g., <style> tags or unusual CSS in signatures).
  • Use browser-side security testing tools or CSP violation reports to detect unexpected execution of inline styles or other CSP exceptions.

Sources

SourceLink
github.comgithub.com/freescout-help-desk/freescout/commit/5aa8d633216f65995e80a7d4a921b784acc94df4
github.comgithub.com/freescout-help-desk/freescout/releases/tag/1.8.213
github.comgithub.com/freescout-help-desk/freescout/security/advisories/GHSA-fh99-wr77-pxq3

Frequently asked

questions

No. An attacker must have valid credentials with permission to modify mailbox settings (such as an agent or admin account). However, once a malicious signature is in place, any authenticated agent or admin who views conversations in that mailbox can be impacted.

The attacker needs the ability to edit the mailbox signature, typically via an agent or admin role with mailbox configuration permissions. After injecting malicious CSS, they rely on higher-privileged users (e.g., admins) visiting the affected conversation views to capture their CSRF tokens.

The safest approach is to treat all user-controllable HTML as untrusted, enforce allowlist-based sanitization that strips <style> and other dangerous constructs, and render content using auto-escaping templates. Where rich formatting is required, transform user input into safe HTML via controlled processors (markdown, sanitized WYSIWYG output) instead of storing and rendering raw HTML.

Prevention relies on security-by-default patterns: always escape output unless there is a strong justification not to, use mature sanitization libraries rather than custom blacklist helpers, align CSP with the actual risk model (avoid permissive unsafe-inline where possible), and incorporate XSS-focused checks into code review, CI pipelines, and automated analysis tools.

Find out what's already
exploitable in your codebase.