The vulnerability is a cross-site scripting (XSS) issue in the @leanprover/unicode-input-component. The root cause is that user-provided input was being rendered as HTML without proper escaping. The component would read text from an input element (innerText), process it, and then write it back to the element's innerHTML. This process failed to sanitize the text, allowing embedded HTML and script tags to be executed.
The patch, identified in commit 14b7a105c89d2819c5e78970fd258393f76453bb, introduces an escapeHtml function to sanitize the input. This function is applied in several key places:
- In the
replaceAt function, which is responsible for constructing the new HTML string. All parts of the original string are now escaped before being added to the result.
- In the
InputAbbreviationRewriter.present method, the text to be underlined is now escaped before being wrapped in <u> tags.
- In the
InputAbbreviationRewriter.replaceAbbreviations method, the newText from a change event is escaped before being incorporated into the updated HTML.
Any of these functions could appear in a runtime profile during an exploit. replaceAt is a central function that processes the untrusted input, while present and replaceAbbreviations are the methods that orchestrate the update and trigger the innerHTML set, making them the primary indicators of the vulnerable operation.