The security vulnerability is a classic Cross-Site Scripting (XSS) issue within the QuestDB Web Console. The root cause is the improper handling of data returned from database queries, specifically column names and cell data, before rendering it in the user interface. The analysis of the patch b42fd9f18476d844ae181a10a249e003dafb823d reveals two primary vulnerable areas:
-
Data Grid Rendering: In src/js/console/grid.js, the grid function was responsible for displaying query results. It used the innerHTML property to set the content of table headers and cells. This allowed any HTML tags within the column names (via aliases) or the data itself to be parsed and executed by the browser. The fix was to switch from innerHTML to textContent, which treats the input as plain text and prevents HTML interpretation.
-
Visualization Configuration: In src/js/console/quick-vis.ts, the quickVis function populates dropdowns for chart axis selection with column names from the query. These names were not sanitized. An attacker could provide a malicious column alias in a query, and the script within it would execute when the visualization panel was rendered. The fix involves explicitly calling a new escapeHtml utility on the column names before they are used in the UI.
In both cases, the vulnerability could be triggered by a user executing a specially crafted SQL query that returns results with malicious content in column names or data, leading to arbitrary JavaScript execution in the context of the user's browser session.