Search for packages
| purl | pkg:gem/rails-html-sanitizer@1.0.1 |
| Vulnerability | Summary | Fixed by |
|---|---|---|
|
VCID-1yh1-jw3q-dfaq
Aliases: CVE-2022-23517 GHSA-5x79-w82f-gw8w GMS-2022-8298 |
Inefficient Regular Expression Complexity in rails-html-sanitizer ## Summary Certain configurations of rails-html-sanitizer `< 1.4.4` use an inefficient regular expression that is susceptible to excessive backtracking when attempting to sanitize certain SVG attributes. This may lead to a denial of service through CPU resource consumption. ## Mitigation Upgrade to rails-html-sanitizer `>= 1.4.4`. |
Affected by 5 other vulnerabilities. |
|
VCID-b9g6-m8kc-2kfg
Aliases: CVE-2024-53985 GHSA-w8gc-x259-rc7x |
rails-html-sanitizer has XSS vulnerability with certain configurations ## Summary There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0 and Nokogiri < 1.15.7, or 1.16.x < 1.16.8. * Versions affected: 1.6.0 * Not affected: < 1.6.0 * Fixed versions: 1.6.1 Please note that the fix in v1.6.1 is to update the dependency on Nokogiri to 1.15.7 or >= 1.16.8. ## Impact A possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer may allow an attacker to inject content if HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags in either of the following ways: * allow both "math" and "style" elements * or allow both "svg" and "style" elements Code is only impacted if Rails is configured to use HTML5 sanitization, please see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information on these configuration options. Code is only impacted if allowed tags are being overridden. Applications may be doing this in a few different ways: 1. using application configuration to configure Action View sanitizers' allowed tags: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["math", "style"] # or config.action_view.sanitized_allowed_tags = ["svg", "style"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view 2. using a `:tags` option to the Action View helper `sanitize`: ``` <= sanitize @comment.body, tags: ["math", "style"] > <# or> <= sanitize @comment.body, tags: ["svg", "style"] > ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize 3. setting Rails::HTML5::SafeListSanitizer class attribute `allowed_tags`: ```ruby # class-level option Rails::HTML5::SafeListSanitizer.allowed_tags = ["math", "style"] # or Rails::HTML5::SafeListSanitizer.allowed_tags = ["svg", "style"] ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 4. using a `:tags` options to the Rails::HTML5::SafeListSanitizer instance method `sanitize`: ```ruby # instance-level option Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["math", "style"]) # or Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["svg", "style"]) ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 5. setting ActionText::ContentHelper module attribute `allowed_tags`: ```ruby ActionText::ContentHelper.allowed_tags = ["math", "style"] # or ActionText::ContentHelper.allowed_tags = ["svg", "style"] ``` All users overriding the allowed tags by any of the above mechanisms to include (("math" or "svg") and "style") should either upgrade or use one of the workarounds. ## Workarounds Any one of the following actions will work around this issue: - Remove "style" from the overridden allowed tags, - Or, remove "math" and "svg" from the overridden allowed tags, - Or, downgrade sanitization to HTML4 (see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information) - Or, independently upgrade Nokogiri to v1.15.7 or >= 1.16.8. ## References - [CWE - CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (4.9)](https://cwe.mitre.org/data/definitions/79.html) - Original report: https://hackerone.com/reports/2503220 ## Credit This vulnerability was responsibly reported by HackerOne user [@taise](https://hackerone.com/taise?type=user). |
Affected by 0 other vulnerabilities. |
|
VCID-e2em-bwyc-uqgh
Aliases: CVE-2022-23520 GHSA-rrfc-7g8p-99q8 GMS-2022-8301 |
Possible XSS vulnerability with certain configurations of rails-html-sanitizer ## Summary There is a possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer. This is due to an incomplete fix of CVE-2022-32209. - Versions affected: ALL - Not affected: NONE - Fixed versions: 1.4.4 ## Impact A possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer may allow an attacker to inject content if the application developer has overridden the sanitizer's allowed tags to allow both "select" and "style" elements. Code is only impacted if allowed tags are being overridden using either of the following two mechanisms: 1. Using the Rails configuration `config.action_view.sanitized_allow_tags=`: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["select", "style"] ``` (see https://guides.rubyonrails.org/configuring.html#configuring-action-view) 2. Using the class method `Rails::Html::SafeListSanitizer.allowed_tags=`: ```ruby # class-level option Rails::Html::SafeListSanitizer.allowed_tags = ["select", "style"] ``` All users overriding the allowed tags by either of the above mechanisms to include both "select" and "style" should either upgrade or use one of the workarounds immediately. NOTE: Code is _not_ impacted if allowed tags are overridden using either of the following mechanisms: - the `:tags` option to the Action View helper method `sanitize`. - the `:tags` option to the instance method `SafeListSanitizer#sanitize`. ## Workarounds Remove either "select" or "style" from the overridden allowed tags. |
Affected by 5 other vulnerabilities. |
|
VCID-efmb-65jk-7qc3
Aliases: CVE-2024-53989 GHSA-rxv5-gxqc-xx8g |
rails-html-sanitizer has XSS vulnerability with certain configurations ## Summary There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0. * Versions affected: 1.6.0 * Not affected: < 1.6.0 * Fixed versions: 1.6.1 ## Impact A possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer may allow an attacker to inject content if HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags in the following way: - the "noscript" element is explicitly allowed Code is only impacted if Rails is configured to use HTML5 sanitization, please see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information on these configuration options. The default configuration is to disallow all of these elements. Code is only impacted if allowed tags are being overridden. Applications may be doing this in a few different ways: 1. using application configuration to configure Action View sanitizers' allowed tags: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["noscript"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view 2. using a `:tags` option to the Action View helper `sanitize`: ``` <= sanitize @comment.body, tags: ["noscript"] > ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize 3. setting Rails::HTML5::SafeListSanitizer class attribute `allowed_tags`: ```ruby # class-level option Rails::HTML5::SafeListSanitizer.allowed_tags = ["noscript"] ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 4. using a `:tags` options to the Rails::HTML5::SafeListSanitizer instance method `sanitize`: ```ruby # instance-level option Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["noscript"]) ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 5. setting ActionText::ContentHelper module attribute `allowed_tags`: ```ruby ActionText::ContentHelper.allowed_tags = ["noscript"] ``` All users overriding the allowed tags by any of the above mechanisms to include "noscript" should either upgrade or use one of the workarounds. ## Workarounds Any one of the following actions will work around this issue: - Remove "noscript" from the overridden allowed tags, - Or, downgrade sanitization to HTML4 (see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information). ## References - [CWE - CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (4.9)](https://cwe.mitre.org/data/definitions/79.html) - Original report: https://hackerone.com/reports/2509647 ## Credit This vulnerability was responsibly reported by HackerOne user [@taise](https://hackerone.com/taise?type=user). |
Affected by 0 other vulnerabilities. |
|
VCID-fwd6-vspn-23ca
Aliases: CVE-2024-53986 GHSA-638j-pmjw-jq48 |
rails-html-sanitizer has XSS vulnerability with certain configurations ## Summary There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0. * Versions affected: 1.6.0 * Not affected: < 1.6.0 * Fixed versions: 1.6.1 ## Impact A possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer may allow an attacker to inject content if HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags in the following way: - the "math" and "style" elements are both explicitly allowed Code is only impacted if Rails is configured to use HTML5 sanitization, please see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information on these configuration options. The default configuration is to disallow these elements. Code is only impacted if allowed tags are being overridden. Applications may be doing this in a few different ways: 1. using application configuration to configure Action View sanitizers' allowed tags: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["math", "style"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view 2. using a `:tags` option to the Action View helper `sanitize`: ``` <= sanitize @comment.body, tags: ["math", "style"]> ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize 3. setting Rails::HTML5::SafeListSanitizer class attribute `allowed_tags`: ```ruby # class-level option Rails::HTML5::SafeListSanitizer.allowed_tags = ["math", "style"] ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 4. using a `:tags` options to the Rails::HTML5::SafeListSanitizer instance method `sanitize`: ```ruby # instance-level option Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["math", "style"]) ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 5. setting ActionText::ContentHelper module attribute `allowed_tags`: ```ruby ActionText::ContentHelper.allowed_tags = ["math", "style"] ``` All users overriding the allowed tags by any of the above mechanisms to include both "math" and "style" should either upgrade or use one of the workarounds. ## Workarounds Any one of the following actions will work around this issue: - Remove "math" or "style" from the overridden allowed tags, - Or, downgrade sanitization to HTML4 (see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information). ## References - [CWE - CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (4.9)](https://cwe.mitre.org/data/definitions/79.html) - Original report: https://hackerone.com/reports/2519941 ## Credit This vulnerability was responsibly reported by So Sakaguchi (mokusou). |
Affected by 0 other vulnerabilities. |
|
VCID-hg99-xn8y-r7gv
Aliases: CVE-2018-3741 GHSA-px3r-jm9g-c8w8 |
There is a possible XSS vulnerability in rails-html-sanitizer. The gem allows non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments, and these attributes can lead to an XSS attack on target applications. This issue is similar to CVE-2018-8048 in Loofah. |
Affected by 10 other vulnerabilities. |
|
VCID-mjgj-1qu6-bbb8
Aliases: CVE-2015-7578 GHSA-59c7-4xj2-hgvw |
Possible XSS vulnerability in rails-html-sanitizer There is a possible XSS vulnerability in rails-html-sanitizer. This vulnerability has been assigned the CVE identifier CVE-2015-7578. Versions Affected: All. Not affected: None. Fixed Versions: 1.0.3 Impact ------ There is a possible XSS vulnerability in rails-html-sanitizer. Certain attributes are not removed from tags when they are sanitized, and these attributes can lead to an XSS attack on target applications. All users running an affected release should either upgrade or use one of the workarounds immediately. Releases -------- The FIXED releases are available at the normal locations. Workarounds ----------- There are no feasible workarounds for this issue. Patches ------- To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset. * 1-0-sanitize_data_attributes.patch - Patch for 1.0 series Credits ------- Thanks to Ben Murphy and Marien for reporting this. |
Affected by 11 other vulnerabilities. |
|
VCID-n7zv-te79-kqee
Aliases: GHSA-qc8j-m8j3-rjq6 |
Moderate severity vulnerability that affects rails-html-sanitizer Withdrawn, accidental duplicate publish. Cross-site scripting (XSS) vulnerability in the rails-html-sanitizer gem before 1.0.3 for Ruby on Rails 4.2.x and 5.x allows remote attackers to inject arbitrary web script or HTML via crafted tag attributes. |
Affected by 11 other vulnerabilities. |
|
VCID-pfk5-ak74-bqgk
Aliases: CVE-2024-53987 GHSA-2x5m-9ch4-qgrr |
rails-html-sanitizer has XSS vulnerability with certain configurations ## Summary There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0. * Versions affected: 1.6.0 * Not affected: < 1.6.0 * Fixed versions: 1.6.1 ## Impact A possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer may allow an attacker to inject content if HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags in the following way: - the "style" element is explicitly allowed - the "svg" or "math" element is not allowed Code is only impacted if Rails is configured to use HTML5 sanitization, please see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information on these configuration options. The default configuration is to disallow all of these elements. Code is only impacted if allowed tags are being overridden. Applications may be doing this in a few different ways: 1. using application configuration to configure Action View sanitizers' allowed tags: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["style"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view 2. using a `:tags` option to the Action View helper `sanitize`: ``` <= sanitize @comment.body, tags: ["style"] > ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize 3. setting Rails::HTML5::SafeListSanitizer class attribute `allowed_tags`: ```ruby # class-level option Rails::HTML5::SafeListSanitizer.allowed_tags = ["style"] ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 4. using a `:tags` options to the Rails::HTML5::SafeListSanitizer instance method `sanitize`: ```ruby # instance-level option Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["style"]) ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 5. setting ActionText::ContentHelper module attribute `allowed_tags`: ```ruby ActionText::ContentHelper.allowed_tags = ["style"] ``` All users overriding the allowed tags by any of the above mechanisms to include "style" and omit "svg" or "math" should either upgrade or use one of the workarounds. ## Workarounds Any one of the following actions will work around this issue: - Remove "style" from the overridden allowed tags, - Or, downgrade sanitization to HTML4 (see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information). ## References - [CWE - CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (4.9)](https://cwe.mitre.org/data/definitions/79.html) - Original report: https://hackerone.com/reports/2519936 ## Credit This vulnerability was responsibly reported by So Sakaguchi (mnokusou). |
Affected by 0 other vulnerabilities. |
|
VCID-qny4-w14e-r7g2
Aliases: CVE-2015-7580 GHSA-ghqm-pgxj-37gq |
Possible XSS vulnerability in rails-html-sanitizer There is a possible XSS vulnerability in the white list sanitizer in the rails-html-sanitizer gem. This vulnerability has been assigned the CVE identifier CVE-2015-7580. Versions Affected: All. Not affected: None. Fixed Versions: v1.0.3 Impact ------ Carefully crafted strings can cause user input to bypass the sanitization in the white list sanitizer which will can lead to an XSS attack. Vulnerable code will look something like this: <%= sanitize user_input, tags: %w(em) %> All users running an affected release should either upgrade or use one of the workarounds immediately. Releases -------- The FIXED releases are available at the normal locations. Workarounds ----------- Putting the following monkey patch in an initializer can help to mitigate the issue: ``` class Rails::Html::PermitScrubber alias :old_scrub :scrub alias :old_skip_node? :skip_node? def scrub(node) if node.cdata? text = node.document.create_text_node node.text node.replace text return CONTINUE end old_scrub node end def skip_node?(node); node.text?; end end ``` Patches ------- To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset. * 1-0-whitelist_sanitizer_xss.patch - Patch for 1.0 series Credits ------- Thanks to Arnaud Germis, Nate Clark, and John Colvin for reporting this issue. |
Affected by 11 other vulnerabilities. |
|
VCID-sq1w-apet-2qfq
Aliases: CVE-2022-32209 GHSA-pg8v-g4xq-hww9 |
Possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer There is a possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer. This vulnerability has been assigned the CVE identifier CVE-2022-32209. Versions Affected: ALL Not affected: NONE Fixed Versions: v1.4.3 ## Impact A possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer may allow an attacker to inject content if the application developer has overridden the sanitizer's allowed tags to allow both `select` and `style` elements. Code is only impacted if allowed tags are being overridden. This may be done via application configuration: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["select", "style"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view Or it may be done with a `:tags` option to the Action View helper `sanitize`: ``` <%= sanitize @comment.body, tags: ["select", "style"] %> ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize Or it may be done with Rails::Html::SafeListSanitizer directly: ```ruby # class-level option Rails::Html::SafeListSanitizer.allowed_tags = ["select", "style"] ``` or ```ruby # instance-level option Rails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: ["select", "style"]) ``` All users overriding the allowed tags by any of the above mechanisms to include both "select" and "style" should either upgrade or use one of the workarounds immediately. ## Workarounds Remove either `select` or `style` from the overridden allowed tags. |
Affected by 9 other vulnerabilities. |
|
VCID-u9bs-nhvv-ruf6
Aliases: CVE-2022-23519 GHSA-9h9g-93gc-623h GMS-2022-8299 |
Possible XSS vulnerability with certain configurations of rails-html-sanitizer ## Summary There is a possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer. - Versions affected: ALL - Not affected: NONE - Fixed versions: 1.4.4 ## Impact A possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer may allow an attacker to inject content if the application developer has overridden the sanitizer's allowed tags in either of the following ways: - allow both "math" and "style" elements, - or allow both "svg" and "style" elements Code is only impacted if allowed tags are being overridden. Applications may be doing this in four different ways: 1. using application configuration: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["math", "style"] # or config.action_view.sanitized_allowed_tags = ["svg", "style"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view 2. using a `:tags` option to the Action View helper `sanitize`: ``` <%= sanitize @comment.body, tags: ["math", "style"] %> <%# or %> <%= sanitize @comment.body, tags: ["svg", "style"] %> ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize 3. using Rails::Html::SafeListSanitizer class method `allowed_tags=`: ```ruby # class-level option Rails::Html::SafeListSanitizer.allowed_tags = ["math", "style"] # or Rails::Html::SafeListSanitizer.allowed_tags = ["svg", "style"] ``` 4. using a `:tags` options to the Rails::Html::SafeListSanitizer instance method `sanitize`: ```ruby # instance-level option Rails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: ["math", "style"]) # or Rails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: ["svg", "style"]) ``` All users overriding the allowed tags by any of the above mechanisms to include (("math" or "svg") and "style") should either upgrade or use one of the workarounds immediately. ## Workarounds Remove "style" from the overridden allowed tags, or remove "math" and "svg" from the overridden allowed tags. |
Affected by 5 other vulnerabilities. |
|
VCID-ut5w-11x9-fyfp
Aliases: GHSA-77pc-q5q7-qg9h |
Moderate severity vulnerability that affects rails-html-sanitizer Withdrawn, accidental duplicate publish. Cross-site scripting (XSS) vulnerability in lib/rails/html/scrubbers.rb in the rails-html-sanitizer gem before 1.0.3 for Ruby on Rails 4.2.x and 5.x allows remote attackers to inject arbitrary web script or HTML via a crafted CDATA node. |
Affected by 11 other vulnerabilities. |
|
VCID-zxcr-zc3j-xfc9
Aliases: CVE-2024-53988 GHSA-cfjx-w229-hgx5 |
rails-html-sanitizer has XSS vulnerability with certain configurations ## Summary There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0. * Versions affected: 1.6.0 * Not affected: < 1.6.0 * Fixed versions: 1.6.1 ## Impact A possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer may allow an attacker to inject content if HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags in the following way: - the "math", "mtext", "table", and "style" elements are allowed - and either "mglyph" or "malignmark" are allowed Code is only impacted if Rails is configured to use HTML5 sanitization, please see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information on these configuration options. The default configuration is to disallow all of these elements except for "table". Code is only impacted if allowed tags are being overridden. Applications may be doing this in a few different ways: 1. using application configuration to configure Action View sanitizers' allowed tags: ```ruby # In config/application.rb config.action_view.sanitized_allowed_tags = ["math", "mtext", "table", "style", "mglyph"] # or config.action_view.sanitized_allowed_tags = ["math", "mtext", "table", "style", "malignmark"] ``` see https://guides.rubyonrails.org/configuring.html#configuring-action-view 2. using a `:tags` option to the Action View helper `sanitize`: ``` <= sanitize @comment.body, tags: ["math", "mtext", "table", "style", "mglyph"] > <# or > <= sanitize @comment.body, tags: ["math", "mtext", "table", "style", "malignmark"] > ``` see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize 3. setting Rails::HTML5::SafeListSanitizer class attribute `allowed_tags`: ```ruby # class-level option Rails::HTML5::SafeListSanitizer.allowed_tags = ["math", "mtext", "table", "style", "mglyph"] # or Rails::HTML5::SafeListSanitizer.allowed_tags = ["math", "mtext", "table", "style", "malignmark"] ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 4. using a `:tags` options to the Rails::HTML5::SafeListSanitizer instance method `sanitize`: ```ruby # instance-level option Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["math", "mtext", "table", "style", "mglyph"]) # or Rails::HTML5::SafeListSanitizer.new.sanitize(@article.body, tags: ["math", "mtext", "table", "style", "malignmark"]) ``` (note that this class may also be referenced as `Rails::Html::SafeListSanitizer`) 5. setting ActionText::ContentHelper module attribute `allowed_tags`: ```ruby ActionText::ContentHelper.allowed_tags = ["math", "mtext", "table", "style", "mglyph"] # or ActionText::ContentHelper.allowed_tags = ["math", "mtext", "table", "style", "malignmark"] ``` All users overriding the allowed tags by any of the above mechanisms to include ("math" and "mtext" and "table" and "style" and ("mglyph" or "malignmark")) should either upgrade or use one of the workarounds. ## Workarounds Any one of the following actions will work around this issue: - Remove "mglyph" and "malignmark" from the overridden allowed tags, - Or, downgrade sanitization to HTML4 (see documentation for [`config.action_view.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-view-sanitizer-vendor) and [`config.action_text.sanitizer_vendor`](https://guides.rubyonrails.org/configuring.html#config-action-text-sanitizer-vendor) for more information). ## References - [CWE - CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (4.9)](https://cwe.mitre.org/data/definitions/79.html) - Original report: https://hackerone.com/reports/2519936 ## Credit This vulnerability was responsibly reported by So Sakaguchi (mokusou). |
Affected by 0 other vulnerabilities. |
| Vulnerability | Summary | Aliases |
|---|---|---|
| This package is not known to fix vulnerabilities. | ||