File tree Expand file tree Collapse file tree 6 files changed +51
-17
lines changed Expand file tree Collapse file tree 6 files changed +51
-17
lines changed Original file line number Diff line number Diff line change 1+ ## 2.12.3 - 2021-04-12
2+
3+ This is a patch release that fixes a vulnerability in ` dart:html ` related to
4+ DOM clobbering. Thanks again to ** Vincenzo di Cicco** for finding and reporting
5+ this vulnerability.
6+
17## 2.12.2 - 2021-03-17
28
39This is a patch release that fixes crashes reported by Flutter 2 users (issue
Original file line number Diff line number Diff line change @@ -40994,8 +40994,8 @@ class _ThrowsNodeValidator implements NodeValidator {
4099440994class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
4099540995 NodeValidator validator;
4099640996
40997- /// Did we modify the tree by removing anything .
40998- bool modifiedTree = false ;
40997+ /// Number of tree modifications this instance has made .
40998+ int numTreeModifications = 0 ;
4099940999 _ValidatingTreeSanitizer(this.validator) {}
4100041000
4100141001 void sanitizeTree(Node node) {
@@ -41026,20 +41026,20 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
4102641026 }
4102741027 }
4102841028
41029- modifiedTree = false;
41030- walk(node, null) ;
41031- while (modifiedTree) {
41032- modifiedTree = false ;
41029+ // Walk the tree until no new modifications are added to the tree.
41030+ var previousTreeModifications ;
41031+ do {
41032+ previousTreeModifications = numTreeModifications ;
4103341033 walk(node, null);
41034- }
41034+ } while (previousTreeModifications != numTreeModifications);
4103541035 }
4103641036
4103741037 /// Aggressively try to remove node.
4103841038 void _removeNode(Node node, Node? parent) {
4103941039 // If we have the parent, it's presumably already passed more sanitization
4104041040 // or is the fragment, so ask it to remove the child. And if that fails
4104141041 // try to set the outer html.
41042- modifiedTree = true ;
41042+ numTreeModifications++ ;
4104341043 if (parent == null || parent != node.parentNode) {
4104441044 node.remove();
4104541045 } else {
Original file line number Diff line number Diff line change @@ -453,6 +453,20 @@ main() {
453453 "<input id='bad' onmouseover='alert(1)'>" ,
454454 "" );
455455
456+ // Walking templates triggers a recursive sanitization call, which shouldn't
457+ // invalidate the information collected from the previous visit of the later
458+ // nodes in the walk.
459+ testHtml (
460+ 'DOM clobbering with recursive sanitize call using templates' ,
461+ validator,
462+ "<form><div>"
463+ "<input id=childNodes />"
464+ "<template></template>"
465+ "<input id=childNodes name=lastChild />"
466+ "<img id=exploitImg src=0 onerror='alert(1)' />"
467+ "</div></form>" ,
468+ "" );
469+
456470 test ('tagName makes containing form invalid' , () {
457471 var fragment = document.body! .createFragment (
458472 "<form onmouseover='alert(2)'><input name='tagName'>" ,
Original file line number Diff line number Diff line change @@ -478,6 +478,20 @@ main() {
478478 "<input id='bad' onmouseover='alert(1)'>" ,
479479 "" );
480480
481+ // Walking templates triggers a recursive sanitization call, which shouldn't
482+ // invalidate the information collected from the previous visit of the later
483+ // nodes in the walk.
484+ testHtml (
485+ 'DOM clobbering with recursive sanitize call using templates' ,
486+ validator,
487+ "<form><div>"
488+ "<input id=childNodes />"
489+ "<template></template>"
490+ "<input id=childNodes name=lastChild />"
491+ "<img id=exploitImg src=0 onerror='alert(1)' />"
492+ "</div></form>" ,
493+ "" );
494+
481495 test ('tagName makes containing form invalid' , () {
482496 var fragment = document.body.createFragment (
483497 "<form onmouseover='alert(2)'><input name='tagName'>" ,
Original file line number Diff line number Diff line change 2626CHANNEL stable
2727MAJOR 2
2828MINOR 12
29- PATCH 2
29+ PATCH 3
3030PRERELEASE 0
3131PRERELEASE_PATCH 0
Original file line number Diff line number Diff line change @@ -158,8 +158,8 @@ class _ThrowsNodeValidator implements NodeValidator {
158158class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
159159 NodeValidator validator;
160160
161- /// Did we modify the tree by removing anything .
162- bool modifiedTree = false ;
161+ /// Number of tree modifications this instance has made .
162+ int numTreeModifications = 0 ;
163163 _ValidatingTreeSanitizer (this .validator) {}
164164
165165 void sanitizeTree (Node node) {
@@ -190,20 +190,20 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
190190 }
191191 }
192192
193- modifiedTree = false ;
194- walk (node, null ) ;
195- while (modifiedTree) {
196- modifiedTree = false ;
193+ // Walk the tree until no new modifications are added to the tree.
194+ var previousTreeModifications ;
195+ do {
196+ previousTreeModifications = numTreeModifications ;
197197 walk (node, null );
198- }
198+ } while (previousTreeModifications != numTreeModifications);
199199 }
200200
201201 /// Aggressively try to remove node.
202202 void _removeNode (Node node, Node ? parent) {
203203 // If we have the parent, it's presumably already passed more sanitization
204204 // or is the fragment, so ask it to remove the child. And if that fails
205205 // try to set the outer html.
206- modifiedTree = true ;
206+ numTreeModifications ++ ;
207207 if (parent == null || parent != node.parentNode) {
208208 node.remove ();
209209 } else {
You can’t perform that action at this time.
0 commit comments