Skip to content

Commit 6ac22f7

Browse files
fix($sanitize): disallow unsafe svg animation tags and add mXSS prote… (#16)
(Code adaptation from angular@67688d5 ) (Code adaptation from angular@bc0d8c4 and angular#12524) Closes [DEV-144](https://bonitasoft.atlassian.net/browse/DEV-144) Co-authored-by: benjaminParisel <[email protected]>
1 parent 4daf6e8 commit 6ac22f7

File tree

11 files changed

+2216
-2229
lines changed

11 files changed

+2216
-2229
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@ngdoc error
2+
@name $sanitize:uinput
3+
@fullName Failed to sanitize html because the input is unstable
4+
@description
5+
6+
This error occurs when `$sanitize` sanitizer tries to check the input for possible mXSS payload and the verification
7+
errors due to the input mutating indefinitely. This could be a sign that the payload contains code exploiting an mXSS
8+
vulnerability in the browser.
9+
10+
mXSS attack exploit browser bugs that cause some browsers parse a certain html strings into DOM, which once serialized
11+
doesn't match the original input. These browser bugs can be exploited by attackers to create payload which looks
12+
harmless to sanitizers, but due to mutations caused by the browser are turned into dangerous code once processed after
13+
sanitization.

lib/htmlparser/htmlparser.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
chars = false;
7373
}
7474

75-
// end tag
75+
// end tag
7676
} else if ( html.indexOf("</") == 0 ) {
7777
match = html.match( endTag );
7878

@@ -82,7 +82,7 @@
8282
chars = false;
8383
}
8484

85-
// start tag
85+
// start tag
8686
} else if ( html.indexOf("<") == 0 ) {
8787
match = html.match( startTag );
8888

@@ -147,8 +147,8 @@
147147
rest.replace(attr, function(match, name) {
148148
var value = arguments[2] ? arguments[2] :
149149
arguments[3] ? arguments[3] :
150-
arguments[4] ? arguments[4] :
151-
fillAttrs[name] ? name : "";
150+
arguments[4] ? arguments[4] :
151+
fillAttrs[name] ? name : "";
152152

153153
attrs.push({
154154
name: name,

0 commit comments

Comments
 (0)