-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libxml2 >= 2.9.2 fails to escape comments within some attributes. It wants to ensure these comments can be treated as "server-side includes", but as a result fails to ensure that serialization is well-formed, resulting in an opportunity for XSS injection of code into a final re-parsed document (presumably in a browser). See #144 for more details and history around this libxml2 issue, which goes back a few years. At this point it's not clear to your humble maintainer why this hasn't been addressed upstream by libxml2 maintainers, and so I'm working around it in Loofah to protect Loofah users, while simultaneously attempting to escalate the issue upstream. [fixes #144]
- Loading branch information
1 parent
0c97c74
commit f739cf8
Showing
4 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# coding: utf-8 | ||
require 'set' | ||
|
||
module Loofah | ||
# | ||
# constants related to working around unhelpful libxml2 behavior | ||
# | ||
# ಠ_ಠ | ||
# | ||
module LibxmlWorkarounds | ||
# | ||
# these attributes and qualifying parent tags are determined by the code at: | ||
# | ||
# https://git.gnome.org/browse/libxml2/tree/HTMLtree.c?h=v2.9.2#n714 | ||
# | ||
# see comments about CVE-2018-8048 within the tests for more information | ||
# | ||
BROKEN_ESCAPING_ATTRIBUTES = Set.new %w[ | ||
href | ||
action | ||
src | ||
name | ||
] | ||
BROKEN_ESCAPING_ATTRIBUTES_QUALIFYING_TAG = {"name" => "a"} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f739cf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this -- highly appreciated. I've prepared this in Debian, pending upload.
f739cf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this breaks two tests in rails-html-sanitizer, some spaces in the output changed. Any idea regarding this? (Will provide details later.)
f739cf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should talk to the rails-html-sanitizer team about that. @kaspth might have some insight.
f739cf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I've sent him a mail already. Thanks. :)
f739cf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a new release that fixes it for rails-html-sanitizer. Thanks! https://github.com/rails/rails-html-sanitizer/releases/tag/v1.0.4
f739cf8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaspth Thank you!