diff --git a/ql/src/queries/security/cwe-079/ReflectedXSS.qhelp b/ql/src/queries/security/cwe-079/ReflectedXSS.qhelp index 12cd913e772..da33512ceb1 100644 --- a/ql/src/queries/security/cwe-079/ReflectedXSS.qhelp +++ b/ql/src/queries/security/cwe-079/ReflectedXSS.qhelp @@ -1,59 +1,55 @@ + "-//Semmle//qhelp//EN" + "qhelp.dtd"> - -

-Directly writing user input (for example, an HTTP request parameter) to a webpage -without properly sanitizing the input first, allows for a cross-site scripting -vulnerability. -

-
+ +

+ Directly writing user input (for example, an HTTP request parameter) to a webpage + without properly sanitizing the input first, allows for a cross-site scripting + vulnerability. +

+
- -

-To guard against cross-site scripting, consider escaping the input before -writing user input to the page. In some frameworks, such as Rails, escaping will -be performed implicitly and by default. -

-
+ +

+ To guard against cross-site scripting, consider escaping the input before + writing user input to the page. In some frameworks, such as Rails, escaping will + be performed implicitly and by default. +

- -

-For instance, the following example is safe because the -params[:user_name] content within the output tags will be -automatically HTML escaped before being output. -

- -
+

+ Care should be taken when using methods such as html_safe or + raw. These methods can be used to output a string without escaping + it. As such, they should only be used when the string has already been manually + escaped (for example, with the Rails html_escape method), or when + the content is otherwise guaranteed to be safe (such as a hard-coded string). +

+
- -

-Care should be taken when using methods such as html_safe or -raw. These methods can be used to output a string without escaping -it. As such, they should only be used when the string has already been manually -escaped (for example, with the Rails html_escape method), or when -the content is otherwise guaranteed to be safe (such as a hard-coded string). -

-
+ +

+ In the following example is safe because the + params[:user_name] content within the output tags will be + automatically HTML escaped before being output. +

+ - -

-The following example is unsafe because user-controlled input is output without -escaping due to being marked as html_safe. -

- -
+

+ However, the following example is unsafe because user-controlled input is + output without escaping due to being marked as html_safe. +

+ +
- -
  • -OWASP: -XSS -Ruby on Rails Cheatsheet. -
  • -
  • -Wikipedia: Cross-site scripting. -
  • -
    + +
  • + OWASP: + XSS + Ruby on Rails Cheatsheet. +
  • +
  • + Wikipedia: Cross-site scripting. +
  • +