Commit ec5f13f
authored
fix: (critical) prevent xss in unicode input component (#735)
This PR fixes a prompt injection in the unicode input component, which is also used on several web pages (e.g. Loogle). The issue was originally reported [here](https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/weird.20behavior.20in.20loogle.20searchbar/with/578558458).
The technical cause of the issue is as follows:
- The text of the unicode input HTML element is set (e.g. from a query parameter) and escaped properly
- Any of the handlers in the unicode input component triggers, reading the `innerText` of the component, which yields the text of the HTML element (without escapes)
- The unicode input component sets the `innerHtml` of the HTML element (potentially including tags to mark active abbreviations using underlines), thus injecting the non-escaped tags
The fix for this issue is to escape all text before setting it in the `innerHtml` except for the underline tags that are created by the unicode input component itself.
**If you are using the unicode input component on a website, it is strongly recommended to update the unicode input component to 0.2.0 after this PR!**1 parent a884fa0 commit ec5f13f
1 file changed
+13
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
125 | 134 | | |
126 | 135 | | |
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
130 | | - | |
| 139 | + | |
131 | 140 | | |
132 | 141 | | |
133 | 142 | | |
134 | | - | |
| 143 | + | |
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
| |||
220 | 229 | | |
221 | 230 | | |
222 | 231 | | |
223 | | - | |
| 232 | + | |
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
| |||
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
239 | | - | |
| 248 | + | |
240 | 249 | | |
241 | 250 | | |
242 | 251 | | |
| |||
0 commit comments