Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 1077813002: Check for DOM clobbering attacks in sanitizing/node validation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/src/Validators.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_Element.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
index a41c6a6831db92c61746f14cf2f01f926dc5e362..14d6abf14b74cd7e7c5b17797fa6e72143953bf9 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -1387,6 +1387,38 @@ $endif
* used when an explicit accessor is not available.
*/
ElementEvents get on => new ElementEvents(this);
+
+ /**
+ * Verify if any of the attributes that we use in the sanitizer look unexpected,
+ * possibly indicating DOM clobbering attacks.
+ *
+ * Those attributes are: attributes, lastChild, children, previousNode and tagName.
+ */
+$if DART2JS
+ bool get _hasCorruptedAttributes {
+ return JS('bool', r'''
+ (function(element) {
+ if (!(element.attributes instanceof NamedNodeMap)) {
+ return true;
+ }
+ var childNodes = element.childNodes;
+ if (element.lastChild &&
+ element.lastChild !== childNodes[childNodes.length -1]) {
+ return true;
+ }
+ if (element.children) { // On Safari, children can apparently be null.
+ if (!((element.children instanceof HTMLCollection) ||
+ (element.children instanceof NodeList))) {
+ return true;
+ }
+ }
+ return false;
+ })(#)''', this);
+ }
+$else
+ // Dartium isn't affected by these attacks, because it goes directly to the C++ API.
+ bool get _hasCorruptedAttributes => false;
+$endif
$if DART2JS
@DomName('Element.offsetHeight')
« no previous file with comments | « tools/dom/src/Validators.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698