Desktop: Security: Remove the `name` attribute when rendering to HTML (#11591)

pull/11572/head^2
Henry Heino 2025-01-06 09:33:19 -08:00 committed by GitHub
parent ac154ee1e8
commit e70efcbd60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,2 @@
<img src="test/" class="jop-noMdConv"/>
<img src="http://example.com/test.png" class="jop-noMdConv"/>

View File

@ -0,0 +1,3 @@
<img name=getElementById src=test/>
<IMG NAME="getElementById" SRC="http://example.com/test.png">

View File

@ -308,6 +308,12 @@ class HtmlUtils {
attrs['href'] = '#';
}
// Allowing the 'name' attribute allows an attacker to overwrite
// DOM methods (e.g. getElementById) with elements.
if ('name' in attrs) {
delete attrs['name'];
}
// We need to clear any such attribute, otherwise it will
// make any arbitrary link open within the application.
if ('data-from-md' in attrs) {