Skip to content

Commit

Permalink
Fix ReDoS vulnerability in PermitScrubber by optimizing regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4n3-yoon committed Aug 13, 2024
1 parent c5734e5 commit 798ea0c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rails/html/scrubbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def scrub_attribute(node, attr_node)
Loofah::HTML5::Scrub.scrub_attribute_that_allows_local_ref(attr_node)
end

if Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF.include?(node.name) && attr_name == "xlink:href" && attr_node.value =~ /^\s*[^#\s].*/m
if Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF.include?(node.name) && attr_name == "xlink:href" && attr_node.value =~ /^\s*[^#].*/m
attr_node.remove
end

Expand Down

0 comments on commit 798ea0c

Please sign in to comment.