Skip to content

Fix potential XSS in Markdown rendering via Event Delegation#332

Open
RinZ27 wants to merge 1 commit intoOpenBMB:mainfrom
RinZ27:fix-xss-dompurify-event-delegation
Open

Fix potential XSS in Markdown rendering via Event Delegation#332
RinZ27 wants to merge 1 commit intoOpenBMB:mainfrom
RinZ27:fix-xss-dompurify-event-delegation

Conversation

@RinZ27
Copy link

@RinZ27 RinZ27 commented Mar 1, 2026

Refactored the Markdown rendering in ui/frontend/main.js to close a potential XSS vector. The previous implementation allowed inline JavaScript via onclick attributes, which could be exploited through prompt injection.

I've moved the interaction logic to a global click event listener using event delegation. This allowed me to strip onclick from the DOMPurify allow-list and replace inline handlers with data attributes (data-code-id, data-ref-id). I've verified that 'Copy Code' and 'Citation' links still work exactly as expected.

@RinZ27 RinZ27 force-pushed the fix-xss-dompurify-event-delegation branch 3 times, most recently from 25173b2 to f9e6be3 Compare March 1, 2026 07:13
@RinZ27 RinZ27 force-pushed the fix-xss-dompurify-event-delegation branch from f9e6be3 to 392121a Compare March 1, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant