/

CVE-2026-27614

Severity:

CRITICAL RISK

(9.3)

Cross-Site Scripting (XSS) in Bugsink Stacktrace Viewer

CVE-2026-27614

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Stored Cross-Site Scripting leading to account takeover and administrative actions in the Bugsink UI

Severity:

CRITICAL RISK

(9.3)

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

Bugsink's web UI contains a stored cross-site scripting vulnerability in how it renders stacktraces that have been syntax-highlighted with Pygments.

An unauthenticated attacker who can send events to a Bugsink project can inject JavaScript into stored events, which will execute in an administrator's browser when they view the crafted stacktrace, allowing actions within Bugsink to be performed with that admin's privileges.

Affected context

This vulnerability affects Bugsink instances that:

  • Accept events via public DSN-based ingest endpoints (per the Sentry protocol model)
  • Use the stacktrace view in the web UI, particularly when syntax highlighting is applied via Pygments
  • Allow administrators or privileged users to inspect detailed stacktraces for incoming events

The issue manifests when Pygments returns more lines than were originally provided for highlighting (a known quirk with Ruby heredoc-style input), causing raw, unsanitized lines from the event to be rendered directly in the browser.

Exploit preconditions

  • Attack surface: Bugsink event ingestion (DSN) endpoint and the web-based stacktrace viewer.
  • Required access: Ability to submit events to a specific Bugsink project (knowing the DSN or having access to a client using it); no Bugsink account is required to inject payloads.
  • Trigger point: A privileged user, typically an administrator, must open the affected event's stacktrace in the Bugsink web UI, at which point the injected JavaScript runs in their browser.
  • Why exploitation is possible: When Pygments returns more lines than expected, _pygmentize_lines() in theme/templatetags/issues.py:75-77 falls back to returning raw input lines. The template logic later calls mark_safe() (lines 111-113) unconditionally, marking unescaped attacker-controlled HTML/JavaScript as safe and causing it to be rendered as active content in the browser.

Why this happens

The underlying bug is a stored cross-site scripting (XSS) issue arising from improper trust in data passed through a syntax highlighter.

The _pygmentize_lines() helper assumes Pygments will return the same number of lines it was given and, on mismatch, simply falls back to the original raw input lines. These lines are then passed into the template where mark_safe() is applied without verifying whether the data is already escaped or whether it is safe to render as HTML. Because event payloads come from external clients over the DSN ingest endpoint, this violates the principle of treating all user-supplied input as untrusted. This pattern maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where attacker-controlled content is rendered directly in the browser without appropriate escaping or sanitization.

Potential impact

  • Execution of arbitrary JavaScript in the browser of an authenticated Bugsink administrator or privileged user
  • Impersonation of the affected administrator within the Bugsink UI (e.g., creating, modifying, or deleting projects or settings)
  • Theft of session tokens, CSRF tokens, or other sensitive browser-stored data related to Bugsink
  • Modification of error data, issue states, or configuration within the Bugsink instance
  • Use of the Bugsink admin's access as a pivot point for broader compromise of associated services or integrations

General mitigation guidance

Effective mitigation focuses on enforcing robust output encoding and avoiding unsafe HTML-marking primitives in views that render untrusted data:

  • Treat all event and stacktrace fields as untrusted input, regardless of upstream processing by helpers like Pygments or similar libraries.
  • Apply context-appropriate escaping/encoding by default when rendering stacktrace lines, ensuring that any HTML or JavaScript-like content is displayed as text rather than executed.
  • Avoid unconditional use of mark_safe() or equivalent "trust this HTML" APIs, especially for values derived from user-controlled or external input; prefer safe template auto-escaping and narrowly scoped whitelists where HTML is truly required.
  • Handle library quirks defensively, such as Pygments returning more lines than supplied, by explicitly validating output shapes and rejecting or re-escaping unexpected or malformed data instead of falling back to raw input.
  • Reduce privilege and exposure in the admin interface, for example by ensuring that critical actions are protected by additional confirmation steps and by separating high-risk diagnostics views from high-privilege configuration actions.

How teams detect issues like this

Detection can be approached through a combination of code analysis and runtime security practices:

  • Static analysis and linters: Configure rules to flag use of mark_safe() or similar functions in templates and views, particularly where the argument originates from request data, event payloads, logs, or other untrusted sources.
  • Code review patterns: During peer review, look for:
  • Code paths where external event data flows into rendering logic without escaping
  • Fallback logic (like _pygmentize_lines() behavior) that returns raw user input to templates
  • Any template tag or helper that wraps content with "safe" markers or disables auto-escaping
  • Security-focused tests: Add unit and integration tests that submit crafted stacktraces (including Ruby heredoc-style payloads) and verify that the resulting UI output is correctly escaped and does not execute scripts.
  • Automated scanning: Use web security scanners or browser-based test harnesses to crawl the Bugsink UI for potential reflected and stored XSS by injecting benign payload markers into events and observing rendered output.

Sources

SourceLink
github.comgithub.com/bugsink/bugsink/commit/e784d6aeb0d5f29b40c2779d2544c2b9ef097ee9
github.comgithub.com/bugsink/bugsink/releases/tag/2.0.13
github.comgithub.com/bugsink/bugsink/security/advisories/GHSA-vp6q-7m36-pq3w

Frequently asked

questions

Yes. An attacker can exploit it remotely as long as they can reach the Bugsink DSN ingest endpoint and submit crafted events to a project. The actual JavaScript execution occurs when a logged-in administrator later views the malicious stacktrace in their browser.

No Bugsink account is required to inject the payload, because DSN-based event endpoints are designed to be publicly reachable by clients. The attacker only needs knowledge of a valid DSN or access to a client that uses it. However, impact depends on an authenticated administrator eventually opening the crafted event in the UI.

The most robust fix is to ensure that all stacktrace lines and event fields are escaped by default and never marked safe unless they originate from a strictly controlled, non-user-supplied source. This typically means removing or tightly constraining mark_safe() usage, validating library outputs like Pygments, and adopting a strict "encode-on-output" strategy in templates.

Prevention involves consistently treating external data as untrusted, relying on template auto-escaping, and banning or heavily reviewing APIs that bypass escaping. Complement this with secure coding guidelines, automated linting for unsafe patterns, regular security-focused code reviews, and regression tests that cover rendering paths for logs, stacktraces, and error payloads.

Find out what's already
exploitable in your codebase.