Skip to content

fix($sanitize): disallow unsafe svg animation tags and add mXSS prote… #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/content/error/$sanitize/uinput.ngdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ngdoc error
@name $sanitize:uinput
@fullName Failed to sanitize html because the input is unstable
@description

This error occurs when `$sanitize` sanitizer tries to check the input for possible mXSS payload and the verification
errors due to the input mutating indefinitely. This could be a sign that the payload contains code exploiting an mXSS
vulnerability in the browser.

mXSS attack exploit browser bugs that cause some browsers parse a certain html strings into DOM, which once serialized
doesn't match the original input. These browser bugs can be exploited by attackers to create payload which looks
harmless to sanitizers, but due to mutations caused by the browser are turned into dangerous code once processed after
sanitization.
8 changes: 4 additions & 4 deletions lib/htmlparser/htmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
chars = false;
}

// end tag
// end tag
} else if ( html.indexOf("</") == 0 ) {
match = html.match( endTag );

Expand All @@ -82,7 +82,7 @@
chars = false;
}

// start tag
// start tag
} else if ( html.indexOf("<") == 0 ) {
match = html.match( startTag );

Expand Down Expand Up @@ -147,8 +147,8 @@
rest.replace(attr, function(match, name) {
var value = arguments[2] ? arguments[2] :
arguments[3] ? arguments[3] :
arguments[4] ? arguments[4] :
fillAttrs[name] ? name : "";
arguments[4] ? arguments[4] :
fillAttrs[name] ? name : "";

attrs.push({
name: name,
Expand Down
Loading